Red and Green Wires

Combinator Building Blocks: Red and Green Wires

The simplest circuit networks is when two objects are connected with a red or green wire.

Any wire hooked up to a box will output the number of each item on the network. For example, this red wire example outputs (100 iron, 87 copper, 5 basic inserters). The red wire network can be read by connecting it to any electric pole, and then hovering the mouse over the pole. Should a second box with different items be connected to the same pole with the green network, you will be able to see the two distinct networks from the electric pole.

Sending information far away is as simple as stringing the green and/or red wire on the electric poles to an intended destination. Notice how the information in the red wire is now transmitted over three electric poles in this example. The green network is left behind.

However, information without any actuators is not very useful. To make things useful, hook up the red wire to an inserter, and configure the inserter to be enabled only when iron plates are less than some number.

Now, the red wire transmits the number of iron, and if there are fewer than 120 iron plates, the connected inserter grabs items and places them into the box. But signals can operate "across" datatypes as well. After all, that red wire is containing more information than just iron plates, but also copper plates and inserters.

To perform a decision based on multiple items, you can use the special signals "Everything" or "Anything". Later in this tutorial, I will explain an additional special signal called "Each", which occurs in arithmetic combinators.

If "Everything" must satisfy a condition, then all elements in the network must satisfy the condition. In this case, iron, copper, and inserters (the three elements in the Red Network) must all be < 150 for the inserter to be active. Programmers may think of this mapping the comparison across a boolean "AND" for every element in the signal. In this example, 150 Iron Plates will disable the yellow inserter, regardless of the other signals.

If "Anything" were instead chosen, then the condition is true as long as at least one element can satisfy the condition. With "Anything" 151 Iron Plates won't disable the inserter because Copper Plates and Inserters still are less than 150. Programmers can think of "Anything" as mapping a boolean "OR" across the entire vector of signals.

A value of zero is never transmitted on the signal network.

Note that the value zero is treated specially. A value of zero is never transmitted on the signal network. This means that any signals that are zero will be ignored in the "Anything" calculations. To check for the value of zero exactly, you should choose a specific item, such as iron or copper. See the following video, where the inserter refuses to work even with an empty chest with the value (Anything = 0).

Note that constant numbers aren't the only thing that can be used. Feel free to make arbitrary comparisons between any object in the game. The following picture compares Iron Plates against Copper Plates for example.

Furthermore, there are a set of signals that are simply mapped to letters A-Z, the numbers 0-9, and nine colors. This gives you the ability to use 45 signals that will never be output from a box. In a later secction, I’ll show how to use constant, decider, and arithmetic Combinators to take advantage of these player-custom signals.

Basic addition across the network

If multiple read-entities, such as boxes, are attached to one wire, the circuit network will simply add up ALL the values of all the read entities together. Note that you can "read" from many sources, including belts, inserters, roboports, storage tanks and of course... boxes.

In this example, I wire up three different boxes to a single red-wire network. The contents of the three boxes are

  • 5 Iron
  • 2 Iron
  • 1 Iron and 5 Copper

After all three are wired up together with red circuits, notice the output is (8 iron, 5 copper).

However, it is not always useful for signals to add together like this. For cases where the information needs to be kept isolated, use strings of green and red wire. Red and Green wire NEVER interfere with each other. Instead they only combine at an actuator point.

A lamp to only turn on if (iron = 13). The red network has 8 iron on it (combined from the three boxes), while the green network has 5 iron in it. When combined together in the lamp, the total iron equals 13 (8+5 = 13) so the lamp turns on. However, the green and red wires will keep the information on separate networks.

In conclusion: using nothing more than just red wires and green wires, you can count-up the amount of items across multiple boxes, transmit that information across long-distances using electric poles, and program inserters to intelligently act based on any particular signal, or two "grouped" signals: "Everything" and "Anything".

To add up values across multiple boxes (or other read entities), simply tie them together using the same wire. Or, use different wires (red vs green) to keep the information separated. You can add up values together in an actuator by connecting an actuator (like a lamp or inserter) to both the red and green wires.

Try wiring up belts, or setting inserters into read mode, or storage tanks to the circuit network. Belts and inserters are both read entities and actuators. Trains can be an actuator, scheduled to move based on the conditions of a circuit network hooked up to a train stop. Train signals can be read through the circuit network. Filter inserters and requester chests can be set so that their filters and requests are based on the value of the circuit network.

Some interesting read entities would be chests and belts, Roboports (read the contents of a logistical network or count the number of logistic bots doing tasks), storage tanks (read the contents of a fluid network), rail signals and chain signals (determine if a train is in a specific rail block), gates (determine if the player's avatar is close to a gate), and accumulators (determine the charge % level stored in an accumulator).