Page 1 of 1

entity-ghost events?

Posted: Fri Oct 02, 2015 2:31 pm
by gheift
Hello,

I try to build a combinator, which emits the ghosts in specific area as signals. My idea is to inital count the entites with find_entities_filtered and then modify the signal if ghosts are placed or removed. I listen to the following events:

Code: Select all

game.on_event(defines.events.on_built_entity,         place)
game.on_event(defines.events.on_robot_built_entity,   place)

game.on_event(defines.events.on_preplayer_mined_item, remove)
game.on_event(defines.events.on_robot_pre_mined,      remove)
game.on_event(defines.events.on_entity_died,          remove)
But neither when the ghosts times out nor if it is built by a robot or by hand I get an event for the removed ghost. Only if I remove it by hand the remove function is called. Do I miss an event or is no event triggered by the game?

Thanks,
Gerhard

Re: entity-ghost events?

Posted: Sat Oct 03, 2015 11:39 am
by Adil
Well you've tried it yourself. Ghosts are strange.
Also, what about newly placed ghosts in area of your combinator? They wouldn't be tracked by it if you don't run find_entities_ on regular basis.

Re: entity-ghost events?

Posted: Mon Oct 12, 2015 2:04 pm
by gheift
When a ghost entity is placed, there is an event, which can handle the update of such a combinator. The events for replaced ghosts or those which times out are missing.

Re: entity-ghost events?

Posted: Mon Oct 12, 2015 2:10 pm
by ratchetfreak
gheift wrote:When a ghost entity is placed, there is an event, which can handle the update of such a combinator. The events for replaced ghosts or those which times out are missing.
When the ghost is placed you can fill a array (sorted by time-until-expires) and on_tick you check each ghost that would expire now/is already expired if it has been refreshed and if it has reset the timeout in the array, otherwise trigger the "event"

is there an event for manual destruction?

Re: entity-ghost events?

Posted: Mon Oct 12, 2015 2:35 pm
by gheift
ratchetfreak wrote:is there an event for manual destruction?
When the ghost is removed by the player (via right click) an event is fired.

If the ghost is removed because a player or a robot has built the entity or a player places another building which overlaps with the ghost then no event is fired.