New event on_control_behavior_changed

Things that we aren't going to implement
Post Reply
User avatar
Godmave
Long Handed Inserter
Long Handed Inserter
Posts: 89
Joined: Tue Nov 15, 2016 3:52 pm
Contact:

New event on_control_behavior_changed

Post by Godmave »

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.

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

Re: New event on_control_behavior_changed

Post by Rseding91 »

When you say "changed" do you mean changed by the player or changed as in the active color changed due to the circuit network value changing and or the enabled condition being true/false?
If you want to get ahold of me I'm almost always on Discord.

User avatar
Godmave
Long Handed Inserter
Long Handed Inserter
Posts: 89
Joined: Tue Nov 15, 2016 3:52 pm
Contact:

Re: New event on_control_behavior_changed

Post by Godmave »

The best option would be to be able to choose. The changed by player can be emulated by hooking the other two events (on_gui_closed and on_entity_settings_pasted)
The changed due to circuit-condition would catch all changes, but might lead to more (over-)load when you have lots of "flickering" lights. One good example for lots of lights would be this map:

https://factoriomaps.com/FactorioMMO/20 ... 6i-71.74i7

For more common scenarios it should be more efficient to get notified of changed states instead of having to check all lamps all the time via on_tick.

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

Re: New event on_control_behavior_changed

Post by Rseding91 »

Godmave wrote:For more common scenarios it should be more efficient to get notified of changed states instead of having to check all lamps all the time via on_tick.
That's not going to happen. The performance implications of firing events every time circuit conditions changed on any entity is not something I want to think about.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Won't implement”