Page 1 of 1
LuaCircuitNetwork.signals_changed
Posted: Tue May 25, 2021 10:55 am
by DaveMcW
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.
Re: LuaCircuitNetwork.signals_changed
Posted: Sat Apr 15, 2023 10:10 am
by Hares
Great suggestion.
+1 on that
Re: LuaCircuitNetwork.signals_changed
Posted: Sat Apr 15, 2023 2:42 pm
by Rseding91
Changed compared to what?
Re: LuaCircuitNetwork.signals_changed
Posted: Sat Apr 15, 2023 3:17 pm
by Nidan
Judging from the final sentence, compared to the previous tick.
Re: LuaCircuitNetwork.signals_changed
Posted: Sun Apr 16, 2023 9:18 am
by boskid
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
Posted: Sun Apr 16, 2023 10:15 pm
by braxbro
DaveMcW wrote: Tue May 25, 2021 10:55 am
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.
Why not make an event out of it?
Re: LuaCircuitNetwork.signals_changed
Posted: Sun Apr 16, 2023 11:19 pm
by mrvn
braxbro wrote: Sun Apr 16, 2023 10:15 pm
DaveMcW wrote: Tue May 25, 2021 10:55 am
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.
Why not make an event out of it?
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
Posted: Mon Oct 09, 2023 9:49 am
by Hares
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.
I suppose an per-entity or per-entity-prototype event could also be a soultion, since it is the most-used case.
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.
Re: LuaCircuitNetwork.signals_changed
Posted: Sun Jul 07, 2024 3:43 am
by scruffyvoltherder
+1
This would be very useful
Re: LuaCircuitNetwork.signals_changed
Posted: Mon Jan 05, 2026 6:32 pm
by Yodo
Any chance for Factorio 2.1?
Re: LuaCircuitNetwork.signals_changed
Posted: Thu Jan 08, 2026 6:02 am
by protocol_1903
I'm working on a mod library for this use case since i doubt it will see proper implementation in the engine. Will be coming soon, hopefully.
mod link for those interested
Re: LuaCircuitNetwork.signals_changed
Posted: Thu Jan 08, 2026 8:38 am
by Hares
protocol_1903 wrote: Thu Jan 08, 2026 6:02 am
I'm working on a mod library for this use case since i doubt it will see proper implementation in the engine. Will be coming soon, hopefully.
mod link for those interested
I appreciate your determination.
However, the whole purpose for this request is to not perform on_tick events for each monitored network.
Re: LuaCircuitNetwork.signals_changed
Posted: Thu Jan 08, 2026 2:04 pm
by Yodo
Hares wrote: Thu Jan 08, 2026 8:38 am
However, the whole purpose for this request is to not perform on_tick events for each monitored network.
I'm pretty sure this request won't change that. You'll still have to check the value of
is_circuit_network_changed every tick, it's not an event.
Re: LuaCircuitNetwork.signals_changed
Posted: Thu Jan 08, 2026 2:10 pm
by Hares
Yodo wrote: Thu Jan 08, 2026 2:04 pm
Hares wrote: Thu Jan 08, 2026 8:38 am
However, the whole purpose for this request is to not perform on_tick events for each monitored network.
I'm pretty sure this request won't change that. You'll still have to check the value of
is_circuit_network_changed every tick, it's not an event.
Yeah, that's my point. The idea behind this feature request is to subscribe to a specific circuit network to reduce on_tick operations.
Re: LuaCircuitNetwork.signals_changed
Posted: Thu Jan 08, 2026 2:54 pm
by Yodo
An event on_signals_changed is not the same as a readable value /attribute is_signals_changed, I thought this thread was about the latter.
Re: LuaCircuitNetwork.signals_changed
Posted: Thu Jan 08, 2026 2:57 pm
by Hares
Yodo wrote: Thu Jan 08, 2026 2:54 pm
An event
on_signals_changed is not the same as a readable value /attribute
is_signals_changed, I thought this thread was about the latter.

I don't see if it is remotely usable.
Re: LuaCircuitNetwork.signals_changed
Posted: Sun Jan 11, 2026 6:15 pm
by protocol_1903
Hares wrote: Thu Jan 08, 2026 8:38 am
protocol_1903 wrote: Thu Jan 08, 2026 6:02 am
I'm working on a mod library for this use case since i doubt it will see proper implementation in the engine. Will be coming soon, hopefully.
mod link for those interested
I appreciate your determination.
However, the whole purpose for this request is to not perform on_tick events for each monitored network.
This is not going to be an on_tick per network. It will be a circuit network monitor that fires events when triggered.