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

37 lines
1.3 KiB
Lua

---Sends all mod infos for the current game, should only be called on the first load of the map since mods don't change during runtime
function GetMods()
local mods = script.active_mods
local modstring = "---mod-info---\n"
for k,v in pairs(mods) do
modstring = modstring .. ("%s:%s\n"):format(k,v)
end
helpers.send_udp(udpAddress, modstring,serverIndex)
end
function GetMapSeed()
helpers.send_udp(udpAddress, ("---map-seed---\n%d"):format(game.surfaces["nauvis"].map_gen_settings.seed),serverIndex)
end
---Concats all player online times into a single string
---Takes all players that ever visited the server into account
---@return string
function GetPlayerTime()
local timeParts = {}
timeParts[#timeParts+1] = "---player-times---\n"
for _,player in pairs(game.players) do
timeParts[#timeParts+1] = ("%s:%d:%d"):format(player.name, player.index, player.online_time)
end
return table.concat(timeParts, "\n")
end
---comment
---@return string
function GetPlayerDeaths()
local deathParts = {}
deathParts[#deathParts+1] = "---player-deaths---\n"
for _,player in pairs(game.players) do
deathParts[#deathParts+1] = ("%s:%d:%d"):format(player.name, player.index, storage.playerDeathCount[player.index]or 0)
end
return table.concat(deathParts, "\n")
end