Private
Public Access
1
0

Add metrics combinator entity, GUI, and related functionality; enhance power and production stats tracking

Greatly improved train trip perfomance by culling table after sending

Fixed formatting in many places
This commit is contained in:
Jan Grießhaber
2026-01-06 02:02:30 +01:00
parent 81e831a236
commit d58c24b8d4
11 changed files with 822 additions and 284 deletions

View File

@@ -1,3 +1,27 @@
protos = {}
--Experimental function, not in use right now
function GetProductionWithQuality(surface)
log("StartQualProd"..surface.name)
local prodWithQualityParts = {}
local prodstat = game.forces["player"].get_item_production_statistics(surface)
for key, _ in pairs(prodstat.input_counts) do
for quality,_ in pairs(prototypes.quality) do
local count = prodstat.get_input_count({name=key,quality=quality})
if count > 0 then
prodWithQualityParts[#prodWithQualityParts+1] =
surface.name..":"..
key..":"..
quality..":"..
count
end
end
end
log("EndQualProd"..surface.name)
return table.concat(prodWithQualityParts,"\n")
end
function SendProductionStats()
if options.enableProduction then
local productionParts = {}
@@ -5,6 +29,9 @@ function SendProductionStats()
for _,surface in pairs(game.surfaces) do
local surfaceName = surface.name
--TODO
--local test = GetProductionWithQuality(surface)
local inputStats = game.forces["player"].get_item_production_statistics(surfaceName).input_counts
local outputStats = game.forces["player"].get_item_production_statistics(surfaceName).output_counts
@@ -80,4 +107,13 @@ function SendBuildStats()
end
helpers.send_udp(udpAddress, table.concat(buildParts, "\n"), serverIndex)
end
end
end
function GetAllPrototypes()
for ID, _ in pairs(prototypes.item) do
for quality,_ in pairs(prototypes.quality) do
protos[#protos+1] = {name=ID,quality=quality}
end
end
end