Indirect ghost destruction should trigger an event

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
NiftyManiac
Long Handed Inserter
Long Handed Inserter
Posts: 90
Joined: Sat Jan 21, 2017 12:01 am
Contact:

Indirect ghost destruction should trigger an event

Post by NiftyManiac »

When a ghost is destroyed via right-click, on_preplayer_mined_item is raised (but not on_player_mined_item, since there's no item stack).

However, when a robot places an item (causing the ghost to be removed), or when a ghost disappears due to the player placing an overlapping item, no event containing the ghost is fired. I think it'd be good if there was a consistent event representing the disappearance of a ghost.

Does there exist any method for detecting the second case? When on_entity_built is raised, the overlapping ghost is already gone. When on_put_item is raised, you can check if there's a ghost at the given position, but you don't know the size of the entity being placed to check for overlap. I suppose an ugly solution would be to store all of the nearby ghosts with on_put_item, and then check if any of them no longer exist when on_entity_built triggers.\

Edit: forgot that ghosts are also destroyed when marked with the deconstruction planner. This seems completely undetectable, since neither on_marked_for_deconstruction nor any other event is triggered. Even more reason to have a unified way to track ghost disappearance.

Post Reply

Return to “Modding interface requests”