Inserting items into character-corpse
Inserting items into character-corpse
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?
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Re: Inserting items into character-corpse
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
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.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!