Train limit for multiple stations

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
adhome
Burner Inserter
Burner Inserter
Posts: 6
Joined: Fri Jul 01, 2022 8:08 pm
Contact:

Train limit for multiple stations

Post by adhome »

Hello,

Short: I search for a setup/trick to limit the train count for multiple stations as a "group"

Long: I have a cityblock with 2/8 Trains and for example 20 Smelting rows in a block (20x8 smelter).
I like to have 1-2 trains always in the train buffer of this block (there are buffer lines near)
If i set the train limit to 2, i need 20 buffer lines next to the 20 smelting lines.
Sure, this problem is very common. But not sure if signals or additional train stations are a solution. Or LTN mod?

Thanks

robot256
Filter Inserter
Filter Inserter
Posts: 594
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: Train limit for multiple stations

Post by robot256 »

When train limits were added, also added was the ability to output the number of "inbound" trains on a circuit signal. If you have some tolerance for imprecision, you should be able to make a simple circuit that adds up all the trains that are inbound, subtracts it from a constant (the global limit), and sets each stop's limit to the remainder (or the remainder plus each stop's inbound trains, capped at a max value).

adhome
Burner Inserter
Burner Inserter
Posts: 6
Joined: Fri Jul 01, 2022 8:08 pm
Contact:

Re: Train limit for multiple stations

Post by adhome »

Thanks. I will try to setup this (;
Or if somebody have a template code of his base it will help also :D

PS: Working on a T2T base where a train makes ore till red circuit. Is working great with cargo filter.

adhome
Burner Inserter
Burner Inserter
Posts: 6
Joined: Fri Jul 01, 2022 8:08 pm
Contact:

Re: Train limit for multiple stations

Post by adhome »

I can not get this to work. If 2 trains are waiting in the parking slot, then they will go to the station, that they wanted to go at the beginning.
But in meantime a station with 1 train assigned to, will get to 0 and a train from far away is coming. The 2 Trains in the parking slot are still waiting to get to the stations, they wanted to go at the beginning.

It should only work, if the 2 Trains that are parking can go to every smelting row, that needs now a new train.

robot256
Filter Inserter
Filter Inserter
Posts: 594
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: Train limit for multiple stations

Post by robot256 »

Hmm, yes this won't work if the individual stations have a limit of more than 1 and share the name with any other stops.

If all trains in the stacker are bound for the same name unloading station, you can use a waypoint stop between the stacker and the unloaders. The waypoint stop has train limit=20 and the unloaders have limit=1. If all the unloaders are occupied, the first train to get to the waypoint will wait there until an unloading stop opens up. The rest of the trains will wait in the stacker for their turn at the waypoint stop.

You could increase throughput by adding another waypoint stop in parallel and give each waypoint limit=10.

adhome
Burner Inserter
Burner Inserter
Posts: 6
Joined: Fri Jul 01, 2022 8:08 pm
Contact:

Re: Train limit for multiple stations

Post by adhome »

Hi,
the limit should be like the count of parking slots i think....

But there is a other problem.... I have lots of this city blocks with 20x smelter rows. It could be, that after the first waiting station, the train likes to go to a other city block smelter and is first blocked, and then get blocked on the waiting station in the other block.

PS: I go to holiday tomorrow and not sure, if i can follow this thread regular (;

Adversarius
Manual Inserter
Manual Inserter
Posts: 3
Joined: Thu Jul 07, 2022 9:39 pm
Contact:

Re: Train limit for multiple stations

Post by Adversarius »

You could extend the last idea with the waiting station, and let the trains leave the waiting station only if the smelter has at least one free spot. Since the train will lock in the smelter station only after it is done with the waiting station, it should always pathfind only to the smelter of the current block (?).

First ideas to realise that would be an additional train schedule condition for the waiting station, checking the currently free smelter stations. Or blocking the access to the waiting station with a wired signal, also based on free smelter spots.

adhome
Burner Inserter
Burner Inserter
Posts: 6
Joined: Fri Jul 01, 2022 8:08 pm
Contact:

Re: Train limit for multiple stations

Post by adhome »

Thanks. But i think, that most is not practically possible.

I found perhaps a solution: Monitor with a signal the fill state of the train and if it close to empty or full and will leave the station, increase the train count of the station for a short time from 1 to 2
Then a train is making his way to this station. My question: If the train count is set back to 1, is the train still trying to reach this station?
As i remember my old gameplays it was so or?

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

Re: Train limit for multiple stations

Post by Tertius »

A generalized approach in spirit of your last idea is this:

For loading stations, you compute the number of trains that can be completely filled with the current chest buffer content of the loading station. Set the train limit to that number. You compute this number by dividing the sum of all chest content by the capacity of a standard train (every train has to be the same size).

For unloading stations, you compute the number of trains that can be completely emptied into the current empty space of the chest buffers of the unloading station. Set the train limit to that number. You compute the free space by subtracting the sum of all chest content from the capacity of all chests, then the amount of trains by dividing the free space by the capacity of a standard train.

For both stations, you need one arithmetic combinator and one constant combinator for each station.

This way, it's guaranteed that trains can be filled or emptied completely without waiting for items (on loading stations) or space (on unloading stations).

If a train limit is lowered, trains already driving continue to drive to the station. For the above solution, this doesn't matter, because there is never a train allowed for which there is not enough item space.

To make this actually work with a larger amount of trains, you need depots (waiting areas) between loading and unloading stations, so the schedule is this: loading station -> depot for full trains -> unloading station -> depot for empty trains

A depot is just a station without loading or unloading facility. It's a convenient place to supply fuel.

SoShootMe
Filter Inserter
Filter Inserter
Posts: 472
Joined: Mon Aug 03, 2020 4:16 pm
Contact:

Re: Train limit for multiple stations

Post by SoShootMe »

adhome wrote:
Fri Jul 22, 2022 9:55 pm
My question: If the train count is set back to 1, is the train still trying to reach this station?
Train limits are considered only when a train repaths; this happens when a train is ready to leave a stop but can also happen while between stops for various reasons (see Repath events in the Wiki). However, it is always possible for a train to repath to the stop it was heading to, even if the train limit has changed and would no longer allow it, as described by boskid in Friday Facts #361:
boskid wrote:
Fri Oct 09, 2020 6:43 am
For this i had to change the hook into trains logic: before the repath happens, old path is deleted. At this point reservation for the old target (or first waypoint) is stashed, and when possible targets list is created, train stop even when being full will still be returned as valid target if the train has a stashed reservation for it. This guarantees that train will not stop in the middle of the rail network because of the limit decreased.

adhome
Burner Inserter
Burner Inserter
Posts: 6
Joined: Fri Jul 01, 2022 8:08 pm
Contact:

Re: Train limit for multiple stations

Post by adhome »

So, this should work.
@Tertius: I need to make it little difficulter, because i use T2T to same train without buffer chests. But i can figure it out.

Post Reply

Return to “Gameplay Help”