New event on_control_behavior_changed
Posted: Mon Jun 25, 2018 12:05 pm
Would fire when the the control_behavior of an entity gets changed.
My use-case:
At the moment I have to iterate all lamps on a map to see if there is any change (i.e. in use_colors)
An event that fires if there is a change would make a lot of useless iteration and checks disappear.
To not fire for stuff that is not interesting to the mod you could do something like the on_nth_tick event.
on_control_behavior_changed(defines.control_behavior.type.lamp, function(e)
-- do stuff with e.entity
end)
If this is not possible/wanted I might go the route of hooking the on_gui_closed and the on_entity_settings_pasted events to at least catch the changes done by players.
Getting an event whenever the color of a lamp changes might be a problem with lots of lamps flickering each tick, too. But that would be something one could implement in a way that at a certain amount of lamps the mod switches to some kind of iteration again on a table that gets update via that new event without immediate visual actions.
My use-case:
At the moment I have to iterate all lamps on a map to see if there is any change (i.e. in use_colors)
An event that fires if there is a change would make a lot of useless iteration and checks disappear.
To not fire for stuff that is not interesting to the mod you could do something like the on_nth_tick event.
on_control_behavior_changed(defines.control_behavior.type.lamp, function(e)
-- do stuff with e.entity
end)
If this is not possible/wanted I might go the route of hooking the on_gui_closed and the on_entity_settings_pasted events to at least catch the changes done by players.
Getting an event whenever the color of a lamp changes might be a problem with lots of lamps flickering each tick, too. But that would be something one could implement in a way that at a certain amount of lamps the mod switches to some kind of iteration again on a table that gets update via that new event without immediate visual actions.