Session building help - automatic junction switching

rjc0235

Member
I am not new to Trainz, but i am very new to trying to build sessions which are more than a single train running along a pre-set route. Yes I have Googled this, but it is likely i do not know the specific terms to search.

I am trying to program a "scheduled" train (likely a trigger from the player train) having to pass the player at a passing point on a single track route (specifically the new "Ferrovia Appennino Centrale" (FAC) route).

But I want it to work that if the player gets their first, they have to wait for the AI train, or if the AI train gets their first, the player can go straight through, and the AI has to wait.

But how do i get the junctions to automate?

The AI train will happily flip junctions in front of me to get to its destination, but how do i get that junction to flip back again to allow my train to pass through the junction?

Is it really as simple as "set the junction how you want the player to go, and rely on it pinging back to default once the AI has passed through?"

Any help would be appreciated, many thanks.
 
Set the junctions using a "Set junctions" rule and have the AI train move using an "Autodrive to..." order. The AI train will follow the path you define with the "Set Junctions" rules and will not turn the junctions.

Of course, you will have to set the junctions again once the AI train has entered the siding so as to allow the player train to run along the main. This can be accomplished using a "Check Trackside" rule with another "Set Junctions" as a child rule: set the Check Trackside so as to trigger it when the AI train stops at its destination TM.
 
It seems what you are trying to do is called a "soft meet" in model railroading. To be able to proceed if the opposing AI train has not arrived, you will have to see that it has stopped somewhere ahead and is waiting for you. You would have to locate or write a command or rule to have the AI train message you with its location, and the other way around as well. If you are running a schedule, the AI train could also get out of the way if it does not reach a certain destination by a certain time. Trackside assets such as semaphores and trackmarks send messages to your AI train that you can check in a program. You could do it that way also.
 
I assume the map is something like this.
Code:
        _B_____loop____C_
___A___/_D_____________E_\___F___
      J0                 J1

Your AI train is moving from point A to point F
The Player's train is moving from point F to point A.

If the Player reaches F before the AI reaches A, you want to loop the player.
If the AI reaches A before the player reaches F, you want to loop the AI.

You'll need rules something like the following:

Code:
Lineside Check: Player Train enters Trackmark F
  Set Variable FLAG = 1

Lineside Check: AI Train enters Trackmark A:

  # Player train isn't near the loop yet
  Variable Check FLAG not equals 1
    Set Junction J0 LEFT # put AI train in Loop
    Set Junction J1 LEFT # put Player train on mainline
    Append Driver Command: AI Navigate via Trackmark C

  # Player train is near the loop
  Variable Check FLAG equals 1 
    Set Junction J0 RIGHT # put AI train on mainline
    Set Junction J1 RIGHT # put Player train in Loop
    Append Driver Command: AI Navigate via Trackmark E

 # The AI Train has cleared J0 and is in the loop. Allow the Player's train to proceed on the mainline.
Lineside Check: AI Train Leaves Trackmark B:
  Set Junction J0 RIGHT

# The AI Train has cleared J0 on the mainline. Allow the Player's train to exit the loop.
Lineside Check: AI Train Leaves Trackmark D:
  Set Junction J0 LEFT

# The Player's Train has cleared J1 and is in the loop. Allow the AI train to proceed on the mainline.
Lineside Check: Player Train Leaves Trackmark C:
  Set Junction J1 LEFT
  Append Driver Command: AI Navigate via Trackmark F


# The Player's Train has cleared J1 on the mainline. Allow the AI train to exit the loop.
Lineside Check: Player Train Leaves Trackmark E:
  Set Junction J1 RIGHT
  Append Driver Command: AI Navigate via Trackmark F
If you're not too bothered about the AI train proceeding up the line after the player has passed, you can ignore the last two rules...
 
Back
Top