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,53 +1,66 @@
function SendPollutionStats()
if options.enablePollution then
local pollutionParts = {}
pollutionParts[#pollutionParts+1] = "---pollution-stats---\n"
for _,surface in pairs(game.surfaces) do
local surface_name = surface.name
local pollutionParts = {}
pollutionParts[#pollutionParts + 1] = "---pollution-stats---\n"
for _, surface in pairs(game.surfaces) do
local surface_name = surface.name
local pollution_input = game.surfaces[surface_name].pollution_statistics.input_counts
local pollution_output = game.surfaces[surface_name].pollution_statistics.output_counts
if surface.platform ~= nil then
surface_name = surface.platform.name
end
for name, stat in pairs(pollution_input) do
pollutionParts[#pollutionParts+1] = ("%s:in:%s:%d"):format(surface_name,name, stat)
end
local pollution_input = game.surfaces[surface_name].pollution_statistics.input_counts
local pollution_output = game.surfaces[surface_name].pollution_statistics.output_counts
for name, stat in pairs(pollution_output) do
pollutionParts[#pollutionParts+1] = ("%s:out:%s:%d"):format(surface_name,name, stat)
if surface.platform ~= nil then
surface_name = surface.platform.name
end
for name, stat in pairs(pollution_input) do
pollutionParts[#pollutionParts + 1] = ("%s:in:%s:%d"):format(surface_name, name, stat)
end
for name, stat in pairs(pollution_output) do
pollutionParts[#pollutionParts + 1] = ("%s:out:%s:%d"):format(surface_name, name, stat)
end
end
helpers.send_udp(udpAddress, table.concat(pollutionParts, "\n"), serverIndex)
end
helpers.send_udp(udpAddress, table.concat(pollutionParts,"\n"),serverIndex)
end
end
function SendKillStats()
if options.enableKills then
local killParts = {}
killParts[#killParts+1] = "---kill-stats---\n"
for _,surface in pairs(game.surfaces) do
local surface_name = surface.name
local killParts = {}
killParts[#killParts + 1] = "---kill-stats---\n"
for _, surface in pairs(game.surfaces) do
local surface_name = surface.name
local kill_input = game.forces["player"].get_kill_count_statistics(surface_name).input_counts
local kill_output = game.forces["player"].get_kill_count_statistics(surface_name).output_counts
if surface.platform ~= nil then
surface_name = surface.platform.name
end
for name, stat in pairs(kill_input) do
killParts[#killParts+1] = ("%s:in:%s:%d"):format(surface_name,name, stat)
end
local kill_input = game.forces["player"].get_kill_count_statistics(surface_name).input_counts
local kill_output = game.forces["player"].get_kill_count_statistics(surface_name).output_counts
for name, stat in pairs(kill_output) do
killParts[#killParts+1] = ("%s:out:%s:%d"):format(surface_name,name, stat)
if surface.platform ~= nil then
surface_name = surface.platform.name
end
for name, stat in pairs(kill_input) do
killParts[#killParts + 1] = ("%s:in:%s:%d"):format(surface_name, name, stat)
end
for name, stat in pairs(kill_output) do
killParts[#killParts + 1] = ("%s:out:%s:%d"):format(surface_name, name, stat)
end
end
helpers.send_udp(udpAddress, table.concat(killParts, "\n"), serverIndex)
end
helpers.send_udp(udpAddress, table.concat(killParts,"\n"),serverIndex)
end
end
function GetEvolution()
local evolutionParts = {}
local playerForce = game.forces["player"]
evolutionParts[#evolutionParts + 1] = "---evolution-stats---\n"
for _, surface in pairs(game.surfaces) do
evolutionParts[#evolutionParts + 1] = ("%s:%d:%d:%d:%d"):format(
surface.name,
playerForce.get_evolution_factor(surface),
playerForce.get_evolution_factor_by_pollution(surface),
playerForce.get_evolution_factor_by_time(surface),
playerForce.get_evolution_factor_by_killing_spawners(surface))
end
return table.concat(evolutionParts, "\n")
end