Page 1 of 1
[MOD 0.12.31] Corpse Chest 1.0.0
Posted: Wed Apr 27, 2016 3:43 am
by anjack
Type: Mod
Name: Corpse Chest
Contributors: slush.filter, anjack
Description: Spawns a container upon your character's death to hold your inventory items for retrieval.
Version: 1.0.2
Release: 2016.05.02
Tested-With-Factorio-Version: 0.12.32
Category: SimpleExtension
Tags: Player, Entity
Download-Url:
https://github.com/anjackthemage/Corpse ... _1.0.2.zip
Website:
https://github.com/anjackthemage/Corpse_Chest
Re: [MOD 0.12.31] Corpse Chest 1.0.0
Posted: Wed Apr 27, 2016 1:23 pm
by apcnc
Re: [MOD 0.12.31] Corpse Chest 1.0.0
Posted: Wed Apr 27, 2016 2:26 pm
by anjack
Re: [MOD 0.12.31] Corpse Chest 1.0.0
Posted: Thu Apr 28, 2016 5:48 pm
by fps_holland
Re: [MOD 0.12.31] Corpse Chest 1.0.0
Posted: Fri Apr 29, 2016 2:23 am
by slush.filter
Thanks, guys. We will add these to the next release.
Re: [MOD 0.12.31] Corpse Chest 1.0.0
Posted: Fri Apr 29, 2016 2:37 am
by anjack
Re: [MOD 0.12.31] Corpse Chest 1.0.0
Posted: Sat Apr 30, 2016 8:34 pm
by Cyber_Garret
Hi, found bug. If im die all ok, problem if my friend die in MP.
and Russian and Ukrainian locale
Re: [MOD 0.12.31] Corpse Chest 1.0.0
Posted: Mon May 02, 2016 12:15 am
by anjack
Cyber_Garret wrote:Hi, found bug. If im die all ok, problem if my friend die in MP.
and Russian and Ukrainian locale
Thank you for the bug report (and the localization info!). I'll add an issue in github and track this down. A few questions: How many people were playing on the server? Did you already have a corpse chest when your friend's character was killed? What version of Factorio were you using?
Edit: Created an issue to track this:
https://github.com/anjackthemage/Corpse_Chest/issues/9
Re: [MOD 0.12.31] Corpse Chest 1.0.0
Posted: Mon May 02, 2016 4:19 am
by anjack
@Cyber_Garret:
Okay, we were able to reproduce the error you saw. We've released v1.0.2 which contains additional entity validation code that should fix this issue. Please test it and let us know if you see any more issues.
Thanks again for the localization info. We'll add it to the next update!

Fix for crash when corpse chest is picked up or destroyed...
Posted: Thu May 05, 2016 2:47 am
by landwaster
This will fix the corpse chest crash when the chest is picked up by a player or destroyed by a monster or player before the decay gets a chance to clean up the chest. The changes go into the control.lua file:
Code: Select all
require "defines"
-- Cycles through each item slot in each inventory (main, quick bar, armor, tool, guns, ammo) and moves any found items to the chest. Also checks player's cursor slot so any items in-hand will also be transferred.
function copyPlayerItems(player, dest)
local currStackIndex = 1
local currStackContent
local cursorStackContent = nil
local sInv -- source inventory
local dInv = dest.get_inventory(1) -- destination inventory
for inv = 1, 6 do
sInv = player.get_inventory(inv)
for index = 1, #sInv do
if sInv[index].valid_for_read then
currStackContent = sInv[index]
if dInv[currStackIndex].can_set_stack(currStackContent) then
dInv[currStackIndex].set_stack(currStackContent)
currStackIndex = currStackIndex + 1
end
end
end
end
cursorStackContent = player.cursor_stack
if dInv[currStackIndex].can_set_stack(cursorStackContent) then
dInv[currStackIndex].set_stack(cursorStackContent)
end
end
-- To track all the corpse chests in the world.
local corpseArray = {}
-- Hook into the "died" event. If it's a player, do our thing.
script.on_event(defines.events.on_entity_died, function(event)
if event.entity.name == "player" then
local player = event.entity
local targetPos = player.surface.find_non_colliding_position("corpse-chest", player.position, 10, 1)
if targetPos == nil then
entity.print("Corpse-Chest mod error: Nowhere to spawn corpse.")
return
end
-- Create the corpse-chest
local cChest = player.surface.create_entity({
name = "corpse-chest",
position = targetPos,
force = game.forces.neutral
})
if cChest == nil then
entity.print("Corpse-Chest mod error: Corpse spawn - Failed.")
return
end
-- Move each of the player's inventories over to the corpse-chest
copyPlayerItems(player, cChest)
-- When will the chest decay?
local expireTick = game.tick + 18000
table.insert(corpseArray, { dies=expireTick, position=cChest.position, corpse=cChest })
end
end)
-- Hook into the on_tick to check if chest should decay.
script.on_event(defines.events.on_tick, function(event)
local corpseArray = remote.call("CorpseChest", "get_corpses")
for index, object in pairs(corpseArray) do
if game.tick > object["dies"] then
game.get_surface(1).create_entity({name="stone", position=object["position"], force=game.forces.player}).destroy()
table.remove(corpseArray, index)
end
end
end)
interface = {
get_corpses = function() return corpseArray end
}
remote.add_interface("CorpseChest", interface)
Re: [MOD 0.12.31] Corpse Chest 1.0.0
Posted: Fri May 27, 2016 12:01 am
by XBBX
i get this error after death

maby because i have alot items in my inventory?
Edit: increased chest size and now it works fine