Clearing signals in a wire / circuit network

Place to get help with not working mods / modding interface.
Post Reply
XYZT
Inserter
Inserter
Posts: 28
Joined: Fri Jun 07, 2019 3:40 pm
Contact:

Clearing signals in a wire / circuit network

Post 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?

User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 490
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: Clearing signals in a wire / circuit network

Post 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.

XYZT
Inserter
Inserter
Posts: 28
Joined: Fri Jun 07, 2019 3:40 pm
Contact:

Re: Clearing signals in a wire / circuit network

Post by XYZT »

Can you point me to the relevant Lua command for this?

User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 490
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: Clearing signals in a wire / circuit network

Post 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.

Post Reply

Return to “Modding help”