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 +} 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