Update Version
This commit is contained in:
56
control.lua
56
control.lua
@@ -10,6 +10,8 @@ udpAddress = 52555
|
||||
isInitialized = false
|
||||
sendIndex = 0
|
||||
serverIndex = 0
|
||||
scannedGrids = false
|
||||
scannedLabs = false
|
||||
|
||||
options = {
|
||||
enableMod = false,
|
||||
@@ -82,6 +84,7 @@ script.on_configuration_changed(function()
|
||||
storage.scannedGrids = storage.scannedGrids or false
|
||||
storage.scannedLabs = storage.scannedLabs or false
|
||||
ScanNetworks()
|
||||
ScanLabs()
|
||||
end
|
||||
)
|
||||
|
||||
@@ -131,23 +134,29 @@ end)
|
||||
|
||||
|
||||
script.on_event(defines.events.on_player_died, function(event)
|
||||
if event.cause.is_player() then
|
||||
local killer_index = event.cause.player.index
|
||||
if event.cause and event.cause.player~=nil then
|
||||
|
||||
local killer = event.cause.player
|
||||
if not killer then return end
|
||||
local killer_index = killer.index
|
||||
|
||||
local victim_index = event.player_index
|
||||
log(("Player ID %d killed player ID %d"):format(killer_index,victim_index))
|
||||
|
||||
storage.playerKillCount[killer_index] =
|
||||
storage.playerKillCount[killer_index] or {}
|
||||
|
||||
storage.playerKillCount[killer_index][victim_index] =
|
||||
(storage.playerKillCount[killer_index][victim_index] or 0) + 1
|
||||
end
|
||||
--local player = game.get_player(event.player_index)
|
||||
end
|
||||
|
||||
storage.playerDeathCount[event.player_index] = (storage.playerDeathCount[event.player_index] or 0) + 1
|
||||
end)
|
||||
|
||||
|
||||
|
||||
function SendGameStats(event)
|
||||
function SendGameStats()
|
||||
if options.enablePlayers then
|
||||
local returnParts = {}
|
||||
GetMods()
|
||||
returnParts[#returnParts+1] = GetMapSeed()
|
||||
@@ -156,6 +165,7 @@ function SendGameStats(event)
|
||||
returnParts[#returnParts+1] = GetPlayerDeaths()
|
||||
returnParts[#returnParts+1] = GetPlayerKills()
|
||||
helpers.send_udp(udpAddress, table.concat(returnParts, "\n"), serverIndex)
|
||||
end
|
||||
end
|
||||
|
||||
function SendAll(event)
|
||||
@@ -171,23 +181,24 @@ function SendAll(event)
|
||||
end
|
||||
isInitialized = true
|
||||
|
||||
--log("ServerIndex is "..serverIndex.." now")
|
||||
|
||||
if storage.scannedGrids == false then
|
||||
if scannedGrids == false then
|
||||
ScanNetworks()
|
||||
storage.scannedGrids = true
|
||||
scannedGrids = true
|
||||
end
|
||||
|
||||
if storage.scannedLabs == false then
|
||||
if scannedLabs == false then
|
||||
ScanLabs()
|
||||
scannedLabs = true
|
||||
end
|
||||
|
||||
|
||||
if options.enableMod==true then
|
||||
|
||||
if (event.tick % math.floor(tickInterval/8) ~= 0) then return end
|
||||
local interval = math.max(1, math.floor(tickInterval / 9))
|
||||
if event.tick % interval ~= 0 then return end
|
||||
|
||||
sendIndex = (sendIndex % 8) + 1
|
||||
|
||||
sendIndex = (sendIndex % 9) + 1
|
||||
if sendIndex == 1 then SendProductionStats() end
|
||||
if sendIndex == 2 then SendPollutionStats() end
|
||||
if sendIndex == 3 then SendKillStats() end
|
||||
@@ -196,12 +207,8 @@ function SendAll(event)
|
||||
if sendIndex == 6 then SendResearchStats() end
|
||||
if sendIndex == 7 then SendLogisticStats() end
|
||||
if sendIndex == 8 then SendPowerStats() end
|
||||
|
||||
if(event.tick % tickInterval*2 == 0) then
|
||||
if options.enablePlayers then
|
||||
SendGameStats(event) end
|
||||
end
|
||||
end
|
||||
if sendIndex == 9 then SendGameStats()end
|
||||
end
|
||||
end
|
||||
|
||||
function UpdateStorage(event)
|
||||
@@ -222,8 +229,11 @@ function RemoveStorage(event)
|
||||
if event.entity.type == "electric-pole" then
|
||||
RemovePowerPole(event)
|
||||
end
|
||||
--log(event.entity.name)
|
||||
if event.entity.name == "crash-site-spaceship" then
|
||||
--log(event.name)
|
||||
if event.name == defines.events.on_player_mined_entity then
|
||||
--log("in ban call")
|
||||
if settings.global["factorio-metrics-exporter-enable_denkmalschutz"].value == true then
|
||||
game.ban_player(event.player_index,"You violated the rules of DENKMALSCHUTZ!!!")
|
||||
end
|
||||
@@ -234,11 +244,11 @@ end
|
||||
script.on_event(defines.events.on_tick, SendAll)
|
||||
|
||||
--Script hooks for power and lab stats
|
||||
script.on_event(defines.events.on_built_entity,UpdateStorage,{{filter = "type", type = "electric-pole" or "lab"}})
|
||||
script.on_event(defines.events.on_player_mined_entity, RemoveStorage,{{filter = "type", type = "electric-pole"or "lab" or "container"}})
|
||||
script.on_event(defines.events.on_robot_built_entity,UpdateStorage,{{filter = "type", type = "electric-pole" or "lab"}})
|
||||
script.on_event(defines.events.on_robot_mined_entity,RemoveStorage,{{filter = "type", type = "electric-pole" or "lab" or "container"}})
|
||||
script.on_event(defines.events.on_entity_died,RemoveStorage,{{filter = "type", type = "electric-pole" or "lab" or "container"}})
|
||||
script.on_event(defines.events.on_built_entity,UpdateStorage,{{filter = "type", type = "electric-pole"},{filter ="type", type="lab"}})
|
||||
script.on_event(defines.events.on_player_mined_entity, RemoveStorage,{{filter = "type", type = "electric-pole"},{filter ="type", type="lab"},{filter = "type", type="container"}})
|
||||
script.on_event(defines.events.on_robot_built_entity,UpdateStorage,{{filter = "type", type = "electric-pole"},{filter ="type", type="lab"}})
|
||||
script.on_event(defines.events.on_robot_mined_entity,RemoveStorage,{{filter = "type", type = "electric-pole"},{filter ="type", type="lab"},{filter = "type", type="container"}})
|
||||
script.on_event(defines.events.on_entity_died,RemoveStorage,{{filter = "type", type = "electric-pole"},{filter ="type", type="lab"},{filter = "type", type="container"}})
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user