Reference to LuaEntity of type "character-corpse" in "on_player_died" event data

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
User avatar
Impatient
Filter Inserter
Filter Inserter
Posts: 883
Joined: Sun Mar 20, 2016 2:51 am
Contact:

Reference to LuaEntity of type "character-corpse" in "on_player_died" event data

Post by Impatient »

I suggest to add a reference to the LuaEntity of the character-corpse that is associated with a character death, to the event data of "on_player_died". nil if for some reason no character-corpse was created. I can imagine, that the engine has that reference at hand, when the event fires.

Currently I can find a character-corpse associated with an on_player_died event by using find_entities_filtered at the position of death and then verifying matching player indexes and tick of death. But - always looking at possible extreme cases - there can be an arbitrary (large) number of character-corpses at that location (imagine idle players dieing at spawn over and over again).

A reference or some other unique identifier via which the LuaEntity for the character-corpse associated with that death event can be retreived at once without searching and iterating would be very convenient, unmistakable and fast.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15026
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Reference to LuaEntity of type "character-corpse" in "on_player_died" event data

Post by Rseding91 »

The corpse is included in on_entity_died in the corpses field.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Modding interface requests”