55 lines
1.9 KiB
Lua
55 lines
1.9 KiB
Lua
function SendPollutionStats()
|
|
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(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
|
|
|
|
function SendKillStats()
|
|
if not (settings.global["factorio-prometheus-exporter-export_kill_stats"].value) then
|
|
return
|
|
end
|
|
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 |