About Scripting

A TrainPlayer script is a series of instructions for operating a layout. It may contain commands to drive trains, throw switches, set preferences, execute menu commands, make decisions -- pretty much everything you need to choreograph a complex operation, then play it back and watch it all run automatically. Scripting is the name we give to the enjoyable and challenging activity of designing and developing these things.

It's a form of computer programming, is what it really is. Possibly you have done some of this in the past, possibly not, but if you are a railroader and a do-it-yourselfer, you will probably enjoy tinkering with it. You can actually get started without doing any programming at all -- just use the script record/playback machinery to create and run scripts.  For more, see How to Get Started in Scripting.

There are several types of script, different in how they are connected to the layout and how activated. Types are:

Train Script a script attached to an engine, designed to drive a train through a series of moves
Junction Action a script attached to a track junction, activated when a given car or train goes across
Master Script a script attached to a layout, designed to run automatically when the layout is opened
Subroutine a batch of script language designed to be called and executed from within other scripts
Proc a subroutine stored not in a file, but between special delimiters inside another script

For more about these types, and procedures for handling them, see Working With Scripts.

Some layouts have multiple scripts of various types.  To manage and keep track of all of them, use the handy new tabbed dialog called Script Central. This dialog gives you a way to browse through scripts and subroutines, not just examining but also editing, deleting, and setting properties.  Scripting also involves a collection of menus, dialogs, toolbars, and other interactive devices; an illustrated overview is given in Scripting UI Devices.

All scripts are written in a custom programming language especially designed for operating TrainPlayer layouts.  An overview of the language is given in TrainPlayer Programming Language.  For a detailed language and command reference, use the built-in guide in the Script Central Reference Tab.

For more information: