54 lines
1.8 KiB
Lua
54 lines
1.8 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 GetPlayerKills()
|
|
local killParts = {}
|
|
killParts[#killParts+1] = "---player-kills---\n"
|
|
for killerIndex, victims in pairs(storage.playerKillCount) do
|
|
for victimIndex, kills in pairs(victims) do
|
|
local killerName = game.players(killerIndex)
|
|
local victimName = game.players(victimIndex)
|
|
killParts[#killParts+1] = ("%s:%s:%s:%s:%d"):format(killerIndex,killerName,victimIndex,victimName,kills)
|
|
end
|
|
end
|
|
return table.concat(killParts,"\n")
|
|
end
|
|
|
|
function GetMapSeed()
|
|
return("---map-seed---\n%d"):format(game.surfaces["nauvis"].map_gen_settings.seed)
|
|
end
|
|
|
|
function GetRocketsLaunched()
|
|
return("---rocket-launches---\n%d"):format(game.forces["player"].rockets_launched)
|
|
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 |