Hello, hello and welcome.
My name is MiniBetrayal and this is a Factorio tutorial - circuits and circuit networks.
Now before the length of this video frightens you off, you should know that this video is
not necessarily meant to be viewed all at once or even in order.
I'll be covering everything from the absolute basics for those who have never touched the
circuit network before, right up to some worked examples of common builds.
At any time, feel free to check the video description where I'll post timestamps to
each part of the video.
Skip forward, back, however you please based on what you'd like to learn.
Or watch the video all at once.
I'm not the police.
Factorio can be quite daunting at times, especially if you're new to the game and see some of
the massively complex megabases and intricate builds that some people share on youtube,
reddit and the like.
Arguably one of the most complex parts of the game is the circuit network, but like
a entire language that is built from just a few letters arranged in increasing layers,
even the most convoluted circuit builds are built on a few relatively simple rules which
I'll aim to share with you in this video.
In the latter part of the video there are a number of worked examples, and I'll post
a link to a blueprint book containing blueprints of each of the examples I show you.
This is the first time I have tried making a video quite like this, and I've tried to
make things as easy to follow as I can.
If you have any questions or comments, please feel free to leave them below and I'll answer
them if I can.
If I get enough questions I may post a follow-up video and if there's enough interest I may
do other, similar videos on other topics within factorio.
Enjoy!
Let's start off with the research.
The Circuit Network research can be completed relatively early in the game, with the only
prerequisite being Electronics 1, and costing just 100 of each science packs 1 and 2.
Once completed, this will unlock two types of wire, coloured red and green, three types
of combinator, called Arith-MET-ic or a-RITH-metic, decider and constant, a power switch and a
programmable speaker.
These can each be combined with each other and other in-game entities to perform all
sorts of computations and functions, from simple commands like switching off production
of a given item once you have a stockpile built up, to vastly more complex tasks like
working computers within the game!
Now let's continue by looking at the materials that the research allows access to, we first
have two kinds of wire, red and green.
Both take the same parts to craft, a copper cable and an electronic circuit, and they're
both used to carry signals from one place to another.
A single cable can reach over shorter distances, for example from a box to an inserter, but
several cables can be hooked up via any of the three types of power poles to transmit
signals over a much longer distance, even from one side of the map to the other.
So why are there two colours of cable and what's the difference between them?
The simple answer is that there is no difference, and either can be used for any task the other
could also be used for.
The reason for having two colours comes down to the fact that sometimes you want to carry
two different signals along the same path, and by sending one signal down each of the
coloured cables, you can avoid cross-contamination of the signals.
Now I can't progress much further without talking about what kind of signals you can
send across a wire, and how they interact with each other.
Factorio includes a large number of different signals, based on the in-game items plus numbers,
an alphabet, and some simple colours.
The easiest way to see this in action is to use a cable - of either colour - to connect
a chest to a power pole.
If you then place any item in the chest, you can then mouseover the power pole to see what
is being carried along the wire.
Here you can see that the wire is carrying a signal of 1 Iron plate.
If I place another plate in the chest, the signal changes to 2 iron plate.
If I place a copper plate in the same chest, the cable now carries a signal or 2 iron plate
and 1 copper plate.
You'll notice that the signals on the power pole have a red backgroud.
This is because the signals are being carried by the red wire.
I'll now place a second chest and connect it to the same pole with a green wire, and
then move the copper plate to the second chest and check the power pole, you can now see
that the signal of two iron plate still has a red background, but the copper plate has
a green background, indicating it is being carried by the green wire.
I'll now demonstrate how the two colours of cable can be used to transmit signals together
by adding a third chest, hooked to the pole with the red wire.
If I put another iron plate in this chest and check the pole, you can see that the contents
of the two chests are added together, 2 iron plates plus 1 iron plate is 3 iron plates.
This is because like-signals on the same colour of wire are added together.
If I take that third iron plate and put in the second chest - that is, the one with the
green wire - you can see that this plate has been added to the green signals with the copper
plate and is therefore not mixed with the other iron plates on the red wire.
It's also worth mentioning that the chests do not need to be connected directly to the
power pole.
Signals are added together along the entire length of the wire, so if the chests are connected
like this, from chest to chest and then to the pole, the same principal still holds.
This is the primary use of the two-colour wire system, though most simple circuit networks
don't really need two colours, meaning you can simplify things and use only one colour,
which can make things look a little neater if you like that sort of thing.
Alternatively, you can use the colour of the wire to indicate input vs. output, or stuff
you have vs. stuff you need, or anything else you can come up with.
Hooking up a chest, or multiple chests to a power pole is already a very simple network,
and is a great way to see how many materials you have in a buffer system for example, without
having to mouseover each chest individually.
Just by checking the connected power pole, you can see at a glance, how many iron ore
you have in your unloading station, or how many forgotten pistols you have in your storage
dumping area.
After the wires, we have combinators, and this is where the vast majority of the logic
of the circuit network takes place.
Firstly, I'll start with the constant combinator, as it is the simplest.
It has a connection point, to which you can attach a red or green wire, and I'll hook
one up to a power pole now so we can see what it does.
When you click on the constant combinator, you are presented with an interface like this,
with fifteen empty boxes and an on/off toggle.
Note that this tutorial is made with Factorio 0.16, and there is a GUI remodel planned for
the 0.17 release, so if you are watching this in the future, what you see may be a little
different, but I don't expect the general idea will change too much.
Now, by clicking on one of the boxes, you are presented with a window like this, which
lists every in-game item, including liquids in a separate tab, and another tab just for
numbers, letters and colours.
If we select, say, a transport belt to place in this first box, you can see there is now
a slider that allows us to set the number of transport belts, or a box we can set the
number directly.
If we set the number to 27 and then check our connected power pole, you can see that
the wire is carrying a signal of 27 transport belts.
In essense, the constant combinator acts exactly like a chest, except we don't need to physically
have the items we want to send along the wire.
The constant combinator also comes with another couple of tricks.
For example, we can select a fluid to send along the wire as well as a transport belt.
While this is technically possible without the combinator - you can also hook up a storage
tank like you can a chest - it is much easer to set an exact number of fluid with the combinator.
The last tab in the combinator allows us to set an abstract number, letter or colour signal,
sometimes known as virtual signals.
These are not in-game items, but can be used as 'extra' signals if you need them; they
work exactly the same as any other signal.
The last trick the constant combinator has up it's sleeve is the on-off toggle.
If you find yourself in a situation where you no longer want to send your signal along
the wire, you could remove each item in the combinator, you could deconstruct the combinator,
or detach it from the network, but if you know you're going to need those same numbers
again later, just toggle the switch to the 'off' position and the combinator will no
longer send its signal, allowing you to simply switch it back on again later.
Moving on, let's discuss the arithmetic combinator.
The first thing to note is that, unlike the constant combinator, the arithmetic combinator
needs to be powered, otherwise it's not going to work.
Secondly, you'll notice that much like an inserter, it has an 'in' and an 'out'.
Pay attention to these, because when you hook up your wires it is very important to get
them connected to the right point or you'll end up with unexpected results.
I'll demonstrate how it works by placing one here, hooking the 'out' end to a power pole
so we can see what's going on.
I'll hook the 'in' end to a constant combinator, which I'll leave empty for now.
Let's click on the arithmetic combinator and discuss what we see.
First up, we have two sections, an input and an output.
The input section is then split into three parts, with a box here, a box here, and an
operator between them.
To start, let's leave the operator as the asterisk or star symbol, which means multiplication.
When you click on the boxes here, we see something much like the signal selection window we saw
with the constant combinator, but with a couple of extra items.
firstly, if we look down the bottom, we can set a constant number instead of a signal.
For example, if we wanted to multiply something by 2, we could just choose '2', and set the
operator to multiplication.
Let's set the second box to a constant of 2 now.
Be careful not to select the signal called 2, as thats a different thing.
If we now go to the first box, we can select the signal we want to perform the operation
on.
For example, lets choose the copper plate signal.
This means that the combinator will look for copper plate among its inputs, and if it is
there, will multiply it by two, then pass the result to the output.
Now that's done, we need to tell the combinator what type of signal to output.
We could select copper plate again, but let's choose something different, copper cable.
So now, what the combinator should do is to see how many copper plate signals are coming
in, multiply it by two, and output the result as that many copper cables, efectively a little
calculator to tell us how many cables we can make from a number of plates.
Of course, if we mouseover the power pole now, we see nothing as the arithmetic combinator
is not receiving any inputs at all, so let's go over to the constant combinator and add
a signal of 1 copper plate.
If we mouseover the pole now, we can see that we are indeed getting a signal of two copper
cables.
If you mouseover the arithmetic combinator itself, you can see that the info bar contains
sections for input and output signals as well.
one copper plate to two copper cables.
If we go back to the constant combinator and add another signal, this time an iron plate,
we can check that nothing else happens.
The arithmetic combinator is only looking for copper plate signals, so ignores the rest.
one copper plate and one iron plate still only outputs two copper cables.
This means the arithmetic combinator can be a good way to isolate one signal from a wire
carrying lots.
[[set constant combinator to 1 raw wood, 2 coal, 3 stone, etc]]]
For example, if we have a wire carrying different numbers of each raw resource, and we want
to isolate only the uranium ore for example, we could set the arithmetic cominator to only
look for uranium ore signals, multiply by 1, and output that result as uranium ore again.
That way, it will look for the right signal, multiply it by 1 - which does nothing to change
the actual value of that signal, and pass it on.
But what if we want to perform an operation on everything coming down the wire.
Do we need to set up a different arithmetic combinator for every possible signal?
No, of course not.
If we go into the 'signals' tab of the first input box of the arithmetic combinator, you
can see an extra feature here, a yellow box with a star in that - if we mouseover it - tells
us it is called 'Each', and it will perform the operation on each of the input signals.
If we do that, and check the combinator output now, it's outputting 28 uranium ore.
This may seem odd at first, but remember that the output box is still set to uranium ore,
so what the combinator is doing is taking EACH of its inputs, that is, 1 raw wood, 2
coal, 3 stone and so on, multiplying that number by 1, then outputting the result as
a number of uranium ore.
If you add up 1 2 3 4 5 6 and 7, you do indeed get 28.
Of course, this is rarely a useful result.
Let's say we want the combinator to multiply everything by 2, but still keep the signals
separate.
This, too, can be done.
First let's set the constant number to a 2 to perform the correct calculation.
Then, if we look at the output box, there is an EACH button here too.
If we select that and check the result, we have each of our inputs multiplied by 2 as
expected.
Another to mention here is that we can perform operations between two signals as well.
For example, lets put 2 iron plates and 3 copper plates in our constant combinator,
and say we want the arithmetic combinator to multiply both of them together, and return
the result as a number of steel plates.
Instead of selecting a constant number in the second input box, we can just select copper
plates instead and the combinator will perform as expected.
Lastly, I'd like to point out that if the combinator receives inputs along both a red
and a green wire, any signals that are present on both wires are added together before doing
any calculations, though the red and green values remain separate on the wires themselves.
Before moving on, a word of caution.
The EACH button will only look through its inputs for signals that currently exist.
If we set the combinator to look through each of its inputs and add 1, then output each,
we could reasonaly expect it to output 3 iron plate and 4 copper plate, which it does indeed
do.
However, note that it does not also output a value of 1 for every other signal, despite
every other signal having a value of 0 at the combinator's input.
This might seem useful here, but in more complicated setups, you may not realise that you are losing
information because of a 0 value not being correctly passed on.
The Arithmetic combinator gives us access to 11 different operations.
Multiply, divide, add, subtract, modulo, power, and five other operators called bitwise operators
which i will get to in a moment.
I"d like to think that anyone capable of playing factorio can understand what multiply, add
and subtract do, but it is worth spending a little time covering modulo, power and - perhaps
surprisingly - divide.
I'll start with power, represented by the caret symbol, or the little up-pointing arrow,
usually above the 6 on your computer.
One number raised to the power of another is multiplying the first number by itself,
by the second number of times.
for example, 3 to the power of 4 is the same as 3 times 3 times 3 times 3.
Most often, you'd raise a number to the power of 2, or square it, which is the same as multiplying
a number by itself.
There are a vast number of online resources that you can read up on if you want to learn
more about powers, or exponentiation as it can also be called.
Next, dividing.
Now, some divisions in factorio will be exactly what you expect.
10 divided by 5?
2.
21 divided by 3?
7.
11 divided by 2?
5.
Wait, what?
it turns out that factorio employs something known as integer division.
In fact, all numbers in factorio circuits are integers, you can't have half or quarter
or any fraction of a circuit value.
So to understand what's going on here, we have to look back to how we first learned
to divide numbers at school when they didn't divide evenly.
If you take the number 11 and divide it by two, yes you could say that the answer is
5 and a half, but you can also say that the answer is 5, with one left over.
or 13 divided by five is two, with three left over.
What integer division is is like this, except that the 'left over' part is ignored, and
you just get the whole number part spat out as your answer.
So, 6 divided by three is 2, 7 divided by 3 is 2
8 divided by 3 is 2 9 divided by 3?...
3!
But what happens to the extra part?
what happens if we need a more accurate calculation?
Well, this is where our other operation comes in, modulo, represented by the percent symbol.
Modulo is also a division operator, except that it ignores the whole number part and
just returns the remainder, or the left over part of the calculation.
So while 13 divided by 5 is 2, 13 modulo 5 is three, the left over bit when 13 is divided
by 5.
For example, 6 modulo 3 is 0 7 modulo 3 is 1
8 modulo 3 is 2 9 modulo 3 is 0!
Once again, there are countless online resources you can learn about the modulo operator now
you know what it is and have a basic understanding of what it does.
Factorio's Arithmetic combinator also includes 5 so-called bitwise operations for you to
choose from.
I will include a short description of them here for completeness, but I will be the first
to admit that - while I understand how they work - I am not the best place to learn about
why you might want to use them.
To understand these, you first need to know how binary numbers work.
As with the other operators, there are countless resources you can find online to learn how
binary numbers work, but as a quick introduction, binary is a counting system that only uses
1's and 0's.
Without going into details, ordinary counting is base ten.
that means if you look at a number from right to left, you have a 1's column, then a 10s,
then 100s, thousands, and so on.
Or, you have a colum of 10 to the power of 0, which is 1, then ten to the power or one,
which is ten, then ten to the power of two, then three, etc.
Binary is a base-2 counting system, so you have a colum for 2 to the power of 0, then
two to the power of one, then to the power of three, four, etc.
Or, a 1's column, a 2's column, 4's, 8s, 16s, 32s, etc.
On the display here you see an 8-digit binary number, 11010011.
If you add up the digits in their places, you have 1s in the 1, 2, 16, 64 and 128's
columns, which all added together is 211.
We now have enough to investigate the first two operations, which are call bit shifts.
These are represented by two arrows to the left and two to the right, for a bitwise left
and right shift respectively.
shifting to the left simply moves each '1' in the binary number a given number of places
to the left and adds 0s on the end.
so shifting our number to the left by 1 place gives 110100110, which is 422. by two places,
1101001100, or 844.
Notice that each shift left is equivalent to multiplying by 2.
Similarly, shifting to the right discards whatever is in the righthand column and moves
each one a place to the left.
so if we take our original number and shift once to the right, we get 1101001, or 105.
shifting again is 52, and a third time is 26.
similarly, this is like dividing by two, using the integer division discussed earlier where
you ignore any fraction.
The last three bitwise operators require us to have another binary number we can work
with.
let's choose 10101010, which is 170 as a normal number.
The AND operator looks at each binary place, and the result has a 1 in that place if and
only if there is a 1 in BOTH of the input numbers.
If either input number or both of them have a 0 in that place, the result has a 0 in that
place.
So in this case, our result is 10000010, which is 130.
The OR operator is similar, but is more 'lenient', so to speak.
The result has a 1 in a given place if either one of the input numbers, or both, has a 1
in that place.
So this time, our result is 11111011, which is 251.
The XOR operator, or exclusive-or operator, places a 1 in the result if one, but NOT BOTH
of the input numbers has a 1 in a given place, this time, our result is 01111001, or 121
as a normal number.
Let's now move on to the last combinator in our selection, the decider combinator.
Whereas the arithmetic combinator is great for performing calculations, the decider is
used for deciding things.
This combinator also needs power, so lets pop one down and hook it up to a constant
combinator to see what we can do with it.
Note that, as with the arithmetic combinator, there is a distinct input and output.
Clicking on the combinator, we see a window similar to that of the arithmetic combinator.
There is an input and an output section, the input section with two boxes to select signals
from and a box to choose the output signal.
we have a list of relations and a selection next to the output box.
The way the decider combinator works is to evaluate a condition between two inputs, and
then if that condition is true, send an output.
For example, let's go to our constant combinator and put 2 iron plate and 3 copper plate in
it to send to the decider.
Then lets choose iron and copper plates for the two input boxes in the decider combinator
itself.
We need to choose an output, so set the output box to steel plate, and click the selection
for '1' rather than 'input count'
The default selection for the relationship is the 'less than' relation, so the decider
is currently asking the question "Is the value of the iron plate signal less than the value
of the copper plate signal?"
Since iron plate is 2 and copper plate is 3, the answer is "yes", so the combinator
proceeds to the output section, and outputs 1 steel plate.
If we leave everything else the same but swap around the iron and copper plates, the question
is now "is the value of the copper plate signal less than the value of the iron plate signal".
The answer is now "No", so no steel plate is output.
If we add some steel plate into the constant combinator as well, we can see what else the
output can do.
Lets also switch copper and iron plate around again so the answer to the relation is "yes"
again.
4 steel plate is now also being passed to the decider combinator.
This is not used for the relationship evaluation, but we can now select "input count" in the
output section, which means that when the output is sent on, instead of just 1 steel
plate, we will get whatever is being put into it, in this case, 4.
If we now look at the extra tab in one of the input boxes, we can see there are a few
special symbols in here too.
First we'll discuss the yellow 'each' symbol that we've seen before.
Set up the combinator to Each on the left and the constant number 10 on the right, and
set the output toggle back to 1, and let's look at what we get.
What's the question here?
For each input item, is it less than 10? if it is, output one steel plate.
We have three input items, all of which are less than 10, so the combinator outputs 1
steel plate for each of them, three in total.
If we add another item, say 20 plastic bars to the constant combinator, we still only
have three steel being output, because the value of the plastic bar signal is not less
than 10.
Going back to the decider combinator, we have another two special signals.
next we'll investigate the green "Anything" symbol, so we'll select that and leave everything
else the same.
The decider combinator now outputs a single steel bar.
The question is "does ANY of the inputs have a value less than 10".
The answer is yes, so one steel is output.
The last special signal is the red "everything" symbol.
switching to that, the question becomes "do ALL of the inputs have a value less than 10?"
as plastic bars still have a value of 20, the answer is no, and nothing is output from
the decider combinator.
The 'anything' and 'everything' special signals also have a special case, when there is no
input at all.
If we toggle the constant combinator to the 'off' position, no signals are supplied to
the decider combinator at all.
If 'everything' is selected, no matter the condition, it is evaluated as true and a steel
is output.
if 'anything' is selected with no inputs, it is evaluated as false and nothing is output.
The decider combinator comes with 6 different relations to choose from, each used in different
cases but all relatively simple.
From top to bottom, they are: greater than
this evaluates to true if the input on the left has a value larger than the input on
the right.
If the values are equal the result is false.
less than this evaluates to true if the input on the
left has a value smaller than the input on the right.
If the values are equal the result is false.
equal to this evaluates to true if the input on the
left has the same value as the input on the right.
greater than or equal to this evaluates to true if the input on the
left has a value larger than the input on the right, or the same value as the input
on the right.
less than or equal to this evaluates to true if the input on the
left has a value smaller than the input on the right, or the same value as the input
on the right.
not equal to this evalues to true if both inputs have different
values.
Moving on from combinators, another things that is unlocked by the circuit network research
is the power switch.
This is great for cutting off power to sections of your base to reduce the load on your power
plant, or to switch on your steam engines if your accumulators are having trouble taking
you through the night.
You can use it like this.
Identify an area that you'd like to isolate with the power switch and place down the switch.
The switch itself doesn't need power but it does need to be reasonably close to your power
line as you need to be able to connect it to power poles for it to work properly.
Now would also be a good time to check te map view and make sure that the area doesnt
have any other connections to to power grid!
Now, holding copper cable in your hand, click first one and and then an adjoining power
pole to sever the connection between them.
you can also shift+click on a power pole to remove all connections if you want.
now click one of the severed power poles to attach a copper cable to it, and then click
on side of the power switch.
Do the same with the other pole and the other side of the power switch, and you're ready
to go! take the cable out your hand and click the switch itself to access its controls.
You can even do this from right across your base, or even the map view! simply toggle
the switch to "on" when you want power to flow through the switch, and "off" when you
don't.
simple as that.
The power switch is also one of the in-game objects that can be controlled by a circuit
condition, which I'll go into a little later.
The last item unlocked by the Circuit Network research is the programmable speaker.
Now it is possible to do great things with the speaker, and even program entire songs
to be played as you go about growing your factory.
An entire video could be dedicated to this one item and how to use it, but I'll give
a brief overview here.
The speaker needs to be connected to a circuit to work.
Then if you click on the speaker, youll be shown a window like this, with some settings
at the top and a circuit condition below.
starting from the top, you have the volume at which the speaker plays, then three options.
Global playback means that wherever you are on the entire map, you will be able to hear
the speaker as though you were standing right next to it.
This is largely a matter of taste, but there are reasons you might not want to hear an
alarm going off on the other side of your base.
Next is the 'show alert' button.
Selecting this will pop up another section for the alert settings, which will allow you
to select an icon, and a written tag that will pop up on the bottom of your screen where
attack notifications normally pop up, whenever the speaker is played.
If the 'Show Icon on map' button is checked, you can also see the flashing symbol on the
map view screen in the location of the speaker.
The third option is 'allow polyphony' If unchecked, only one speaker will be able to play a sound
at a time, which might be useful for alarms and alerts.
If checked, up to ten speakers at a time will be able to play their sound, which is great
for crafting music!
Onto the circuit connection settings, there is a section much like a decider combinator
that will ask a question based on the circuit input that will be evaluated to true or false.
Whenever the condition is evaluated to true, the speaker will play.
You can select different instruments and pitches (or different alarms), or you can tell the
speaker to accept the signal value as the pitch of the instrument by clicking the checkbox.
then, lower values of the input signal will trigger lower pitches, and vice versa.
Lamps deserve their own section in this video.
Which separate from the circuit network they are often used as indicators of various things,
or as components of full displays.
When a lamp is placed down, it only turns on at night, but if it connected to a circuit
network, it will automatically turn off right away.
clicking on it to show it's window reveals we can now set a circuit condition, much as
with a decided combinator, to ask if the lamp should be turned on.
For now, I'll set an everything greater than 0 condition, to make sure the lamp gets switched
on.
You can also see there is a selection to "use colours".
Remember the colour signals in the special signals tab?
You can set the colour of a lamp by using those.
As long as the 'use colours' button is selected, and the lamp is on, the lamp will display
the colour of any color signal with a value greater than zero that it receives.
Note that this doesnt work with white, grey or black, but Red, green blue, yellow, magenta
(or pink) and cyan are all up for grabs.
But what happens if a lamp receives more than one colour signal.
As you can see demonstrated here, colours further "left" in the list on the special
signals tab outrank those further to the right.
So if a lamp receives both blue and magenta, it will be blue.
If it receives all colour signals, it will be red.
At the moment of recording, the actual value of the colour signal has no bearing, though
I personally hope that lamps will be changed to instead display the colour signal with
the greatest nonzero value.
Many other in-game items can also be connected to the circuit network and have different
effects when connected.
Here follows a brief overview:
Transport belts: By default, belts can be enabled or disabled
based upon a circuit condition.
Useful to cut resources to an area of the base you don't want to be active.
You can also select the belt to read its contents and send that information into the connected
network.
'Pulse' will only send a single pulse of information when an item enters the belt whereas 'hold'
will continuallly send the signal as long as the item is on the belt.
Both are useful in different scenarios.
You can also enable both modes of operation.
Inserters: Inserters can also be enabled or disabled
by an incoming circuit condition.
If you want the insert to always be active, you can set the mode of operation to 'none'.
Similar to belts, inserters can also read their contents in a pulse or hold mode, when
they pick up items.
Inserters can also have their maximum stack size set by an incoming signal's value.
Additionally, filter inserters and stack filter inserters can have their filters set by nonzero
values in the incoming circuit, though be wary of the number of filters an inserter
may have.
Chests: As shown earlier in the video, chests can
send their contents into the connected network.
Additionally, requester chests can instead have their requests set by the values on an
incoming network.
Storage Tanks: Similar to chests, a storage tank can be connected
to a network and will send its contents to that network.
Gates: A Gate, when connected to a wall on at least
one side, can be opened by a circuit condition instead of the player.
They can also send a chosen signal to the network when the gate detects that it should
open.
These can be used in combination with rail signals to make safe rail crossings, which
I'll get to later.
Rail Signals: By default, a rail signal will read its current
colour and send red, yellow, green, or for a chain signal, blue, into the network, though
these signals can be configured.
Normal rail signals can also be set to red by the circuit, preventing trains from continuing
on their path.
Train Stations: Train stations have four modes of operation,
some or all of which can be active at a time.
The entire station can be turned off by a circuit condition, which can be useful for
directing trains away from old stations or stations that are not ready for them.
The stations can also send the circuit contents to the train, which can then have its own
conditions that use the circuit signals to determine how long to wait at the station.
The station can also read the cargo contents of the train and send that into the network,
as well as just send a simple signal into the network to indicate when there is a train
stopped at the station.
By default, this signal is the special 'T' signal, and has the value of the train's ID,
which is unique to each train.
Accumulator: Accumulators can send the amount of charge
they have as a percentage into the network.
This is useful for determining how much power storage you have, and can be used to trigger
emergency power generation procedures if the percentage drops too low.
Power Switch: As Discussed earlier, the power switch can
also be connected to a circuit network, and made to open or close based on a condition.
This is how you can automatically connect or sever parts of your base to or from the
main power grid automatically.
An example of this will be shown later in the video.
Roboports: Roboports have two modes of operation, the
logistics network contents or robot statistics.
'Read Logistic network contents' will send the contents of all the logistics chests in
that logistics network into the circuit.
This is much easier than connecting every chest with bits of red or green wire!
Alternatively, the roboport can send statistics about the number of total and available construction
and logistics bots in that network, as four different signals.
The special signals XYZ and T are used by default but these can be changed.
Mining Drills and Pumpjacks: Both Burner Mining Drills and Eletric Mining
Drills can be connected to a circuit network.
They can be enabled or disabled by a circuit condition, but can also read the expected
amount of resources available to them, either to an individual miner or the size of the
entire ore patch, and send that number to the circuit.
This can be a good way of automatically performing some action when an ore patch runs out.
Similarly, pumpjacks can also be enabled or disabled, and can read the amount of oil per
second they can draw from their well.
Pumps Both pumps and offshore pumps can be enabled
or disabled by a circuit condition.
This is great as it allows us to control the flow of oil fractions to cracking plants to
avoid things backing up, which is an example I'll get to later in the video.
The first example today is a counter.
Say you have a belt, as you see here, with some items on it, and you want to count how
many items go past.
We know that a belt can read its current contents, but we need a way of remembering that value.
We can use a counter for this purpose.
I'll set up a decider combinator here and hook it to one of the belts.
I'll set the belt to read contents in pulse mode, as I only want to count each item once
as it goes by, not once for every game tick it stays on that belt.
I can then hook up the output of the decider combinator to its own input.
If I now set the combinator to say "If everything is greater than the constant number 0, output
everything" with input count, we now have out counter.
Simple as that.
The way this works is that when the combinator receives a pulse from the belt saying an item
is present, it passes is through to the output, because its not possible to have a negative
or zero number of items being counter by the belt.
The very next game tick, the output is received again by the combinator's input, so even though
the belt is no longer sending a signal, the combinator receives the signal of one iron
plate again... and again and again and again.
Effectively, it will remember that one iron plate has passed.
When the plate comes around again, there will be an instant where the combinator receives
two iron plate signals, one from the belt and the other from its own output the previous
game tick. so it will pass that signal of two back into itself, and remember the new
value of two, and so on.
This system works fine, but does come with a drawback that it can only count up and up,
and you can't reset it back to a count of zero without removing and reconstructing it.
Luckily, there is an easy way to build this system in such a way that it has a reset switch
built in.
If I construct a contant combinator over here, with a signal of R for "reset" in it, and
turn it off for now, then go back to the decider combinator, I now only want to count up when
R is off, i.e. when we are not resetting the system.
So If I change the condition to reflect that, we have "If R equals 0, then output everything"
with input count.
The combinator continues to count passing iron plates as normal, but now If I enable
the Reset switch, even for a moment, The decider combinator will not pass its input through
to its output, and will therefore "forget" the number it has counted to.
This system can also be used to count multiple things at once.
If you have a so-called "sushi belt" with many different items on it, you can use a
counter like this to determine how many of each item has passed.
Instead of a manual reset switch, you could pass a signal to reset the counter after a
given amount of time has passed to see how many of each item passes each minute, say.
This leads us into our next example.
A common use of circuit networks in factorio is that of a clock.
Now while such things can be built, I'm not yet talking about a conventional clock with
a digital display to tell the time.
What we'll build here is simply a way of telling how much game time has passed.
By default, and assuming your base isnt big enough to slow your computer down, factorio
runs at 60 UPS or 60 updates per seconds.
each update is called a 'tick'.
If you press The F4 key, you can enable the 'show FPS' option to keep a summary of your
frames and updates per second in the top corner as you play.
Now, if we were to make a counter that instead of counting items on a belt, just added one
to a total every game tick, we would know that whenever that total reached 60, or a
multiple of 60, one real-time second will have passed.
We can do that by modifying our last example just a little.
Let's set up a decider combinator and constant combinator as before, but with different values
this time.
We'll put a signal of T equals 1 in the constant combinator, T for time, and connect that to
the decider combinator's input, and then onto the output.
We want the combinator to keep counting up until a second has passed, at which time it
would make sense for the counter to reset itself.
So our condition can be, if T is less than 60, output T. T will count up and up and up
until T reaches 60, and then will reset back to zero.
If I hook up a light to be enabled when T equals 60, you can see it flash once a second,
meaning this is working just fine.
If you have other things in your factory that need to happen regularly, it need not be once
a second.
If you need something to happen every minute, you just need to know how many ticks that
is.
60 ticks a second means 3600 ticks per minute, so use that number in your condition and your
counter will reset every minute instead, or use any other number you need.
You can also chain counters like this together.
If I replace my light with another decider combinator set to if T equals 60, output 1
T, I can use this as the input for another counter.
Because this one will only tick up once per second, If I set the condition to the same
as the first, it will reset every minute instead of every second.
I could chain another to tick every hour, or go even further.
Hook them all up to a numerical display, and you have yourself a time-telling clock.
The next example is a simple SR Latch, or Set-Reset Latch.
It's designed for when you need a single pulse of information to turn into a steady signal,
which can then be reset by a different pulse.
The way it works, there are two inputs, a "set" signal and a "reset" signal.
There are also two outputs, which always has one on, and one off.
When the "set" signal is received, output A will turn on and output B will turn off.
If another "set" signal is received, nothing will change.
The outputs will switch states when a "reset" signal is received, and remain that way until
another "set" signal comes along.
This is a lot less complicated than it sounds, so hopefully this example will clear things
up.
The latch is easy to set up.
As dummy inputs, I'll put two constant combinators here, both containing a virtual A signal.
the top one will be the set, and the bottom the reset button; I'll turn them both off
for now.
The latch itself consists of two decider combinators, both with idential settings.
If A equals the constant number 0, then output 1 A. Now using red wires, we can connect the
output of each combinator to the input of the other.
Using green wires, we can plug in our dummy input switches, and I'll use lights to indicate
which output is on.
The lights will be conected to the two outputs of the decider combinators, and each have
the conditition to be enabled when A equals 0.
And that's it! if I enable the "set" switch, we can see that output A turns on.
If I turn off the switch, A stays on.
If I enable the "set" switch again, no matter how many times, A remains on and B remains
off.
If I then enable the "reset" switch, A turns off and B turns on, and remains that way no
matter how many times the "reset" switch is turned on.
The reasoning for how this works is a little more complicated, but its still easy enough
to follow through if you consider what each combinator is doing one at a time.
Let's assume that the "set" button is pressed.
This sends a signal of 'A' to the top combinator.
That combinator will only output if A equals zero, so it doesnt output anything.
This means that the top output light turns on, as its not receiving an A signal.
It also means that the bottom combinator is not receiving any input, so the bottom combinator
does output an 'A' signal.
This will turn off the bottom light, but that A signal will also be fed back into the top
combinator.
The total input at the top combinator is now 2 A signals, which is still not zero, so it
doesnt output anything and because nothing has changed since the last time we we here,
the system is now stable.
If we now turn the "set" switch off, the top combinator is no longer receiving a signal
from the set switch, but it is still receiving an A signal from the bottom combinator, so
it's output does not change.
the bottom combinator is still receiving nothing, so its output doesnt change either.
Even though nothing is being input, the system is still stable and the outputs havent changed.
enabling the "set" button again doesnt change anything either, as giving the top combinator
an A value of 2 again doesnt change anything.
Now if we enable the "reset" switch this time, the bottom combinator gets an A input.
because its A input is no longer zero, it stops outputting an A, switching on the bottom
light.
however, this also means that the top combinator is now no longer receiving any input, so it
begins to output an A signal, turning off the top light and supplying another A signal
to the input of the bottom combinator.
Even when the reset switch is turned off again, the bottom combinator continues to get the
signal from the top combinator, so the outputs don't change and once again the system is
stable, back where we started.
Over here we can see a similar example, this time being set and reset by transport belts
with their mode set to read contents, rather than with manual switches.
You can use just about anything that can output a value to a circuit network instead of manual
switches, if you can think of a reason to do so.
We'll see an example of it in use in the very next example.
If you've played much factorio, you've quite possibly come across a situation like this.
You have a nice big solar field to power your factory during the day, and a heap of accumulators
to store any excess energy for use during the night.
But you havent yet deconstructed your old Steam engine set up because as the factory
grows - as it always must - you may need the extra power.
you don't want to have a blackout in the middle of the night after all.
But how can you get this to work?
During the day, the steam engines turn off because the solar panels can cover the energy
needs of your base, but during the night, the steam engines do all the work while your
accumulators sit there doing nothing.
You don't want to needlessly pollute and attract biters - that was the point of building solar
in the first place, right?
But you can't just disconnect the steam engines from the network entirely - you'd need to
be able to connect them again in an emergency and don't want to run all the way across your
base in the middle of a blackout to reconnect them when you need them most.
Because - as any seasoned factorio player will tell you - the middle of a blackout is
always when the biters choose to attack.
Of course, with the power switch, you can remotely disconnect and reconnect the steam
engines from the main power grid, but it wouldnt be the true factorio way unless you can automate
the process right?
Circuit networks to the rescue.
An accumulator attached to a circuit network will output its storged energy as a percentage,
and we can use this to trigger a power switch to turn on when the charge drops below, say,
20 percent.
But if we try this, you may notice a problem.
If I turn the time of day to night so the solar panels turn off, the accumulators will
drain as expected, and the steam engines kind of turn on, but the accumulators don't charge
back up.
If we check the charge level of the accumulator here and look closely, the percentage is actually
flicking between 19 and 20 percent.
Let's have a think about whats going on.
The power drops below 20 percent, so the switch closes. this connects the steam engines, which
turn on to power the base and recharge the accumulators.
However, once the charge reaches 20%, the switch turns off again, disconnects the steam
engines, and the charge drops.
this happens very quickly but it means that the power just flicks back and forward constantly.
We can use an SR latch to solve this.
Firstly, we need two decider combinators to turn the charge level of our accumulators
into a set and reset switch.
we'll have one to "set" the system if the charge drops below 20%, so the steam engines
will connect and recharge the accumulators, but we won't trigger the "reset" until the
charge is done, that is to say at 100%
So if we use X as our set-reset signal, and the accumulator outputs charge on the A channel,
we want out setting decider to say "if A is less than 20, output 1 X", and we want out
resetting decider to say "if A is equal to 100, output 1 X".
Then we can build the latch, with both deciders reading "If X equals zero output 1 X", and
connected up with diagonals as before.
Then if we connect the setting output to the switch, we just tell the switch to turn on
when X equals 0.
If we test this now, we can see that as out charge level A drops below 100, nothing happens
with the switch as the system has already been reset.
Waiting a little longer until the charge drops below 20 percent, then the SR latch is set,
the power switch turns on and this time stays on until the accumulators are all charged
again.
When the accumulators all charge up to full, the switch turns off and the accumulators
begin to drain once more.
If you wanted, you could combine this idea with a clock, to maybe use a programmable
speaker to set off an alarm if the switch stays on too long, or with a counter to determine
if the engines get connected more than once a night, as either could be an indication
that you need to expand your solar fields or accumulators if they are not lasting through
the night.
Once again, I think it's safe to say that most factorio players have a some point come
across tehe problem when the oil refineries all stop working because one of the oil fractions
has backed up.
There are simpler ways around this, especially once you have already researched cracking,
but here is a way you can keep even amounts of your three oil fractions with just a couple
of simple circuit conditions.
We could simply spam down chemical plants and crack everything into petrol, and in some
cases, you will want to do just that.
But remember, we also need heavy oil to make lubricant, and light oil is the most efficient
wat to make solid fuel, a step on the way to rocket fuel.
By using a couple of pumps, open or close the pipes to our cracking plants based on
how much of each oil fraction we have, meaning we never back up and we never run out.
What you see here is a situation I have set up to mimic what has happened to me more times
than I would like to admit.
I've run out of petroleum gas!
The refineries have a solid supply of both water and crude oil, but they are not producing
because the light oil has nowhere to go.
Here's what we can do.
I have my heavy oil supply connected directly to my lubricant production.
In the grand scheme of things we don't need much lubricant so I expect this to fill up
at some point but that's okay.
I have a pump here between the heavy oil storage and the chemical plants that crack heavy oil
to light oil.
If I connect that pump to both the heavy and light oil storage tanks, That pump will receive
as its inputs, how much of each of those oils I have.
Now, I'd like to keep a little heavy oil on standby in case I run out of lubricant, so
lets set that pump to enable only if I have more heavy oil than light oil.
At the moment, all my heavy oil has been turned into lubricant, so I have less heavy thatn
light oil and nothing happens, so let's move on.
Similarly, I have a pump between my light oil storage and the plants cracking light
oil to petroleum gas.
I can connect that pump to both the light oil and petrol storage tanks, and set it to
enable only when I have more light oil than petrol.
At the moment, I have no petrol and full light oil, so the pump turns on.
We start cracking light oil into petroleum, and now we have space for light oil to go,
the refineries turn back on.
I've set up a pump to act like a drain for petroleum into my base, so if I go above 20
thousand petrol I'll start using it.
With what we've done here, I'll only crack heavy into light and then light into petrol
if I have more heavy than light, and light than petrol respectively.
If I wait long enough, the system should stabalise with 20 thousand of each oil fraction, nothing
backed up except lubricant and eyerthing working nicely.
Another common use of the circuit network is to give yourself a nice visual display
in order to tell how much of a given resource you have in a series of chests.
I have here a bunch of chests with different numbers of each basic raw resource in them.
They're already hooked up to a power pole, so I could simply mouseover the pole to see
how many of each resource there are, but let's see If we can do something a little better.
I have here a series of constant combinators here just to act as labels, but I won't connect
them to anything.
Then next to them, lets make a grid of lights.
Horizontally, I'll connect them all with red wires, and vertically I'll connect them with
green wires.
You can speed up the process of making a grid like this by just connecting up one line and
then using a blueprint to place down the rest.
As an added bonus, blueprinted wires don't take anything from your inventory, and though
while I have a creative mode mod enabled for this example, it'll work just fine with bots
too.
I'll use the horizontal red wires to carry the actual number of resources from the chests,
and the green wires to carry colours.
That way, I can have low numbers show up as red, medium as yellow and higher numbers as
green.
A different colour of wire is used so that each light only receives one colour at a time
and avoid cross-contamination.
I'll put combinators at the top with a red, yellow and green signal and connect them
Then, I just need to go through each light and set it to be active is the relevant resource
is higher than whatever number I choose, say in multiples of a thousand.
Now this will work, but it means that every single one of these lights has a different
condition so it'll take a while to set up, so Let's see if we can do better.
As mentioned before, we can use a combinator to isolate a signal from a bunch of signals.
Let's put an arithmetic combinator in each row to isolate each raw resource by adding
zero to it, and in each case, we'll output an A virtual signal.
If we hook up this result to the lights, we then need to switch the condition on the lights
to be active if 'A' is greater than 1000, 2000, 3000, etc.
The benefit here is that we can then copy the
entire row, and just by choosing different settings for a single combinator to isolate
a different signal, we see our nice coloured display.
but once again, We can do better.
With this setup, the colours of each lamp is static. that is to say, it doesnt change,
so there are red and yellow lamps in each row even when that resource is full.
What if we want the entire row to be the given colour?
For this, we have to pay special attention to the priority of the different colours.
Yellow has the lowest priority, so let's give everything a default yellow signal by getting
rid of our green and red constant combinators and hooking up the other columns to the remaining
one so everything becomes yellow.
Next highest priority of our chosen colours is the green signal, so we want to add a decider
combinator that will output one green signal if the total number of the input A is above,
say, seven thousand.
red has the highest priority of all, so we need to do that one last.
So let's add another decider combinator, this time to output a red signal if the input A
is less than three thousand.
Now each of these combinators needs to be connected to the output of the isolating combinator.
also, the output of the two new combinators needs to go into the light grid.
If you use the same colours of wire for this, there may be a couple of loops where colours
are fed back into combinators, but becuase the combinators are only ever looking for
the A signal, theres no problem with that in this case.
Now we have one row, lets copy and paste! set the isolating combinators back to their
different settings and we have a nice colourful display that we can use to see at a glance
what we have, and what we are low on, as well as wondering why we have over four thousand
fish
in storage.
So That's it
for
this video, I hope you
managed to learn something useful.
Let me know what you manage to make of what you've learned from here and most importantly,
have fun!
In the mean time, I'll say thank you very much for watching, and I'll see you again
soon!
No comments:
Post a Comment