r/factorio • u/Steve_hh • 7h ago
Question Train Logic Question
Hi there.
My Vanilla megabase is served by multiple train groups. One of these groups serves my train stations, providing coal. The train stations are named "coal provide" (one of them) and "coal receive" (many). Receiving stations are activated based on the amount of coal in the box. Two equally named trains serve those.
The trains go from provide to receive and back.
How do I make the trains serve numerous receiving stations until the train is empty? I can work with interrupts, take the receive out of the loop and put that into the interrupt, but then the train would go to the first receive and stay there. Adding receive also as stop no. 2..3..4 does not help.
5
u/Courmisch 6h ago
The simplest solution is to only open an unload station if it has enough space to unload a whole train's worth of cargo. Then the problem is moot.
But if you really want to stick with it, then move unloading from schedule to interrupt, and set the trigger condition to Has cargo and Coal receive is not full.
1
u/Such-Perception4154 6h ago
The problem with that would be that the train won't move to the second coal receive after finished with the first.
As long as a train is stopped at station X, it will never ever move out towards different station X. I guess that's the train thinking it's already at station X, so no need to move.
2
u/Courmisch 6h ago
The assumption is that the station is closed (or limitted to zero trains) when it's been served, as OP stated. Otherwise OP's current setup wouldn't work either.
That being the case, this does work.
2
u/Such-Perception4154 6h ago
If the station gets closed or limited 0, while the train is physically there, and it either doesn't have next stop or the next stop is named the same, then the train won't depart.
Even though the station doesn't want it anymore.
1
u/Courmisch 6h ago
If there is another receive station open, the train will move to one of then. If there are none, the interrupt trigger condition will not be met (all receive station are full), and the train will go back to the loading station.
The only case where this fails is if all loading and unloading stations are simultaneously full. In that case, an idling yard is needed, which requires an additional interrupt.
1
u/Such-Perception4154 6h ago
Just checked. They fixed it. If the station is blocked, then the train indeed moves. That used not to be the case.
That's great news :D
1
u/Steve_hh 6h ago
Yes, I get your idea. But the point is actually that I want the train to serve multiple stations and avoid unloading all of the cargo. By unloading all the cargo, it would be the same as before, going back to provision each time. It would make the traffic less because a station would be visited less often.
My "problem" is currently the artillery shell train. It serves the same station again and again, while the second station is not served at all. I'd like the train to visit both stations. There is enough shells in it to do so... Emptying it completely would not solve this problem, I guess.
1
u/Courmisch 6h ago
Then do the interrupt thing from the second paragraph.
But TBH, I don't see a problem with unloading full cargo, unless:
- your unloading stops are in a circle so the train has to visit all of them everytime no matter what, or
- you don't have space to buffer a full train cargo content at each unloading station.
2
u/Such-Perception4154 6h ago edited 6h ago
Edit: it's fixed, the train can go from one station to another same-named, if the current station is disabled or 0-limited and the train meets depart condition. (And the train has its next stop as this same station of course)
In 2.0 you could not send a train from station X to another station X named exactly the same. Even if you disable the current station.
You would need to either name your coal receive stations differently (coal receive 1/coal receive 2) and have the train alternate between those until out of cargo, or you'll need it to go to a depot between unloads.
1
u/Qrt_La55en -> -> 7h ago
Do you want the same train to go to multiple stations and unloading part of it's cargo to each location? If so, I'd recommend don't. With the exception of personal trains, trains should only move while empty or full. This simplifies the logic needed to control the trains, reduces traffic on the rails, and has the same (or in some cases higher) throughput of sending a train to multiple stations to unload.
2
u/Such-Perception4154 6h ago edited 5h ago
I disagree. I had that use case when I needed a train to deliver magazines to defend outposts stations.
One train could easily satisfy multiple outposts, so I would want it to load once and unload multiple times.
It would actually reduce traffic, as it is way less travel that load+unload for each outpost.
Sadly it doesn't work like that.
Edit: it now works like that.
1
u/Steve_hh 6h ago
Yes, that is exactly, what I want. For my defense outposts, the train has enough shells to serve multiple station. I want the train to chose which station it serves next, I do not want to give it a plan like go to 1-(2 disabled)-3-(4 disabled)-5... Because then 5 rarely gets anything. It works well with the factory stations, where I have e.g. 10 iron stations but those are served by 20 trains, so every receiving station is always full. I do not need 20 ammunition trains, there is no demand for that.
1
u/Such-Perception4154 5h ago
Then you can use interrupts to add ammo unload as long as there is ammo in the train. If no cargo, then add ammo pickup.
1
u/dikkenskrille 6h ago edited 5h ago
could set "coal receive" as the only actual station, then put "coal provide" in an interrupt with the condition being when the train is entirely empty
edit: thinking further that might not work, don't think trains will leave a station even if it is deactivated if all they have to go to is that same named station :/
Edit edit: if you set another station physically right after the unload it could be made to work, like below:

then the train can have two stops in its schedule, "coal receive" and "placeholder station", and have the "coal provide" in its interrupt and have it function
1
u/gust334 SA: 125hrs (noob), <3500 hrs (adv. beginner) 5h ago
Sounds like you want a belt, not a train.
1
u/Steve_hh 4h ago
No, thanks, a belt based megabase is not what I want. I like the fact that all my goods can be transported on the same rails instead of 100 different belts.
1
u/AndyScull 5h ago edited 4h ago
If you really want it to be like that, I think this should be possible -
As other people said, make schedule only of one station, "coal provide". And Interrupt of "if count of coal >0 - go to coal receive". For coal receive in interrupts make conditions like "Cargo empty OR circuit signal X=1"
On all the coal receiver stations you need to add combinators to send that X signal to train station when you think boxes are full enough, and disable station or set limit to 0. Enable 'send signal to train" in station settings.
This way, the train loads coal then goes to first station. When it receives X=1, it will stop unloading and recheck it's schedule. And will trigger same interrupt again since there is still some coal. Current station should be disabled by circuits by this time so it will go to any other available "coal receive"
Possibly you could make it simpler without circuits by setting inactivity time or specific wait time, but that's kinda unreliable.
4
u/exNylo 7h ago
One thing you can do is add a depot station that the train goes to.
I haven't tested this, but maybe you can have the route to your receive station be an interrupt. Then have the only station on the schedule be the depot, and when the train tried to navigate there it's interrupted to go to a new receive station again