1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-08 00:39:30 +02:00

Merge pull request #170 from Hyperdingo/master

Added container destruction logging if container has more than 100 ex…
This commit is contained in:
Gerkiz 2020-05-13 10:33:57 +02:00 committed by GitHub
commit 55cc921c86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 1 deletions

View File

@ -201,6 +201,30 @@ local function on_entity_died(event)
global.friendly_fire_history[#global.friendly_fire_history + 1] = str
end
local chest_types = {
["container"] = true,
["logistic-container"] = true
}
--Bad Fire History
local function on_entity_died_do_actual_usefull_logging(event)
if not event.cause then return end
if event.cause.name ~= "character" then return end
local player = event.cause.player
if not player then return end
if not chest_types[event.entity.type] then return end
if event.entity.get_item_count("explosives") < 100 then return end
if not global.bad_fire_history then global.bad_fire_history = {} end
if #global.bad_fire_history > 999 then global.bad_fire_history = {} end
local str = player.name .. " destroyed container with explosives amount: " .. event.entity.get_item_count("explosives") .. ", at location: "
str = str .. " at X:" .. event.entity.position.x .. " Y:" .. event.entity.position.y
global.bad_fire_history[#global.bad_fire_history + 1] = str
end
--Mining Thieves History
local function on_player_mined_entity(event)
if not event.entity.last_user then return end
@ -249,6 +273,7 @@ end
event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
event.add(defines.events.on_entity_died, on_entity_died)
event.add(defines.events.on_entity_died, on_entity_died_do_actual_usefull_logging)
event.add(defines.events.on_built_entity, on_built_entity)
event.add(defines.events.on_gui_opened, on_gui_opened)
event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction)

View File

@ -234,7 +234,8 @@ local create_admin_panel = (function (player, frame)
line.style.top_margin = 8
line.style.bottom_margin = 8
local histories = {}
local histories = {}
if global.bad_fire_history then table.insert(histories, "Bad Fire History") end
if global.friendly_fire_history then table.insert(histories, "Friendly Fire History") end
if global.mining_history then table.insert(histories, "Mining History") end
if global.landfill_history then table.insert(histories, "Landfill History") end
@ -258,6 +259,7 @@ local create_admin_panel = (function (player, frame)
local history = frame["admin_history_select"].items[frame["admin_history_select"].selected_index]
local history_index = {
["Bad Fire History"] = global.bad_fire_history,
["Friendly Fire History"] = global.friendly_fire_history,
["Mining History"] = global.mining_history,
["Landfill History"] = global.landfill_history,

View File

@ -58,6 +58,7 @@ function Public_chrono.restart_settings()
for _, player in pairs(game.connected_players) do
objective.flame_boots[player.index] = {fuel = 1, steps = {}}
end
global.bad_fire_history = {}
global.friendly_fire_history = {}
global.landfill_history = {}
global.mining_history = {}

View File

@ -223,6 +223,7 @@ function Public.reset_map()
game.forces.player.set_spawn_position({0, 21}, surface)
global.bad_fire_history = {}
global.friendly_fire_history = {}
global.landfill_history = {}
global.mining_history = {}