From 1f4e1b7d9b8ea66cdeaade7e9dccfcf5e4516663 Mon Sep 17 00:00:00 2001 From: Windsinger Date: Thu, 20 Oct 2022 15:29:19 +0200 Subject: [PATCH 1/2] Update deconlog.lua Add for regular rocket and explosive rocket + adding comma between timestamp and playername. --- modules/addons/deconlog.lua | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/modules/addons/deconlog.lua b/modules/addons/deconlog.lua index 4b2529d6..52b1914a 100644 --- a/modules/addons/deconlog.lua +++ b/modules/addons/deconlog.lua @@ -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 \ No newline at end of file +end From 6a98444710c94acebb2463bc1784b7fbf9b46d3c Mon Sep 17 00:00:00 2001 From: Windsinger Date: Sun, 23 Oct 2022 18:54:01 +0200 Subject: [PATCH 2/2] Update deconlog.lua added requested changes in /config/deconlog.lua --- config/deconlog.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/deconlog.lua b/config/deconlog.lua index ca46a0e1..b7fd5ab6 100644 --- a/config/deconlog.lua +++ b/config/deconlog.lua @@ -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 -} \ No newline at end of file +}