Page 1 of 1

No event called on destruction of ghost entity

Posted: Mon Jun 05, 2017 10:12 pm
by wakjah
I have been playing with the event API for item destruction and I have the events registered for entity destruction.

I can see that when I place a ghost entity and then mine it, some of these events are called - specifically, on_preplayer_mined_item.

If I use the deconstruction planner to remove the ghost entity, however, none of these events are called.

I have the following events registered to listen for destruction of an entity:

Code: Select all

script.on_event(defines.events.on_preplayer_mined_item, on_preplayer_mined_item)
script.on_event(defines.events.on_player_mined_item, on_player_mined_item)
script.on_event(defines.events.on_robot_pre_mined, on_robot_pre_mined)
script.on_event(defines.events.on_robot_mined, on_robot_mined)
script.on_event(defines.events.on_entity_died, on_entity_died)
script.on_event(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction)
and in each of the handlers I print a log message indicating the event that occurred.

Expected:
- One of these events is called when a ghost entity is destroyed with the deconstruction planner
- Consistent with what happens when a user mines the entity

What happens:
- None of them are called

Re: No event called on destruction of ghost entity

Posted: Mon Jun 05, 2017 10:16 pm
by Rseding91
Ghosts selected with the deconstruction planner fire no events because nothing happens to them except them being deleted. That's working as intended.

The player doesn't mine them and they aren't removed by robots they simply go away.