Private
Public Access
1
0
Files
lua-prometheus-exporter/pollution-stats.lua
Jan Grießhaber 5accb091b0 Added more functions
Streamlined the process
2025-12-29 16:32:47 +01:00

26 lines
978 B
Lua

function GetPollutionStats()
if not (settings.global["factorio-prometheus-exporter-export_pollution_stats"].value) then
return
end
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(name,surface_name, stat)
end
for name, stat in pairs(pollution_output) do
pollutionParts[#pollutionParts+1] = ("%s:out:%s:%d"):format(name,surface_name, stat)
end
helpers.send_udp(udpAddress, table.concat(pollutionParts,"\n"),serverIndex)
end
end