Private
Public Access
1
0
Files
lua-prometheus-exporter/game-stats.lua
Jan Grießhaber 149b085cb7 Initial Commit
2025-12-28 18:48:24 +01:00

22 lines
820 B
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 .. ("mod-info:%s:%s\n"):format(k,v)
end
helpers.send_udp(52555, modstring,1)
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] = ("player-time:%s:%d:%d"):format(player.name, player.index, player.online_time)
end
return table.concat(timeParts, "\n")
end