26 lines
978 B
Lua
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 |