I would like a read-only boolean property on LuaCircuitNetwork to tell when the contents of a circuit network have changed. I believe this already exists internally, it just needs to be exposed to Lua.
The use case is controlling modded buildings through the circuit network. With a fast way to see if a circuit network has changed, a mod can skip the time-consuming comparison of individual signals on ticks where nothing happened.
LuaCircuitNetwork.signals_changed
Re: LuaCircuitNetwork.signals_changed
Great suggestion.
+1 on that
+1 on that
Re: LuaCircuitNetwork.signals_changed
Changed compared to what?
If you want to get ahold of me I'm almost always on Discord.
Re: LuaCircuitNetwork.signals_changed
Judging from the final sentence, compared to the previous tick.
Re: LuaCircuitNetwork.signals_changed
Such value is indeed available but it is not save-load stable and as such i am not allowed to expose that without risks of desyncs. Due to way circuit network is implemented in 1.1, it is recomputing some values during first update after save was loaded (by client) even when those computations are not required on server. There are also some annoying behaviors related to this value as it may be spuriously set by some entities (i think roboport may be one of them) every tick even if the signals are not changing so it may not be useful in some cases. I may reconsider this once 1.2 would be released since the circuit network in 1.2 is implemented slightly differently causing less spurious notifications about changed signals and the value in 1.2 is save-load stable making it possible to be exposed here.
Re: LuaCircuitNetwork.signals_changed
That would generate an event for every single circuit network that has a change. You can't just listen to events on a specific circuit network (which would be really great).
Maybe there could be a new CircuitNetworkListener prototype, a new entity, that generates events. That way you would only get events where that entity is placed and connected.
Re: LuaCircuitNetwork.signals_changed
I suppose an per-entity or per-entity-prototype event could also be a soultion, since it is the most-used case.mrvn wrote: ↑Sun Apr 16, 2023 11:19 pm That would generate an event for every single circuit network that has a change. You can't just listen to events on a specific circuit network (which would be really great).
Maybe there could be a new CircuitNetworkListener prototype, a new entity, that generates events. That way you would only get events where that entity is placed and connected.
Plus, unlike per-network event, this will allow not worrying about player rewiring their stuff or scripts performing multiple (un)wire actions on the same tick.
-
- Burner Inserter
- Posts: 10
- Joined: Fri Jun 14, 2024 12:33 am
- Contact:
Re: LuaCircuitNetwork.signals_changed
+1
This would be very useful
This would be very useful