[MOD 0.12.31] Corpse Chest 1.0.0

Topics and discussion about specific mods
anjack
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sat Apr 23, 2016 5:17 am
Contact:

[MOD 0.12.31] Corpse Chest 1.0.0

Post 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

Long description
Pictures
Version history
Last edited by anjack on Mon May 02, 2016 4:17 am, edited 3 times in total.
apcnc
Inserter
Inserter
Posts: 20
Joined: Fri Apr 08, 2016 1:34 pm
Contact:

Re: [MOD 0.12.31] Corpse Chest 1.0.0

Post by apcnc »

german locale
anjack
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sat Apr 23, 2016 5:17 am
Contact:

Re: [MOD 0.12.31] Corpse Chest 1.0.0

Post by anjack »

apcnc wrote:
german locale
Thanks! Er... Danke!
fps_holland
Manual Inserter
Manual Inserter
Posts: 3
Joined: Thu Apr 28, 2016 5:44 pm
Contact:

Re: [MOD 0.12.31] Corpse Chest 1.0.0

Post by fps_holland »

Dutch translation

Code: Select all

[entity-name]
corpse-chest = Lijk
slush.filter
Manual Inserter
Manual Inserter
Posts: 1
Joined: Wed Apr 27, 2016 4:18 am
Contact:

Re: [MOD 0.12.31] Corpse Chest 1.0.0

Post by slush.filter »

Thanks, guys. We will add these to the next release.
anjack
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sat Apr 23, 2016 5:17 am
Contact:

Re: [MOD 0.12.31] Corpse Chest 1.0.0

Post by anjack »

Updated: https://github.com/anjackthemage/Corpse ... _1.0.1.zip

Thank you very much apcnc and fps_holland!
User avatar
Cyber_Garret
Burner Inserter
Burner Inserter
Posts: 14
Joined: Sat Jan 31, 2015 10:51 pm
Contact:

Re: [MOD 0.12.31] Corpse Chest 1.0.0

Post by Cyber_Garret »

Hi, found bug. If im die all ok, problem if my friend die in MP.
Image

and Russian and Ukrainian locale

Code: Select all

[entity-name]
corpse-chest = Труп
"What is locked, can be opened,
What is hidden, can be found,
What is yours, can be mine" (c) Garret

My English is very bad, sry.
anjack
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sat Apr 23, 2016 5:17 am
Contact:

Re: [MOD 0.12.31] Corpse Chest 1.0.0

Post by anjack »

Cyber_Garret wrote:Hi, found bug. If im die all ok, problem if my friend die in MP.
Image

and Russian and Ukrainian locale

Code: Select all

[entity-name]
corpse-chest = Труп
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
anjack
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sat Apr 23, 2016 5:17 am
Contact:

Re: [MOD 0.12.31] Corpse Chest 1.0.0

Post 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! :)
landwaster
Manual Inserter
Manual Inserter
Posts: 2
Joined: Wed May 04, 2016 2:56 pm
Contact:

Fix for crash when corpse chest is picked up or destroyed...

Post 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)
XBBX
Long Handed Inserter
Long Handed Inserter
Posts: 74
Joined: Wed Jan 07, 2015 4:30 pm
Contact:

Re: [MOD 0.12.31] Corpse Chest 1.0.0

Post by XBBX »

i get this error after death
Image
maby because i have alot items in my inventory?

Edit: increased chest size and now it works fine
Post Reply

Return to “Mods”