Page 1 of 1
Inserting items into character-corpse
Posted: Fri Oct 15, 2021 11:43 pm
by Pi-C
If a player has died, we can access the inventory of the character-corpse per script. We can also use surface.create_entity() to spawn a character-corpse, and we can set properties like character_corpse_player_index, character_corpse_tick_of_death, and character_corpse_death_cause to make this corpse appear somewhat authentic. However, the corpse will have 0 slots in its inventory, and it seems there is no way to insert anything into it. Is there something I'm missing, or is there really no way to put some loot into a corpse created by script?
Re: Inserting items into character-corpse
Posted: Sat Oct 16, 2021 12:02 am
by Silari
When you spawn the corpse it takes a parameter that tells it what size you want the inventory to be: see
https://lua-api.factorio.com/latest/Lua ... ate_entity and look for the 'character-corpse' section, there's an inventory_size parameter. You can then interact with a corpse inventory the same way you do with any other entity inventory.
Re: Inserting items into character-corpse
Posted: Sat Oct 16, 2021 12:09 am
by Pi-C
Silari wrote: Sat Oct 16, 2021 12:02 am
When you spawn the corpse it takes a parameter that tells it what size you want the inventory to be
Thanks, that should work! It would have been too frustrating if I'd wasted two days' work only to find out that what I wanted to achieve was impossible.
