Support for bidirectional stations

Adds new train stops forming a highly configurable logistic network.

Moderator: Optera

Post Reply
mrvn
Smart Inserter
Smart Inserter
Posts: 5704
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Support for bidirectional stations

Post by mrvn »

I'm trying to build a rail network with subcells that have no crossing rails. So everything is basically one big loop. Now when I need to move something from A to B it goes along the loop. But sometimes stuff needs to go from B to A and then it has to take the long way around taking forever. Or it would have to drive long the loop in the reverse direction causin major blockage.

So what I want to do is build the subcell like a ladder. One side has trains going up and one side has trains going down and the train stations on the steps of the ladder.

Code: Select all

^
H
H
H
H
H
v
Simple enough to build. But for this to work I need double headed trains bi-directional stations. A train going down will leave the station to the left and enter the next station from the left. A train going up will leave a station to the right and enter the next station from the right. Trains would have an odd number of cars so the cars end up at the same spots in both directions for best results. Each station has a train stop at both ends with the same name and the game picks the right station to drive to automatically. Works just fine with vanilla.

Not so with LTN because I can't name 2 station the same. What I want to do is change LTN so it allows stations with the same name IF AND ONLY IF they are on the same rail segment. Could you give me some idea where I would have to change that all and how difficult it would be please?

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2916
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: Support for bidirectional stations

Post by Optera »

Grouping stops to logical units is a reoccurring wish almost as old as LTN itself.

TLDR:
Development on this feature is on hold indefinitely.

Long version:
LTN tracks stops through entity.unit_number and trains through train.id. Changing to logical stop groups of 1 to n stops per group requires changing the entire data structure.
I was planning on doing that for the 2.0 release when my circumstances changed. Currently I hardly have time to maintain and add minor changes let alone doing such a massive redesign.

mrvn
Smart Inserter
Smart Inserter
Posts: 5704
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Support for bidirectional stations

Post by mrvn »

I looked at the code and have a proof-of-conecpt running. You don't really need a 1-to-N mapping of stations. What I did is share the activeDeliveries table between stations of the same name. I also only program one of the stops in the group. So if a train is scheduled for one station but arrives at the other the delivery still gets accounted to the right stop.activeDeliveries. It adds some code to the station rename and delivery rename but was simpler than I thought.
Bidirectional LTN stations
Bidirectional LTN stations
bidirectional.png (14.38 MiB) Viewed 2120 times
I still have some bugs with the indicator lights since they are controlled per stop and not as a group. Since programming more than one stop in a group would cause confusion for LTN so I'm thinking of adding a new entity, a slave train stop. A slave train stop would be like a LTN stop but without the indicator light and constant combinator. Instead the slave stop would use the main stops light and constant combinator. With that only slaves would be allowed to have the same name as a main stop.

Note: I didn't find any way to connect stations that should be handled as a group. Connecting them with wires works but there is no event telling me a wire was placed or removed. So LTN would have to check the wire connection constantly to detect changes. Not something I wish to do. Same with rail segments. No event when the segment status changes. I really don't want to poll this.


So in case you want to merge my changes later what do you think:

1) Should stations with the same name all have indicator lights and constant combinators (and those would be synced between stations adding a lot more code)? Or would a single master station and slave stations without extras be the way to go?
2) Should I poll to check stations with the same name are connected? Or simply allow stations with the same name and leave it up to the user to not do something stupid? (I lean towards the later)

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2916
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: Support for bidirectional stations

Post by Optera »

Slave stops have severe shortcomings
- output of composition and loading list would be on the master, but the station design would have to treat it backwards for the slave
- trains with even number of carriages have a 1 tile offset making this unfeasable
- players probably will start trying to group stops from parallel tracks
- I simply hate item and signal spam (worst reason of them all I know :P)

Why poll at all?
Duplicate name detection only has to run when entities are created, removed or renamed. LTN Stores them in a dictionary global.TrainStopNames.

A versatile, but very prone to user configuration error, way would be to add a signal with a group id.

mrvn
Smart Inserter
Smart Inserter
Posts: 5704
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Support for bidirectional stations

Post by mrvn »

Optera wrote:Slave stops have severe shortcomings
- output of composition and loading list would be on the master, but the station design would have to treat it backwards for the slave
- trains with even number of carriages have a 1 tile offset making this unfeasable
- players probably will start trying to group stops from parallel tracks
- I simply hate item and signal spam (worst reason of them all I know :P)

Why poll at all?
Duplicate name detection only has to run when entities are created, removed or renamed. LTN Stores them in a dictionary global.TrainStopNames.

A versatile, but very prone to user configuration error, way would be to add a signal with a group id.
- Yes, composition is a problem. I have to play with differently composed trains trains and think about what would be best to use.
- For bidirectional stops odd number of carriages is best because then the carriages align both ways. But one can work just fine with a 1 tile offset too. But that's a limitation of the game and if the player doesn't like it he shouldn't use bidirectional trains. Only thing I think LTN could care about is have a signal to only allow odd sized trains or palindrom trains. A flag for palindrom trains would be good for terminal stations too.
- I thought about that too. Shouldn't be a problem. The difficulty would be that you don't know which of the tracks the train ends up so you have to make sure all tracks have enough buffer space. Or you have to enable/disable individual stations when they have buffer space and adjust the number of trains allowed accordingly. Should be fun for people to design the combinator logic to make this works as they wish. Note: With cars, big (2x2) chests or warehouses you can unload into a shared buffer from 2 tracks.
- Why poll at all? Well, simply to detect user errors. If you simply put down 2 stops with the same name by accident then an error would be nice, On the other hand when you connect them it's probably on purpose.
But I'm fine with simply allowing any same named station to be a group.

Post Reply

Return to “Logistic Train Network”