diff --git a/config/death_logger.lua b/config/death_logger.lua index 53f8187a..7e03c2bb 100644 --- a/config/death_logger.lua +++ b/config/death_logger.lua @@ -4,7 +4,7 @@ return { --allow_teleport_to_body_command=false, -- allows use of /return-to-body which teleports you to your last death --allow_collect_bodies_command=false, -- allows use of /collect-body which returns all your items to you and removes the body - --use_chests_as_bodies=false, -- weather items should be moved into a chest when a player dies + use_chests_as_bodies=false, -- weather items should be moved into a chest when a player dies auto_collect_bodies=true, -- enables items being returned to the spawn point in chests upon corpse expiring show_map_markers=true, -- shows markers on the map where bodies are include_time_of_death=true, -- weather to include the time of death on the map marker diff --git a/expcore/common.lua b/expcore/common.lua index ab66e63f..aa70892a 100644 --- a/expcore/common.lua +++ b/expcore/common.lua @@ -239,7 +239,7 @@ function Public.move_items(items,surface,position,radius,chest_type) -- Makes a new emtpy chest when it is needed local function make_new_chest() local pos = surface.find_non_colliding_position(chest_type,position,32,1) - local chest = surface.surface.create_entity{name=chest_type,position=pos} + local chest = surface.create_entity{name=chest_type,position=pos,force='neutral'} table.insert(entities,chest) count = count + 1 return chest @@ -260,11 +260,14 @@ function Public.move_items(items,surface,position,radius,chest_type) end end -- Inserts the items into the chests + local last_chest for item_name,item_count in pairs(items) do local chest = next_chest{name=item_name,count=item_count} if not chest then return error(string.format('Cant move item %s to %s{%s, %s} no valid chest in radius',item.name,surface.name,p.x,p.y)) end Util.insert_safe(chest,{[item_name]=item_count}) + last_chest = chest end + return last_chest end return Public \ No newline at end of file diff --git a/modules/addons/death-logger.lua b/modules/addons/death-logger.lua index 9ffb31cf..938e550f 100644 --- a/modules/addons/death-logger.lua +++ b/modules/addons/death-logger.lua @@ -58,6 +58,13 @@ end Event.add(defines.events.on_player_died,function(event) local player = Game.get_player_by_index(event.player_index) local corpse = player.surface.find_entity('character-corpse',player.position) + if config.use_chests_as_bodies then + local items = corpse.get_inventory(defines.inventory.character_corpse).get_contents() + local chest = move_items(items,corpse.surface,corpse.position) + chest.destructible = false + corpse.destroy() + corpse = chest + end local death = { player_name = player.name, time_of_death = event.tick,