Page 1 of 1

[Rseding] [0.17.74] missing corpse from on_post_entity_died

Posted: Sun Nov 03, 2019 4:28 am
by JuicyJuuce
So I'm editing the pvp.lua scenario and responding to an on_post_entity_died event. Specifically I'm trying to use it to look at the corpse of a player after they have died. However, event.corpses is empty (i.e. `{}`) even when a corpse has clearly been created. Here is my testing code inside on_post_entity_died:

Code: Select all

  if not (event.prototype.type == "character") then return end
  if event.corpses == nil then game.print("corpses nil") end
  game.print(serpent.block(event))
Result:Image

Re: [Rseding] [0.17.74] missing corpse from on_post_entity_died

Posted: Mon Nov 04, 2019 11:39 am
by Rseding91
Thanks for the report. That's working correctly: the character corpse is not a "corpse" type entity. It's a "character-corpse" type entity and so is done as a completely different system to standard corpses.

The generic event system for an entity dying doesn't know about this separate system that character entities use on death and so it's not in the event. You can however just entity-search for the character-corpse to find it.

If you only care about players dying then you can use https://lua-api.factorio.com/latest/eve ... layer_died