r/factorio • u/ParanoikCZ • May 07 '25
Tutorial / Guide Tutorial for LTN-like trains in vanilla
When starting SA, I was actually concerned LTN is discontinued (now it's already 2.0 ready) so I was looking for alternatives, tried few and Railway Logistics Dispatcher seemed to be promising. Eventually, I started vanilla for achievements and was all the time thinking how to do train stuff without mods. And here we are. It's possible to set up your train network only with interrupts. Totally generalized trains, only two types (for cargo and fluids). No radars, nor waits or advanced wiring. Just interrupts. And I would say it's even more effective since these mods usually uses depot station as the train's home and only updates its route when there.
Aside of common refuel, there is need for three different interrupts: Load, Unload and Depot if train is not needed.
Setup:
There are multiple ways how to achieve this, but let's have ALL stations that supply something to be named same name - 'Supply"/'Fluid Supply'. (If you want to identify stations or factory, you can use map tags). Let's unify ALL requesters as '[resource icon] Unload'. You can ofc differ station names by expected train sizes and categorize your trains accordingly. In this example, only one train size (2+4) is used. Set all station limits to 1, unless you are using waiting tracks.

Loading trains:
I guess this should be pretty straightforward. If the train is empty, go to supply station and wait until full.

Note: You need to recreate another interrupt for fluid trains because different station name.
Unloading trains:
Unloading is where stuff starts to be funny. Since the train is full after loading interrupt finished, we need to check cargo type and properly select unloading station accepting loaded items. To achieve this, you'll need to set a condition with exact cargo that contains a wildcard item parameter, which is then properly propagated to a target station. You'll need to write this station name manually. Wait condition is clearly waiting for the train to be empty.

Note: You need to create another interrupt for fluid trains with wildcard fluid icon.
What will happen? When the train is full, item parameter (icon) is loaded and propagated to the target station name. The train will try to find the closest one with proper name and if there is no available, it will wait in supply station until any will be free to accept loaded cargo.
Depot:
Since now fine, basically you'll start filling your network with trains, but it will get eventually clogged because trains that unloaded their cargo want to go to stations supplying cargo which are occupied by trains blocked by occupied unloading stations. So, to resolve this deadlock, we want the train that doesn't have a proper target loading station to park it in the depot until it has somewhere to go.
So, firstly, setup some depot parking like this and don't forget to set trains limit to 1 for each depot station.

For depot interrupt, we want to trigger it when target station is not available, and we want to trigger it only for empty trains since full has to wait in loading station otherwise your depot will be flooded with full trains and clogging whole network. Target will be depot without any waiting condition. This will lead into instantly triggering the loading interrupt after arriving into depot. Which will retrigger to depot if there is still nothing to do and since it's already sitting in depot and trains always chose the closest station, it won't do anything, just sit, and wait in the loop until some supply station becomes available.
Important: don't forget to tick checkbox allowing interrupting other interrupts.

Note: Set some basic, e.g. 5-10s wait if having like 100+ trains to avoid constantly looping in depot<>load interrupts.
Refueling tips:
It should be easy for you to create this interrupt by yourself, but here are some optimization tips:
- Set condition to fuel less AND empty cargo. Because if you don't tick the empty cargo, your train might get refueled full, and if target unloading will be occupied and since depot condition is only for empty trains, your train will be stuck in refueling station blocking others.
- Set condition to fuel wildcard and set it like <30. This allows you to have multiple refuel stations (useful for bigger networks) and mixed fuel types (wood/coal/solid/rocket).
- Don't set target condition to full fuel if you use mixed fuels because obviously you will never fill those locomotives.
- If transitioning to nuclear fuel, stop using wildcard and set condition to like nuclear fuel < 2. Replace all your refuel stations with nuclear fuel and make there unloading chest for each locomotive that takes out of them everything that is no nuclear fuel.
- Don't forget to tick interrupting for interrupts checkbox.
Optimization tip for lowering amount of trains in the network:
You might have noticed on the first screenshot that my unloading stations are red. They are red because they are disabled by wiring. What am I doing is disabling stations when trains cannot be unloaded. Why? Because it doesn't make sense having train sitting in supply and requester stations, so basically the idea is to limit amount of trains and overall logistics. How am I doing this? Connect all chests in requester station to train stop, calculate chests capacity, deduct train capacity and set stop to be enabled when under threshold. In this example, there are 4 wagons, each handled by 4 chests. So, chest capacity is 48 stacks by 50 (for ores) by 4 chests by 4 wagons, totalling in 38400 resources. Train capacity is then 40 stacks by 50 by 4 wagons, totalling in 8000. So, a train could properly unload if there are less than 30400 resources in the station. I've rounded down and using 30/60/120K for different stack sizes. It's kind of annoying, but since you start doing that, copy/paste eases the whole process. Also, for this, unloading cargo wagons needs to be properly balanced.

Same way, you might optimize requesters, either by enabling them or with some logic, set the number of allowed trains by remaining space in chests so they are able to fully unload. However, my experience showed, that in such case, you will still need specific amount of trains, but since they will be blocked either in loading stations or depots, you will never know the exact number. This might lead into situation that when factory production peaks, as trains prefers closest stations, they might supply only specific materials while others will be in deficiency. When not using any wires, all you need to check is that there is simply one train (per type) sitting in depot, since all loading and unloading stations should be always occupied. This way, you should always know when to add more trains.
9
u/Skorchel May 07 '25
Jup this is a perfectly working solution, but for some reason a lot of people seem fixated on using very few trains. I am not sure where this obsession is coming from, maybe its just having grown accustomed to LTN in the 1.x days.
3
u/ilpazzo12 May 07 '25
Beautiful, saving this.
Kind of a noob question, but what's the idea of putting more than one engine per direction on a train?
2
u/its2ez4me24get May 07 '25
Why does your unload interrupt have both full cargo & cargo item > 0?
2
u/ByePas May 07 '25
With this setup, you would have some trains sitting in supply stations waiting for a requester station to ask for it. You would be able to work around it by using circuitry with combinators and radars to only enable a supply station when there is an active request for that item.
2
u/Sostratus May 07 '25
Don't systems like this have a major problem of unbalanced deliveries? Like your generic trains just keep moving iron around while copper doesn't get serviced for a long time, for example.
Fixing that looks like a pain in the butt, and I'm not sure what you gain for the effort other than "hey look isn't it cool that these trains can move any item".
1
u/Somorled May 07 '25
Why do you want to limit the amount of trains in requester stations? Is that for practicality or aesthetics?
1
u/daV1980 May 07 '25
I like this and have setup similar. The only change I would suggest is that instead of using circuitry to disable stations, you use circuitry to set train limits at stations. I set my limit to 0 and then change the limit to 1 at each of the supply and delivery stations when they have at least one train to provide or receive, respectively.
1
u/MaeCilantro May 07 '25
Wouldn't this always send trains to the nearest available provider station no matter if the provider station has enough inventory to fill a train, or a respective requester station needs items?
If so why not just skip the LTN part and just use normal trains, that go from a defined provider to a defined requester. You could use blueprint parameters to make it so the provider station and accompanying train get pasted at the same time. Your design seems to want a train per provider station anyway.
1
u/TwiceTested May 07 '25
So the key is just have a lot of trains? have both the iron and copper station suppiers just named 'supply' or 'provider', with a limit of 2, and the overabundance of trains will just make sure we have 2 trains at these loading stations at all times! Should all the 'iron requesting' stations be full, the train just waits at the iron supply. All empty trains that can't fit in these supply stations are then routed to the Depots so the requester stations don't get clogged.
This tells me we should, at minumum, have a number of depot stations + supply stations equal to the total number of trains, otherwise things could get clogged. However, when do you need to make more trains? when you see that no trains are using the depots anymore?
1
u/SPHAlex May 08 '25
What's funny is I've been doing this since the introduction of "generic" parameters (almost to a T to what OP posted, except I use the new stack size feature to only enable station when it has enough stacks to fill all the wagons or when they have enough space to full empty them), but I still don't know what "LTN" actually means.
1
u/Sir_Richfield May 08 '25
Now I get it. :)
Making all suppliers generic was the thing I missed in the last post of yours.
But this makes the whole thing only work if you can make sure that ALL suppliers will have a train waiting, by having an overabundance of trains (no issue) or suppliers (which is kind of the point of the whole game).
Otherwise you risk that far out suppliers will be ignored, no matter the demand.
And when you have reached the goal, a train waiting in each supplier, the system will always drive a loop through the depots. Which isn't an issue as such, just a bit inefficient. :)
Throughput might be interesting with only limit 1. Heavily depending on demand and distance the train has to travel, ofc. But the shole system should work with a limit 2, just add more trains.
I think I'll give it a try in one of my next plays.
You can even specialize trains (with different sizes), only the "load" interrupt (and supplier names, ofc) must be changed.
1
u/Legit_Ready May 08 '25
I have a potential issue.
If you get unlucky, you can have multiple trains needlessly visit the same supply station in succession.
Let's say you have a sub factory that produces sulfur (an intermediate you dont need as much of as say, green Chips), and it's near your depot. A train goes to it fills up and leaves and heads to your sulfur dropoff. Just as it leaves another train becomes available and starts heading to the sulfur depot to get filled up. Then another. Odds are you don't have enough output to feed 12 wagons in a minute, so this third train acts like a stop to this loop (though this infinite requesting loop could continue beyond but it's unlikely)
So now your network has 3 full sulfur trains, essentially removing two of those trains from the network until you eventually request more sulfur.
If it happens to multiple stations simultaneously, you now have multiple trains full of "low demand" items that aren't helping throughout for your higher demand items.
Your trains are essentially randomly assigned, and randomness screams inefficiency.
A solution is, like for most things in this game, just build more trains, but that also means more depot slots and increased odds of this situation happening again.
A "real" solution would be, as someone mentioned, having your supply stations be circuit controlled to enable with demand. Is it a pretty solution? No. It's so off-putting to have such long spanning wires (or using radars for wireless) but I can't currently think of a better method of solving it.
2
u/MartokTheAvenger May 08 '25
I did not know the wildcards worked for station names like that, that is really cool.
1
u/korneev123123 trains trains trains May 07 '25
I used this exact configuration for vanilla, for delivering raw ores, works perfect.
But in modded playthrough i switched to multiple-requester stations, one station for each resource is simply not viable anymore
1
u/Haykii03 May 08 '25
That is clever. You just need as much train as producer, but its very fine. Thx for the idea !
1
u/egelat May 13 '25
I use something like this, but my only station for a train is the depot. All trains wait there until a request station can fit one trains worth. It triggers an interrupt to go load (providers only open based on having at least a full train load). Train goes to load, then unload, then back to depot. If I need say 2 iron, then signals are sent to dispatch 2 trains (of course, only if I have 2 providers worth of iron). No trains have ore unless requested so I can have say 5 trains for twice the number of stations all being reused. I use a timer at he depot so only one train is sent to a provider when requested and then I track the inbound train to stop signaling that the Provider is available to fulfill a requester. Works great. One interrupt for all solids, another for fluids
1
u/TasteNo9746 May 24 '25 edited May 24 '25
This is amazing, thanks! I've set it up successfully for items, but for some reason my fluid trains are not unloading. It says 'no stops with this name exists' while retaining the wild card logo instead of replacing it with the fluid logo (e.g. light oil) - is there something specific that needs to be setup for fluid unloading? Your post only mentioned a second interrupt for fluid loading
-2
u/[deleted] May 07 '25
Is there a reason why people saw braindead logistic bots and thought that it would be great to help solve all scaling issue by modding the game and making trains brain dead as well?
-1
u/Plastic-Analysis2913 May 07 '25
So, we anyway have to use hardly specialized trains (specific resource) - no way to use any train for any job? I ask it generally, because I tried to design such system but haven't found way to do that for multiple stations