[0.15] Dead character inventory

Place to get help with not working mods / modding interface.
User avatar
mexmer
Filter Inserter
Filter Inserter
Posts: 870
Joined: Wed Aug 03, 2016 2:00 pm
Contact:

[0.15] Dead character inventory

Post by mexmer »

hello, anyone has ideas or knowledge about inventory access for dead characters?

seems following construct no longer works

Code: Select all

function on_player_died(event)
	local player = game.players[event.player_index]
	if player ~= nil then
			for i = 1, #storeinventories, 1 do
				local inventoryid = storeinventories[i]
				local playerinventory = player.get_inventory(inventoryid)
				for j = 1, #playerinventory, 1 do
						if playerinventory[j].valid and playerinventory[j].valid_for_read then
							local item = playerinventory[j]
							--[[ do something here ]]--
						end
				end
			end
	end
end
valid and valid_for_read always return false

mind this code was working in 0.14
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: [0.15] Dead character inventory

Post by Nexela »

You are aware that players drop corpses that contain their loot when they die?

Also you probably want on_player_pre_died or whatever it is called
User avatar
mexmer
Filter Inserter
Filter Inserter
Posts: 870
Joined: Wed Aug 03, 2016 2:00 pm
Contact:

Re: [0.15] Dead character inventory

Post by mexmer »

Nexela wrote:You are aware that players drop corpses that contain their loot when they die?

Also you probably want on_player_pre_died or whatever it is called
you sure about that corpse? because my corpse lays on rails after i got hit by train, and there is nothing to pickup.

i will move what i need into on_pre_playerd_died, as you suggest, will think about better solution later.

thanks for then info :mrgreen:
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: [0.15] Dead character inventory

Post by Nexela »

Player corpses on tracks seem to be hard to open, (they are just chests) If you mine the track up you should be able to loot your corpse
User avatar
mexmer
Filter Inserter
Filter Inserter
Posts: 870
Joined: Wed Aug 03, 2016 2:00 pm
Contact:

Re: [0.15] Dead character inventory

Post by mexmer »

Nexela wrote:Player corpses on tracks seem to be hard to open, (they are just chests) If you mine the track up you should be able to loot your corpse
btw. can't find any info about lootable corpse. when did that change?

if corpses were lootable, i will not need mod for storing inventory and craft queue in first place :D
Post Reply

Return to “Modding help”