So, I have 2 train routes for exports, highlighted for visibility:
- A cement train that runs between the red line (at the end of which is a loading station for cement) and the customs house at the far end of the green line
- A gravel train that runs from the aggregate loading station at the end of the blue line to the same customs house
Here's the behavior I want:
- When returning from the green route, a train has right-of-way to return to its loading station
- If a train arrives at the intersection from the red or blue route, it should proceed only if there is no train on the green line; otherwise, it should wait until the green line is clear
I'm not entirely sure how semaphores work and no combination of them seems to do the trick. I get trains unable to return from the customs house, trains colliding, or trains forever deadlocked at the junction. I've watched/read like 3 different tutorials and I'm still not sure what I'm supposed to do.
If you want a simple rail like this, the way to think of is like this:
these rules mean that
a) You need at least n+1 segments of track for it to be possible for your trains to move (n is the number of trains)
b) Each "branch" of the shared line can only service a single train (since two trains trying to enter/exit a branch simultaneously will get stuck)
So for this setup, you need two semaphores to make it work
This should split your track into three sections, which is enough if you have 2 trains. Assuming that only one train is traveling to the red branch, and only one train traveling to the blue branch, this setup should provide exactly the behavior you're after, where a train on the green section causes a train trying to enter it to wait.
That said, it's a LOT easier to make trains work seamlessly with dual parallel tracks (one going in each direction, using one-way semaphores to force the trains to use the correct side, and having junctions at the customs house to allow trains to start/end on any track). If cost is a concern, you can create what i'm going to call a "one and a half" track by adding a "passing lane" halfway between the customs house and your town, and using semaphores to make each side of the "passing lane" one-way (make sure the passing/waiting track section is at least as long as your longest train!).
Thanks, that got it to work! The trains are running properly now.
I'll give it a shot, thanks for the suggestion. I feel like I'm slowly getting the hang of semaphores so I might be able to make this work.