entity-ghost events?

Place to get help with not working mods / modding interface.
gheift
Fast Inserter
Fast Inserter
Posts: 188
Joined: Tue Mar 03, 2015 9:20 pm
Contact:

entity-ghost events?

Post 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
User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: entity-ghost events?

Post 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.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
gheift
Fast Inserter
Fast Inserter
Posts: 188
Joined: Tue Mar 03, 2015 9:20 pm
Contact:

Re: entity-ghost events?

Post 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.
ratchetfreak
Filter Inserter
Filter Inserter
Posts: 952
Joined: Sat May 23, 2015 12:10 pm
Contact:

Re: entity-ghost events?

Post 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?
gheift
Fast Inserter
Fast Inserter
Posts: 188
Joined: Tue Mar 03, 2015 9:20 pm
Contact:

Re: entity-ghost events?

Post 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.
Post Reply

Return to “Modding help”