Private
Public Access
1
0

Added more functions

Streamlined the process
This commit is contained in:
Jan Grießhaber
2025-12-29 16:32:47 +01:00
parent 149b085cb7
commit 5accb091b0
6 changed files with 133 additions and 112 deletions

View File

@@ -1,18 +1,26 @@
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 pollutionParts = {}
local pollution_stats = game.surfaces[surface_name].pollution_statistics
local pollution_input = pollution_stats.input_counts
local pollution_output = pollution_stats.output_counts
pollutionParts[#pollutionParts+1] = ("---pollution-input---%s\n"):format(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:%d"):format(name, stat)
pollutionParts[#pollutionParts+1] = ("%s:in:%s:%d"):format(name,surface_name, stat)
end
pollutionParts[#pollutionParts+1] = ("---pollution-output---%s\n"):format(surface_name)
for name, stat in pairs(pollution_output) do
pollutionParts[#pollutionParts+1] = ("%s:%d"):format(name, stat)
pollutionParts[#pollutionParts+1] = ("%s:out:%s:%d"):format(name,surface_name, stat)
end
helpers.send_udp(52555, table.concat(pollutionParts,"\n"),1)
helpers.send_udp(udpAddress, table.concat(pollutionParts,"\n"),serverIndex)
end
end