Greatly improved train trip perfomance by culling table after sending Fixed formatting in many places
67 lines
2.4 KiB
Lua
67 lines
2.4 KiB
Lua
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 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
|
|
|
|
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
|
|
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 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
|
|
|
|
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
|
|
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
|