How To Get Started
There is a lot of material to be covered on the subject of scripting. Here is a suggested recipe for easing your way into it.
1. Watch the Arlington in action.
Included with the release is the Arlington RR (filename arlington_s.rrw). This layout has a set of scripts which automatically run the Local along its route. At each stop, a Junction Action takes control of the train, pulls it into the station, waits while passengers exchange, then pulls it out again and turns it back over to the main script.
Instructions for running the demo:
The train starts to move and so does the script. Script comments and messages are echoed to the schedule window to keep you informed as the scripts run. With luck, the train will run all the way around the layout, making three stops, then wait a bit and start over. And you will have gotten a reasonable idea of what a script can do.
2. Record a script.
You can create a script without doing any programming or having any knowledge of the script language: just press Record, and let the program generate a script as you operate the train; change speed, throw switches, reverse, uncouple -- every action generates the corresponding script language. Press Stop when done, and there you have a script you can rewind, replay, save, and study. If you have the Script Editor up while recording, you can see the script as it gets created.
It is just that easy to record a script, but here are a few disclaimers. First, when you replay a recorded script, it may not exactly reproduce your sequence of actions. You have to cut it some slack as it tries to convert mouse moves into script commands. Second, the result is not optimized for readability. For example, varying the train speed while recording often generates a pile of speed-change commands, where in a hand-made script, only a single speed command is needed to do the job.
If you are not the programmer type, you don't need to go beyond this step. Use script recording to capture the action on your layout, then play it back, or send it to another TP user to play back.
3. Write a Junction Action.
The low-barrier way to write your first script is to right-click a track junction and create a little action there -- say a one-line script to announce something in the output window. Bring a car up next to the junction, roll it across, and the action executes. Do this a time or two and you might find yourself wanting to make fancier actions.
The procedure:
echo Crossing the junction!
4. Write a Train Script
Writing a train script is no harder than writing a junction action, but it involves an additional complexity or two.
The procedure:
speed 20
throw J36 1
at J37 stop
except yours will of course have appropriate junction numbers for your layout.
A couple of shortcuts:
5. Join the Scripters' Forum
You will surely come up with questions. The best place to go for answers is our panel of experts.
6. Become an expert.
Script your layout, or do one of ours, send us the result and we'll post it for others to enjoy. To inquire, send e-mail.