Merge pull request #232 from Windsinger1985/patch-1

Update deconlog.lua
This commit is contained in:
Cooldude2606
2022-10-23 18:05:57 +01:00
committed by GitHub
2 changed files with 34 additions and 7 deletions

View File

@@ -5,5 +5,7 @@ return {
decon_area = true, ---@setting decon_area whether to log when an area is being deconstructed
built_entity = true, ---@setting built_entity whether to log when an entity is built
mined_entity = true, ---@setting mined_entity whether to log when an entity is mined
fired_rocket = true, ---@setting fired_nuke whether to log when a rocket is fired
fired_explosive_rocket = true, ---@setting fired_nuke whether to log when a explosive rocket is fired
fired_nuke = true, ---@setting fired_nuke whether to log when a nuke is fired
}
}

View File

@@ -26,7 +26,7 @@ if config.decon_area then
Event.add(defines.events.on_player_deconstructed_area, function (e)
local player = game.get_player(e.player_index)
if Roles.player_has_flag(player, "deconlog-bypass") then return end
add_log(get_secs() .. player.name .. ",decon_area," .. pos_tostring(e.area.left_top) .. "," .. pos_tostring(e.area.right_bottom))
add_log(get_secs() .. "," .. player.name .. ",decon_area," .. pos_tostring(e.area.left_top) .. "," .. pos_tostring(e.area.right_bottom))
end)
end
@@ -36,7 +36,7 @@ if config.built_entity then
local player = game.get_player(e.player_index)
if Roles.player_has_flag(player, "deconlog-bypass") then return end
local ent = e.created_entity
add_log(get_secs() .. player.name .. ",built_entity," .. ent.name .. "," .. pos_tostring(ent.position) .. "," .. tostring(ent.direction) .. "," .. tostring(ent.orientation))
add_log(get_secs() .. "," .. player.name .. ",built_entity," .. ent.name .. "," .. pos_tostring(ent.position) .. "," .. tostring(ent.direction) .. "," .. tostring(ent.orientation))
end)
end
@@ -45,20 +45,45 @@ if config.mined_entity then
local player = game.get_player(e.player_index)
if Roles.player_has_flag(player, "deconlog-bypass") then return end
local ent = e.entity
add_log(get_secs() .. player.name .. ",mined_entity," .. ent.name .. "," .. pos_tostring(ent.position) .. "," .. tostring(ent.direction) .. "," .. tostring(ent.orientation))
add_log(get_secs() .. "," .. player.name .. ",mined_entity," .. ent.name .. "," .. pos_tostring(ent.position) .. "," .. tostring(ent.direction) .. "," .. tostring(ent.orientation))
end)
end
if config.fired_rocket then
Event.add(defines.events.on_player_ammo_inventory_changed, function (e)
local player = game.get_player(e.player_index)
if Roles.player_has_flag(player, "deconlog-bypass") then return end
local ammo_inv = player.get_inventory(defines.inventory.character_ammo)
local item = ammo_inv[player.character.selected_gun_index]
if not item or not item.valid or not item.valid_for_read then return end
if item.name == "rocket" then
add_log(get_secs() .. "," .. player.name .. ",shot-rocket," .. pos_tostring(player.position) .. "," .. pos_tostring(player.shooting_state.position))
end
end)
end
if config.fired_explosive_rocket then
Event.add(defines.events.on_player_ammo_inventory_changed, function (e)
local player = game.get_player(e.player_index)
if Roles.player_has_flag(player, "deconlog-bypass") then return end
local ammo_inv = player.get_inventory(defines.inventory.character_ammo)
local item = ammo_inv[player.character.selected_gun_index]
if not item or not item.valid or not item.valid_for_read then return end
if item.name == "explosive-rocket" then
add_log(get_secs() .. "," .. player.name .. ",shot-explosive-rocket," .. pos_tostring(player.position) .. "," .. pos_tostring(player.shooting_state.position))
end
end)
end
if config.fired_nuke then
Event.add(defines.events.on_player_ammo_inventory_changed, function (e)
-- this works only if the player took more than one nuke, which they usually do
local player = game.get_player(e.player_index)
if Roles.player_has_flag(player, "deconlog-bypass") then return end
local ammo_inv = player.get_inventory(defines.inventory.character_ammo)
local item = ammo_inv[player.character.selected_gun_index]
if not item or not item.valid or not item.valid_for_read then return end
if item.name == "atomic-bomb" then
add_log(get_secs() .. player.name .. ",shot-bomb," .. pos_tostring(player.position) .. "," .. pos_tostring(player.shooting_state.position))
add_log(get_secs() .. "," .. player.name .. ",shot-nuke," .. pos_tostring(player.position) .. "," .. pos_tostring(player.shooting_state.position))
end
end)
end
end