You are on page 1of 11

Factorio - Vanilla Train Network

Introduction
Some of you may know the fantastic mod Logistic Train Network (LTN) which can be found on the
factorio mod portal. But when you want to play without mods you have to find a solution for the
train logistic system.
I tried to implement a dynamic system with circuits which can send out material trains to locations
where the material is needed.Here I present you a possible solution how you can manage your
trains in vanilla.
The system is inspired by many different circuitry videos on Youtube. I would recommend you to
take a look at the channel of ShredGuy991 for some good tutorials on combinators and circuit
networks.
To achieve what we want we have to fulfill a few prerequisites:
Firstly, we need a wired train network with red and green wires along the tracks.
Secondly, we need one station and at least one train per material.
Lastly, all supply and request stations need to have the same name (e.g. IRON PLATE - Out for
supply stations and IRON PLATE - In for request stations)

I have used this system on several community servers of Nilaus2 (Vanilla and Angel + Bobs) and
on a server of cl0wnt0wn3 with the Angels + Bobs modpack. The system worked pretty stable on
both of them. Nilaus also made a review of one Community map where we are using this system.
You can find the video here:
Factorio Engineering - BLOCK BASED TRAIN NETWORK - Community Map Review (YouTube)
Tutorial on the Vanilla train setup (Nilaus):
https://www.youtube.com/watch?v=v4VgZv35yUI&t=1s
On the following pages I will try to explain the circuits at each station. If you have any questions
feel free to contact me on Discord (​Haphollas#6927)
You can find a link to the blueprint book which includes all stations at the end of this guide but​ I
strongly recommend to read everything to understand what is going on​.

1
ShredGuy99: ​Youtube​, ​Twitch
2
Nilaus: ​YouTube​, ​Discord
3
cl0wnt0wn: ​Twitch​,​YouTube
Request Station Setup
Overview

We want to activate the station if the threshold is below a predefined threshold. As soon as there is
less material in the storage we want a train to deliver the material.
All request stations have the same name (in the shown case: Wood - In)
Circuit diagram

What is going on here?


First, we connect all of the storage chests to an arithmetic combinator (AC1 for later
reference). The combinator will multiply all ingoing signals by -1 so that we get a negative value.
This result will merge with the signal of the constant combinator where we set the threshold for the
request station. You should keep in mind that you add at least one full cargo load to the threshold
you want.
If you wire two different signals together you can make an addition without the need of
additional combinators.
The left decider in the diagram checks if the ingoing signal (threshold + negative storage) is
above zero (threshold is above the storage amount). If it is true then it will give out a ‘S’ (station)
signal which activates the station. To prevent that we request another train if a train is already
unloading we feed back the train contents to the storage amount (red wire from the train station
back to AC1)
The right decider requests items from the train network. It checks each ingoing value and
outputs only the values which are above zero. Attention: This combinator gives out the input count
instead of 1 (!)
Supply Station Setup
Overview:

The general idea here is to call a train if there is enough material in the storage to fully load
it. To achieve this we will send a material signal on the red wire as soon as there is enough
material in the storage.
After the train is loaded it should only leave if there is a demand on the train network which
will be transferred on the green wire of the train system.
We need to check both signals in several combinators and enable/disable the station
regarding to the storage amount as well as sending a signal to the train when it should leave to
deliver the goods.
Like the request stations all Supply stations for one type of material will have the same
name (e.g. Wood - Out)
Circuit diagram:

What is going on here?


In the beginning we calculate how much cargo can be carried by the train. Therefore, we
need the wagon count and the cargo capacity of each wagon (both are stored in constant
combinators here). In the next step we subtract the cargo capacity from the stored amount of
goods. This result will be used in two different ways:
First, we check if the result is above zero. If it is the case the station will send a signal of
material = 1 (wood in the example) onto the red wire of the train network. This means that one
station is ready for pickup.
Second, we check if the result is above zero and if this is true we send a ‘S’ (Station) signal.
The S signal is used to activate the train station if a train can be fully loaded. (Enable / disable
option in the station)
Lastly, we want to ensure that the train will be send out if there is a request in the Train
network (green wire). Therefore, we check if the wood signal on the green line is above zero. In
this case we send a green signal to the station which is used in the train schedule (Send to train
option in the station)
Remark​: If you have problems with the @ signal you can use any other variable/signal instead.
Depot Station Setup

The idea here is to fill the trains with fuel and send them out into the world if a supply
station is ready for pickup.
If you remember: The Supply station will send a signal of material = 1 onto the red
wire of the train network.
All we need to do here is to send the signals of the red wire to the trains (which will
be used later in the train schedule)
Train schedules

Until this point you should have a general idea how the Train network works. To finish our
system we need to take a look at the train schedules. You can tweak the schedule of the train if
you want but the initial setup should look like the schedule in the table

Stop Condition Description


Depot 15 seconds passed The time passed condition is used to fuel the
AND train without leaving the station instantly.
<material> >= 1 The circuit condition ensures that the train will
only leave if a supply station is ready for
pickup.
If you want to add additional trains for several
supply stations you can set the circuit
condition to >= 2,3,...
Pickup Station Full cargo inventory The trains will wait until their cargo is full.
AND They will only leave the supply station if there
Circuit Condition = Green > 0 is a demand on the train network (Green = 1)
Look at the supply station setup for more
information about this.
Drop-off Station Empty cargo inventory The Inactivity prevents that the whole system
OR jams (storage is full)
5 seconds of Inactivity

I usually recommend to use 2 trains per signal in the depot. This means:You have two trains which
have the depot condition ‘Circuit Network <material> >=1’; two trains with <material >=2;...
This is the easiest way to scale the system for longer distances.

Remark:
If you want to carry several different materials you need to reserve one wagon per material
or lock the slots within the wagon and use filter inserters for unloading.
Example:
You are running a general green/red/blue circuit train (1​st​ wagon: green circuits, 2​nd​ wagon
red, 3​ blue) if you need only red circuits then unload only the 2​nd​ wagon (you can use filter
rd​

inserters and a material signal if you have differently configured trains)


Train Pathfinding

The main issue with this system is that nearby stations always will have a higher priority
over stations which are further away.
This behaviour can be tweaked by adding ‘unused’ train stations in front of your supply /
request stations. The vanilla train pathfinding will add a penalty of 2,000 tiles to the
trainpath if a station which is not in the schedule lies on the path.

You could also control nearby rail signals with a circuit to increase the penalty for a
specific part of your tracks. A rail signal which is set to red by a circuit will add a penalty of
1000 tiles to the pathfinding. You could for example read the train signal at the train station
(T) and use a decider combinator.
Input of the decider combinator: T > 0 Output: red = 1.
Rail signal: Close signal: red > 0

I would strongly recommend that you take a look at the Factorio Wiki to see how different
modifiers affect the vanilla pathfinding. You can find the article here:
https://wiki.factorio.com/Railway/Train_path_finding
Troubleshooting

If you have problems with your stations you should check the corresponding circuits.
Common mistakes:
● Train schedule
○ you used OR (default) instead of AND for the circuit conditions
○ you used less (default) instead of greater for the circuit signals
○ make sure that you use the proper item for the trains (e.g. copper signal for
iron stations)

● Stations
○ a signal for the amount of cargo wagons is missing
○ the storage amount is multiplied by the cargo capacity (default) instead of
subtracted
○ The ‘close’ signal for the train station is not setup correctly (S > 0)
○ If you have more than one material in the request station: you must isolate
the wanted signal by changing the ‘each’ * -1 into <material> * -1
○ if a train doesn’t leave a station/doesn’t go to a requester station: check if the
wires to the global network are hooked up
Summary:

I’m using the described system on several maps and it is pretty stable if you pay attention to
the wiring. One have to keep in mind that the nearby stations will be served before the stations that
are further away. You might have to adjust the thresholds if some stations are not served at all (or
increase the production of the supply station).
Possible things to optimize the system:
You could add an arithmetic combinator to the supply station for sending out more trains to
one far away outpost. Additionally, you could add some train stops to guide dedicated trains to a
station (just disable them as soon as a train enters the block with the station in it by reading out the
next rail signal and disable the station at a red signal)

Pro:
- ‘dynamic’ management of material to several locations
- Trains are not running back and forth permanently
- demand driven system
- no need for fueling locomotives at every station (centralized depot)
- easy to connect new request stations without the need of editing schedules

Cons:
- requires one station per material (huge station setups)
- it may take some time to find a good threshold (rule of thumb: two times the max. cargo
capacity)
- complicated if you look only at the combinators and don’t take the time to understand it
- the system will break if the red and green wires on the rail network are disconnected
- a nearby opened station will always be served first before stations further away will be
served

I hope this guide will help you on your maps.

Haphollas

Link to the Blueprint Book:

https://pastebin.com/1TJiqgUF​ (Factorio 0.17 needed)

The big power poles are the connection to the train network.

You might also like