Event raised when LuaGenericOnOffControlBehavior entity is disabled/enabled

Things that we aren't going to implement
Post Reply
Fractaliste
Inserter
Inserter
Posts: 28
Joined: Wed Dec 06, 2017 9:20 am
Contact:

Event raised when LuaGenericOnOffControlBehavior entity is disabled/enabled

Post by Fractaliste »

I'm currently implementing this functionnality with a on_nth_tick handler which call someSurface.find_entities_filtered() with a filter over train-stop entities, and then checking state throught control behaviour associated....
But I think this state change is already detected into C++ code to trigger the activated state, and raising a new event here would be much more efficient that my current implementation...

Rseding91
Factorio Staff
Factorio Staff
Posts: 13201
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Event raised when LuaGenericOnOffControlBehavior entity is disabled/enabled

Post by Rseding91 »

Fractaliste wrote:
Thu Jan 17, 2019 7:42 pm
But I think this state change is already detected into C++ code to trigger the activated state, and raising a new event here would be much more efficient that my current implementation...
While true, it would have too much overhead and be fired too frequently compared to not having the event at all (as it is now).
If you want to get ahold of me I'm almost always on Discord.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Event raised when LuaGenericOnOffControlBehavior entity is disabled/enabled

Post by DaveMcW »

Fractaliste wrote:
Thu Jan 17, 2019 7:42 pm
call someSurface.find_entities_filtered() with a filter over train-stop entities, and then checking state throught control behaviour associated...
You can improve your implementation by creating a global table of train stops indexed by unit_number and updated on built/destroyed events. This skips the find_entities_filtered() overhead.

Post Reply

Return to “Won't implement”