Automated train stations. How do I "store" my idle trains?

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
Roaders
Burner Inserter
Burner Inserter
Posts: 18
Joined: Mon Jan 15, 2024 1:33 pm
Contact:

Automated train stations. How do I "store" my idle trains?

Post by Roaders »

Hi All

I am pretty new to factorio but I am loving it. Spending far too much time on it...

I am currently trying to improve the efficiency of my train stations. On my current level I have 2 oil refinery train stations. One of them is far away and never gets picked as a destination by the trains and they instead queue at the nearer by lower output oil field.
I have "solved" this by disabling the stations if the stored oil is less that 140,000 (my trains have 6 wagons). This is grea but the problem is that when there are no stations that are full my trains just wait at the refinery, blocking it from other trains that do have oil.
To solve this issue I added a new set of stations called "Holding Area" so the train route is "Oil Field" (with multiple stations), "Oil Refinery" then "Holding Area"
The problem with this is that there is no Wait condition at holding area so the trains forever cycle between the refinery and the holding area.

I want my trains to wait in the holding area until there is an enabled "Oil Field" station. How can I achieve this?

There are quite a few options on the station for automation as far as I can see and I don't understand most of them. I hope that there is somethine in there that allows me to do this.

I know there will be a way! :-) I've just not found it yet.

Many thanks for any help or suggestions.

I did look for a video tutorial on this sort of stuff but I didn't find any. It was all either basic train signals or train mods. If someone can link one that would be useful.

Loewchen
Global Moderator
Global Moderator
Posts: 8321
Joined: Wed Jan 07, 2015 5:53 pm
Contact:

Re: Automated train stations. How do I "store" my idle trains?

Post by Loewchen »

You almost have it already, all you need to change is instead of disabling the stations you set the train limit to 0, by doing this the trains will not skip the station but wait for one to become available instead.

Roaders
Burner Inserter
Burner Inserter
Posts: 18
Joined: Mon Jan 15, 2024 1:33 pm
Contact:

Re: Automated train stations. How do I "store" my idle trains?

Post by Roaders »

Loewchen wrote:
Mon Jan 15, 2024 2:05 pm
You almost have it already, all you need to change is instead of disabling the stations you set the train limit to 0, by doing this the trains will not skip the station but wait for one to become available instead.
THanks for the reply. I need to set it to 1 surely not 0?

Loewchen
Global Moderator
Global Moderator
Posts: 8321
Joined: Wed Jan 07, 2015 5:53 pm
Contact:

Re: Automated train stations. How do I "store" my idle trains?

Post by Loewchen »

You need a circuit condition that outputs 1 if enough oil is available and not output anything (and therefore sets it to 0) when there is not enough oil.

astroshak
Filter Inserter
Filter Inserter
Posts: 597
Joined: Thu May 10, 2018 9:59 am
Contact:

Re: Automated train stations. How do I "store" my idle trains?

Post by astroshak »

At the Oil Field stops, wire up a Decider Combinator between the Train Stop and the Storage Tanks. Storage Tanks on the input side, Train Stop on the output side. Crude Oil > 140,000 output L = 1. Then go into the Train Stop and set it to do the Train Stop Limit by circuit.

L is the default Train Stop Limit signal. When you have enough crude for a pickup, this will raise the Limit from 0 (station closed) to 1 (station open for exactly one train). Trains will wait at Holding Area, complaining about “Destination Full”, until the Limit at an Oil Field station goes to 1, at which point one train will go charging off to get its load.

Qon
Smart Inserter
Smart Inserter
Posts: 2118
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: Automated train stations. How do I "store" my idle trains?

Post by Qon »

You can set it to 1 on both stations, if you have 2 trains. Then the other train will pick the free stop when the "popular" stop is taken.

Dynamically lowering the limit to 0 (like Loewchen said) at the popular stop when you don't need a train there is also an option. And yes, this means you have a higher limit when you do want trains visiting.

mmmPI
Smart Inserter
Smart Inserter
Posts: 2747
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: Automated train stations. How do I "store" my idle trains?

Post by mmmPI »

Roaders wrote:
Mon Jan 15, 2024 1:41 pm
I want my trains to wait in the holding area until there is an enabled "Oil Field" station. How can I achieve this?
I agree with the others, that sound like a place where the "train limit" setting from the train stop would be useful.

With the "disabling" station train "skip" when there is none available, when you instead reduce the limit to 0 with circuits, trains already routing there are allowed to complete their schedule, they are not re-routed to the next and other trains having the "full"/"limited" train stop in their schedule that are not on their way will be prevented from departing their current train stop with a message "destination full" instead of skipping 1 of the 3 station of their schedule or showing "no path".

This was not originally in the game, and was announced to be changing for the future 2.0 version of factorio, if you want to put some time onto understanding/refining your system you would find tutorials using the key words "train limit tutorial" it may be useful to know , they showed up on the internet when it was introduced as a tool to help players deal with the exact problem you describe, but i suppose it will be improved in the future with more of a rework and also it may explain why it's not mentionned in other older tutorial about trains. I haven't rewatched it since , but i remember this one https://www.youtube.com/watch?v=x2CfoEXa77M , i don't remember exactly what's shown but i think it's the feature demonstrated in context, spoiler alert , it stick better in memory when you find your own way to use that "train limit" feature, and i advise to watch it after you found a way that you find satisfying, as source of inspiration to try something new rather than the initial lead given how close you are already.

The other options from the train stop allow you to "read incoming trains", if you set a signal like "C", it will outputC=1 or C=2 or C=3 or nothing, if you have 1 or 2 or 3 or no trains that are currently going into this station. This can be helpful if you reduce the limit to 0, you could get the information for circuits contraptions of how many trains are still on their way anywhere accross the whole map. This was introduced at the same time.

The one called "read Train ID" is by default using the signal T , and a unique number for each train , visible when there are stopped at the train stop. If you have an iron train, it may have the number 25, to it would show "T = 25 ", and then another train "T=55" , it can be used to differentiate 2 trains but if you change the composition of the train the number is updated , add a wagon and the train "25" would become train "60" or something you don't really get control over.

The "read Train content" is much more robust, it makes the train stop output in the connected wire what's inside the wagons of the whole train. It's the go-to option to use to differentiate iron and copper and empty trains to then activate inserter from one side or the other or more complex logic around the train stop itself.

The "send to Train" is doing the opposite, it is taking the signal from the wire, and transmitting it to the train, so if you have the previous box ticked the train would be able to read its content or ID but really this is to be used with the train schedule condition "circuit network", so you can configure a train to have a condition of "cargo full" but also "A<50", if you want to have a train that move only when the accumulator charge is under 50% , like a train full of steam as back up, you wouldn't find that on most tutorials because that's too silly, but it's possible to make :)

You can also connect regular signals with circuits that's also part of the toolbox , like to turn them red , that can be used to give priority, or you can read their color instead of changing it, so you can detect if the signal is red ( how many green signal in the holding area ? how many red ? ), i found it often time useful for making the details works fine.

Roaders
Burner Inserter
Burner Inserter
Posts: 18
Joined: Mon Jan 15, 2024 1:33 pm
Contact:

Re: Automated train stations. How do I "store" my idle trains?

Post by Roaders »

astroshak wrote:
Mon Jan 15, 2024 2:23 pm
At the Oil Field stops, wire up a Decider Combinator between the Train Stop and the Storage Tanks. Storage Tanks on the input side, Train Stop on the output side. Crude Oil > 140,000 output L = 1. Then go into the Train Stop and set it to do the Train Stop Limit by circuit.

L is the default Train Stop Limit signal. When you have enough crude for a pickup, this will raise the Limit from 0 (station closed) to 1 (station open for exactly one train). Trains will wait at Holding Area, complaining about “Destination Full”, until the Limit at an Oil Field station goes to 1, at which point one train will go charging off to get its load.
This is what I was looking for. Many Thanks. I did get it working with a static limit on the oil fields (after removing the holding area). I like this though, I like the idea of my trains waiting in the holding area then going to fill up when there is oil stored.

Kyralessa
Filter Inserter
Filter Inserter
Posts: 446
Joined: Thu Sep 29, 2016 5:58 pm
Contact:

Re: Automated train stations. How do I "store" my idle trains?

Post by Kyralessa »

Not sure how much oil you can store at your stations, but if you can store multiples of 150,000, then you can put in an arithmetic combinator, divide your total oil by 150,000, and set the resulting value to your station's train limit, because it's one train load.

So 150,000 would give you 1, 300,000 would give you 2, etc.

Then you can always have the right number of trains heading to any given station based on the oil waiting there.

quyxkh
Smart Inserter
Smart Inserter
Posts: 1028
Joined: Sun May 08, 2016 9:01 am
Contact:

Re: Automated train stations. How do I "store" my idle trains?

Post by quyxkh »

Don't disable stations at a hard limit, disable a station if it has less than the other stations.

astroshak
Filter Inserter
Filter Inserter
Posts: 597
Joined: Thu May 10, 2018 9:59 am
Contact:

Re: Automated train stations. How do I "store" my idle trains?

Post by astroshak »

I like to set the Train Stop Limit dynamically for solids. A single Steel Chest has more room than an entire Cargo Wagon, and I tend to use 6 per Cargo Wagon! Plenty of space for materials for additional loads. Liquids, I tend to have one Storage Tank per Fluid Wagon anyway, so setting it to 1 based on having enough at the station works well enough.

I would not recommend “disabling if it has less than other stations” though - that would require sending out a bunch of signals on logistics wires and actually comparing to see what the highest is. Setting the Limit dynamically - either to 1 based on the fluid content, or to a number based on the amount of material on hand to be picked up - works perfectly fine.

quyxkh
Smart Inserter
Smart Inserter
Posts: 1028
Joined: Sun May 08, 2016 9:01 am
Contact:

Re: Automated train stations. How do I "store" my idle trains?

Post by quyxkh »

You can do it with one wire carrying the summed product amounts + station counts, then the below-average stations can disable themselves with a single combinator, but really? Disable at LTL quantities, have at least one more outpost than you really need, set an alarm on it. If any train ever reaches it, either your resource patches are running dry or your consumption is increasing, whatever, the first train arriving at the most distant outpost is your bulid-more-outposts notice.

Tertius
Filter Inserter
Filter Inserter
Posts: 671
Joined: Fri Mar 19, 2021 5:58 pm
Contact:

Re: Automated train stations. How do I "store" my idle trains?

Post by Tertius »

A general approach. It doesn't just answer the question in the OP ("do this"), instead it explains the mechanics in general so it answers the question as byproduct.
  • every unloading station should have a train unloading
  • every loading station should have a train loading
  • empty trains should leave an unloading station immediately
  • every station has 1 or more slots (colloquial for "train limit").
  • we have a number of loading stations and a number of unloading stations. This is the number of stations of each type.
  • we have a number of loading slots and a number of unloading slots. The number of slots is the sum of the train limits of all stations of one kind.
  • basic schedule: 1) loading station - wait for full; 2) unloading station - wait for empty
  • employ the maximum possible number of trains
Let's have a factory with 4 iron ore unloading stations. How many trains, slots, waiting areas, ore loading stations do we need?

As start, we set a fixed train limit of 1 to every loading station. Unloading stations can have a circuit controlled train limit of 0 or 1, depending on the free space of the unloading station chests: 0 if the free space is less than the content of one train, 1 otherwise. But that's not required. It postpones dispatching full trains until a train is actually required.

Let's look at trains leaving their unloading station.
A train can only leave its unloading station, if there are free loading slots.
So we need at least as many free loading slots as we have unloading stations - in case every train gets empty at the same time.

Upper limit:
We must not have more trains than loading slots. [A]

Lower limit:
We want a train at every unloading station in case demand is high, so
we need at least as many trains as we have unloading stations [B]

So according to A and B, we need at least as many trains as unloading stations, but not more than the number of loading slots.

Let's assume we need 3 ore mines to satisfy the demand of one unloading station.
So we build 4*3=12 ore mines. This results in 12 loading slots.
According to A, the upper limit for trains is 12. According to B, the lower limit for trains is 4.
So we employ 12 trains to have as many loading stations occupied as possible.

What happens if every unloading station is full, and we set every train limit to 0 with circuits, so the number of unloading slots became 0?
After some time, all 12 trains are full and wait at their ore mines for an unloading slot becoming available. If it becomes available one train will start, freeing its slot at the loading station. If it becomes empty, it can return to its loading station, because that slot became available when it left.

This setup will work fine until the distance between loading and unloading stations becomes so high that the time required to travel from a loading station to an unloading station is longer than the train load actually lasts, so trains are unable to deliver enough to satisfy demand. Keep in mind: if an unloading slot becomes available, one train will start from an ore mine far away. If it needs more time to travel to the unloading station than the previous train unload lasts, the station chests will run empty.

In this case, we need more than 1 unloading slot per station, so we can have 1 train currently being unloaded and 1 or more trains currently driving to the station. We can build a longer track in front of every unloading station, so there is enough space for an additional train not clogging the main track. Now we can toggle the train limit of unloading stations between 1 and 2 via circuit (1 if the station is full, 2 if the station has space for at least 1 train).

If you do this, you might observe full trains waiting in front of full stations while another station is running empty.

So we need to clarify B:
We want a train at every unloading station in case demand is high, so
we need at least as many trains as we have unloading slots [B2]

So whenever we check B, we actually need to check B2 (count slots, not only stations)

Let's check:
4 unloading stations with 2 unloading slots = global 8 unloading slots.
This is below our train limit of 12 and should be enough, but in case all unloading slots are occupied, we have 8 trains dealing with unload and only 4 trains dealing with loading. So we might need to increase the number of trains to have full trains available in case one of the unloading slots becomes available again.

To be able to increase the number of trains, we need to increase the number of loading slots.
To increase the number of loading slots we can either add new ore mines, or we can add a longer track in front of the ore stations, similar to what we did for the unloading station, and increase the fixed station limit to 2 where we added this longer track. If we add new mines or just waiting space depends on supply and demand: if our demand can be satisfied by the existing mines, we only need to add a longer track. Otherwise we need to add more mines.

Finally, there is an alternative approach to add 1 additional track in front of each station. If there are multiple stations of the same type directly next to each other, which is common for unloading stations, you can share these tracks across stations. Create multiple parallel tracks ("stacker") that exit to these multiple stations, with proper chain signaling, so in case all stations are full the trains wait in the stacker, and if one slot becomes available, one of the waiting trains will reserve the track and proceed to that station.

If you use a stacker that serves multiple stations, the sum of the train limits of the individual stations is the sum of the number of stations plus the number of lanes in the stacker. So if you have 2 stations and want an overall train limit of 6, the stacker needs 6-2=4 lanes and each station needs a limit of 3. This way, if everything is full, 1 train is standing at each station and 4 trains are in the stacker.

Ok, there is a second finally.
Sometimes, the distance is so large, these waiting areas made of stackers won't work. Or the stations are so distributed, it makes no sense to make shared stackers. You can make stackers for one station of course, but that needs quite some space.
But it can happen your base grows so large, this direct approach of stackers directly in front of stations isn't feasible. In this case, you can create what I assume is called a depot. A depot is a lone station without loading/unloading functionality but with a stacker. Its train limit equals the number of lanes it has. You insert a depot station between loading and unloading, i. e. you can have a depot for empty trains in the schedule before the loading station, and a different depot for full trains before the unloading station. Its schedule entry doesn't have any waiting condition.

The maximum amount of trains changes with the usage of depots.
A changes, if you're using a depot for empty trains. It's currently "we must not have more trains than loading slots. [A]".
Since now empty trains can also wait in a depot, it's now:
We must not have more trains than empty train depot slots plus loading slots. [A2]
So we can use more trains!

If you're using a depot for full trains, neither A nor B changes. Its function is to uncouple waiting areas/stackers in front of stations from each other and to bring full trains near the base without actually assigning them to a specific stacker/unloading station.

Sorry for the long writeup... I somehow felt the urge to cover all of my observations.

ps.
Don't ever use the "activate/disable station" functionality with circuits. If a station is disabled while a train is driving to it, and there is currently no other station with the same name and a train limit above 0, this train stops right in the middle of nowhere, clogging the tracks. Always use train limits instead, which is the only possible operation in the upcoming Factorio 2.0, by the way.

astroshak
Filter Inserter
Filter Inserter
Posts: 597
Joined: Thu May 10, 2018 9:59 am
Contact:

Re: Automated train stations. How do I "store" my idle trains?

Post by astroshak »

Tertius wrote:
Tue Jan 16, 2024 12:36 pm
ps.
Don't ever use the "activate/disable station" functionality with circuits. If a station is disabled while a train is driving to it, and there is currently no other station with the same name and a train limit above 0, this train stops right in the middle of nowhere, clogging the tracks. Always use train limits instead, which is the only possible operation in the upcoming Factorio 2.0, by the way.
Its actually a little bit more nuanced than that.

Train enroute to a station that got disabled while it was still headed there? Train looks to find any other station of that same name. If all it finds are Disabled stations, it moves on to the next stop on its schedule. Once it finds any station going through its list that is Enabled, it looks at all of those stops for one that has an opening in its Train Stop Limit and goes there. If it goes through all of the stops with that name and all it finds are full stations, it stops wherever it is and sits there complaining about Destination Full.

Disabling a station can be a good thing, if you want the train to *skip* that station. I tend to do that with flamethrower fuel deliveries to the Walls. Since I already have a crude oil train, I just have the train’s schedule be :
Oil Wells (until full)
Wall Resupply (until empty) - usually Disabled unless there is nothing left in the tanks
Refineries (until empty).

The only drawback to this setup is that the train needs to go from the wall to the refinery then back to the oil wells to get more crude.

Post Reply

Return to “Gameplay Help”