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...
Event raised when LuaGenericOnOffControlBehavior entity is disabled/enabled
-
- Inserter
- Posts: 28
- Joined: Wed Dec 06, 2017 9:20 am
- Contact:
Re: Event raised when LuaGenericOnOffControlBehavior entity is disabled/enabled
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).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...
If you want to get ahold of me I'm almost always on Discord.
Re: Event raised when LuaGenericOnOffControlBehavior entity is disabled/enabled
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.Fractaliste wrote: ↑Thu Jan 17, 2019 7:42 pmcall someSurface.find_entities_filtered() with a filter over train-stop entities, and then checking state throught control behaviour associated...