So two things:
1. When an entity is deconstructed by script with LuaEntity.order_deconstruction the event on_marked_for_deconstruction is not triggered even though the documentation says it is.
2. When a player mines an entity-ghost the on_preplayer_mined_item event is triggered. This is not the case when he deconstructs ghosts with a deconstruction planner (even though it is basically the same action). Neither on_preplayer_mined_item or on_marked_for_deconstruction is triggered and once on_player_deconstructed_area is triggered the ghosts are already destroyed.
[0.15.23] Deconstruction not triggering events
Re: [0.15.23] Deconstruction not triggering events
Thanks for the report. I've fixed the no-event when marked for deconstruction. The ghost(s) not firing events is intended. Ghosts aren't mined/processed - they're simply destroyed and cease to exist.
If you want to get ahold of me I'm almost always on Discord.
Re: [0.15.23] Deconstruction not triggering events
But the is on_preplayer_mined_item is fired when a player destroys a ghost by right clicking it. It is not fired when selecting a ghost with deconstruction planner which is inconsistent.Rseding91 wrote:Ghosts aren't mined/processed
My mods:
Re: [0.15.23] Deconstruction not triggering events
There's no inherit event that's fired when something is selected by blueprints or the deconstruction planner. When an entities state is changed from not-marked to marked or from marked to not-marked it fires an event - which isn't directly related to the deconstruction planner selecting the entities. Similar to how an entity being built destroys ghost entities without firing any event.321freddy wrote:But the is on_preplayer_mined_item is fired when a player destroys a ghost by right clicking it. It is not fired when selecting a ghost with deconstruction planner which is inconsistent.Rseding91 wrote:Ghosts aren't mined/processed
Now, I could add some event when a ghost is about to be deleted as a result of being selected by the deconstruction planner but it wouldn't go in the on-deconstruction-ordered event.
The main problem is figuring out what to name the event...
If you want to get ahold of me I'm almost always on Discord.
Re: [0.15.23] Deconstruction not triggering events
That would be perfect. What I originally wanted in my mod was to free some memory which was saved using the ghosts unit number which was useless as soon as the ghost became invalid (therefore I needed the events).Rseding91 wrote:Now, I could add some event when a ghost is about to be deleted as a result of being selected by the deconstruction planner but it wouldn't go in the on-deconstruction-ordered event.
The main problem is figuring out what to name the event...
So ideally it should be an event which is fired before a ghost is destroyed in any way and provides the ghost as a parameter.
Here are some naming suggestions:
on_pre_ghost_destroyed, on_pre_player_destroyed_ghost, on_ghost_became_invalid, on_ghost_vanished
Thanks a lot for the quick fix and your time
My mods: