Trainz/Driver Sessions and Rules< Trainz
A Rule is a command which runs in a Driver session.
In the config.txt file of a Trainz asset, setting
"behavior" as the parameter of the
kind tag identifies the asset as a Rule. For this reason, Rules are sometimes also called behaviours.
Rules are not the same as Driver Commands, although they are closely related to each other. The Driver Command Rule specifies which Driver Commands will be available in a Driver session.
Rules are also not the same as Scriptlets. Scriptlets are sections of GameScript coding associated with assets such as rolling stock items and industries.
How Rules Are SpecifiedEdit
Rules and their parameters are specified when a Driver session is created in Surveyor, by means of the "Edit Session Rules" option. A few standard built-in Rules are available by default. Additional built-in and custom Rules can be added as desired.
When Rules OperateEdit
By default Rules commence operation as soon as the Driver session starts to run.
In "Edit Session Rules", Rules can be indented, in which case they will only be obeyed when the Rule immediately above the indented Rule fires its event.
For example, a master Trigger Rule can have a Play Sound Rule indented under it, so that the sound will be played when a train enters a trigger. This is analogous to the ON EVENT concept in traditional programming.
Rules indented under an Ordered List Rule will be run in sequence, each one commencing only after the previous one completes.
- TRS2004 World Builders Manual > Section 13 Surveyor Main Menu > Session And Rules Management
- Explains the concept of Rules, how to specify Rules and their parameters, and what the standard built-in Rules do.
- TRS2006 Manual > Section 11.14 Session And Rules Management
- Explains the concept of Rules, how to specify Rules and their parameters, but not what the standard built-in Rules do.
- TRS2006 Sessions & Rules Guide (downloadable from Auran's web site)
- Covers the subject in detail, except that it has no information about how to create Rules, only how to use them. Most of the material in this document is also applicable to TRS2004.
- TRS2004 SP2 Variable Rules Tutorial (downloadable from Auran's web site)
- Explains the usage of the variable Rules which were introduced with TRS2004 SP2. The downloadable package includes a sample tutorial route and Driver session.