---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 SendChunked(modstring) end function GetPlayerColors() local colorParts = {} colorParts[#colorParts + 1] = "---player-colors---\n" for index, player in pairs(game.players) do local colorSettings = player.color colorParts[#colorParts + 1] = ("%d:%s:%d:%d:%d:%d"):format(index, player.name, colorSettings.r, colorSettings.g, colorSettings.b, colorSettings.a) end return table.concat(colorParts, "\n") 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].name local victimName = game.players[victimIndex].name killParts[#killParts + 1] = ("%s:%s:%s:%s:%d"):format(killerName, killerIndex, victimName, victimIndex, kills) end end return table.concat(killParts, "\n") end function SendPlayerEntityStats() local resultParts = {} -- Localize for speed local insert = table.insert local prof = game.create_profiler() insert(resultParts, "---player-build-stats---") -- Process Constructed for playerIndex, items in pairs(storage.constructedEntites) do local playerName = game.players[playerIndex].name local prefix = playerIndex .. ":" .. playerName .. ":c:" for itemName, itemCount in pairs(items) do insert(resultParts, prefix .. itemName .. ":" .. itemCount) end end -- Process Deconstructed for playerIndex, items in pairs(storage.deconstructedEntities) do local playerName = game.players[playerIndex].name local prefix = playerIndex .. ":" .. playerName .. ":d:" for itemName, itemCount in pairs(items) do insert(resultParts, prefix .. itemName .. ":" .. itemCount) end end prof.stop() game.print(prof) SendChunked(table.concat(resultParts, "\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 resultParts = {} resultParts[#resultParts + 1] = "---player-times---\n" for _, player in pairs(game.players) do resultParts[#resultParts + 1] = ("%s:%d:%d"):format(player.name, player.index, player.online_time) end return table.concat(resultParts, "\n") end ---comment ---@return string function GetPlayerDeaths() local resultParts = {} resultParts[#resultParts + 1] = "---player-deaths---\n" for _, player in pairs(game.players) do resultParts[#resultParts + 1] = ("%s:%d:%d"):format(player.name, player.index, storage.playerDeathCount[player.index] or 0) end return table.concat(resultParts, "\n") end function onPlayerDeath(event) SendChunked(("---player-died---\n%s:%s:%d"):format(event.player_index,game.players[event.player_index].name,event.tick)) end function GetPlayerDeathCauses() local resultParts = {} resultParts[#resultParts + 1] = "---player-death-cause---\n" for playerIndex, deathCauses in pairs(storage.playerDeathCause) do for causeName, causeCount in pairs(deathCauses) do resultParts[#resultParts + 1] = ("%s:%d:%s:%d"):format(game.players[playerIndex].name, playerIndex, causeName, causeCount) end end return table.concat(resultParts, "\n") end function GetTotalPlayTime() return ("---game-time---\n%d:%d"):format(game.tick, game.ticks_played) end function CheckReactor(event) if not event and not event.entity then return end if event.entity.name == "nuclear-reactor" then if event.entity.temperature >= 900 then storage.nuclearReactorDeaths = (storage.nuclearReactorDeaths or 0) + 1 end end end function GetReactorExplosions() return "---reactor-explosion---\n" .. (storage.nuclearReactorDeaths or 0) end