Page 1 of 1
Clearing signals in a wire / circuit network
Posted: Mon Jun 07, 2021 12:23 am
by XYZT
Hi,
I am looking for a command to clear the signals in a circuit network. Let's say, there's a green wire carrying some frame of signals. Is there a Lua command to "set signal" or "clear/reset signals" in a particular wire?
Looking at the Factorio Lua API, most attributes are read-only and I can't find a function that let's me alter or clear the signal information in a particular wire (or all wires) via a Lua command.
Is there a way to achieve this?
Re: Clearing signals in a wire / circuit network
Posted: Mon Jun 07, 2021 3:15 am
by Silari
You can't do that because wires don't store signals, they're just passing along the signals given to them by the attached entities. If you want to remove a signal, you'd need to find whatever entities are adding a value to that signal and remove them. As an example, if you want to remove the wood signal from a network, and that wood signal is being set by a constant combinator, you can alter the settings of that combinator via the API to stop it from sending the wood signal, and thus remove it from the network.
Re: Clearing signals in a wire / circuit network
Posted: Mon Jun 07, 2021 4:32 am
by XYZT
Can you point me to the relevant Lua command for this?
Re: Clearing signals in a wire / circuit network
Posted: Mon Jun 07, 2021 5:53 am
by Silari
Can't say I know exactly how you'd handle finding everything.
Far as I can see there's no easy way to get all the entities that are part of a network. You might be able to use
https://lua-api.factorio.com/latest/Lua ... d_entities on an entity in the network to get everything directly connected to your starting point, then call that again on each of those entities, and keep going through to find everything on the network. Then do it all again if you want it for the other kind of wire.
LuaEntity.get_control_behavior() can get the
LuaControlBehavoir of an entity which is how you'd configure what signals it send, like what a constantcombinator is sending. Keep in mind what you have available changes a lot based on what kind of entity it is.