From cb2e6fec50cecb1af460079d6f04d90126453519 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grie=C3=9Fhaber?= Date: Tue, 6 Jan 2026 16:20:45 +0100 Subject: [PATCH] Fixed send size of player entity stats --- .vscode/settings.json | 2 +- control.lua | 6 ++++-- game-stats.lua | 7 +++++-- info.json | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 2fa9811..b176754 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { "Lua.workspace.userThirdParty": [ - "c:\\Users\\jangr\\AppData\\Roaming\\Code\\User\\workspaceStorage\\efbcb086d2b4a3aca622c4db8c3b2aec\\justarandomgeek.factoriomod-debug\\sumneko-3rd" + "c:\\Users\\jangr\\AppData\\Roaming\\Code\\User\\workspaceStorage\\14f36f4acfd74cd0fa85ac34cb84b920\\justarandomgeek.factoriomod-debug\\sumneko-3rd" ], "Lua.workspace.checkThirdParty": "ApplyInMemory", "factorio.versions": [ diff --git a/control.lua b/control.lua index 86344e0..67bb5a3 100644 --- a/control.lua +++ b/control.lua @@ -240,7 +240,6 @@ function SendGameStats() returnParts[#returnParts + 1] = GetPlayerDeaths() returnParts[#returnParts + 1] = GetPlayerDeathCauses() returnParts[#returnParts + 1] = GetPlayerKills() - returnParts[#returnParts + 1] = GetPlayerEntityStats() helpers.send_udp(udpAddress, table.concat(returnParts, "\n"), serverIndex) end end @@ -280,7 +279,10 @@ function SendAll(event) sendIndex = (sendIndex % 10) + 1 if sendIndex == 1 then SendProductionStats() end if sendIndex == 2 then SendPollutionStats() end - if sendIndex == 3 then SendKillStats() end + if sendIndex == 3 then + SendKillStats() + SendPlayerEntityStats() + end if sendIndex == 4 then SendFluidProductionStats() end if sendIndex == 5 then SendBuildStats() end if sendIndex == 6 then diff --git a/game-stats.lua b/game-stats.lua index 7631007..4375a54 100644 --- a/game-stats.lua +++ b/game-stats.lua @@ -32,7 +32,7 @@ function GetPlayerKills() return table.concat(killParts, "\n") end -function GetPlayerEntityStats() +function SendPlayerEntityStats() local entityParts = {} entityParts[#entityParts + 1] = "---player-build-stats---" for playerIndex, items in pairs(storage.constructedEntites) do @@ -41,13 +41,16 @@ function GetPlayerEntityStats() entityParts[#entityParts + 1] = ("%s:%s:constructed:%s:%s"):format(playerIndex, playerName, itemName, itemCount) end end + helpers.send_udp(udpAddress,table.concat(entityParts,"\n",serverIndex)) + entityParts = {} + entityParts[#entityParts + 1] = "---player-build-stats---" for playerIndex, items in pairs(storage.deconstructedEntities) do local playerName = game.players[playerIndex].name for itemName, itemCount in pairs(items) do entityParts[#entityParts + 1] = ("%s:%s:deconstructed:%s:%s"):format(playerIndex, playerName, itemName, itemCount) end end - return table.concat(entityParts, "\n") + helpers.send_udp(udpAddress,table.concat(entityParts,"\n",serverIndex)) end function GetMapSeed() diff --git a/info.json b/info.json index 90dae8c..af50b7b 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "factorio-metrics-exporter", - "version": "0.3.2", + "version": "0.3.3", "title": "Prometheus Metrics Exporter", "author": "Jan Grießhaber", "contact": "jan@griesshaber.systems",