LuaCircuitNetwork.signals_changed

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3717
Joined: Tue May 13, 2014 11:06 am
Contact:

LuaCircuitNetwork.signals_changed

Post 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.
User avatar
Hares
Filter Inserter
Filter Inserter
Posts: 387
Joined: Sat Oct 22, 2022 8:05 pm
Contact:

Re: LuaCircuitNetwork.signals_changed

Post by Hares »

Great suggestion.
+1 on that
Rseding91
Factorio Staff
Factorio Staff
Posts: 14363
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: LuaCircuitNetwork.signals_changed

Post by Rseding91 »

Changed compared to what?
If you want to get ahold of me I'm almost always on Discord.
Nidan
Filter Inserter
Filter Inserter
Posts: 270
Joined: Sat Nov 21, 2015 1:40 am
Contact:

Re: LuaCircuitNetwork.signals_changed

Post by Nidan »

Judging from the final sentence, compared to the previous tick.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3063
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: LuaCircuitNetwork.signals_changed

Post 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.
braxbro
Inserter
Inserter
Posts: 22
Joined: Sun Jan 01, 2023 2:54 am
Contact:

Re: LuaCircuitNetwork.signals_changed

Post 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?
mrvn
Smart Inserter
Smart Inserter
Posts: 5925
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: LuaCircuitNetwork.signals_changed

Post 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.
User avatar
Hares
Filter Inserter
Filter Inserter
Posts: 387
Joined: Sat Oct 22, 2022 8:05 pm
Contact:

Re: LuaCircuitNetwork.signals_changed

Post 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.
scruffyvoltherder
Burner Inserter
Burner Inserter
Posts: 10
Joined: Fri Jun 14, 2024 12:33 am
Contact:

Re: LuaCircuitNetwork.signals_changed

Post by scruffyvoltherder »

+1

This would be very useful
Post Reply

Return to “Modding interface requests”