Variable Modify Rule

From TrainzOnline
Jump to: navigation, search
VariableModifyRule Icon.jpg

The Variable Modify Rule is used to define and modify a custom integer variable within a session. The variable can then be shown to the player via the Variable Show Rule or tested to affect the session outcome via the Variable Check Rule.

What is a variable?

A variable is an identifier linked to a numeric value which once set can be updated as a result of an event or series of events. A variable can be accessed and measured at any time, and used to trigger outcomes or consequences that are assigned to specific values.


Configuration Options


The rule can be run in three different modes:
Add: Adds the amount specified to the variable upon execution
Subtract: Subtracts the amount specified from the variable upon execution
Change: Sets the value of the variable to the specified amount upon execution


Specifies the amount to be added to, subtracted from, or set to for the variable.

Variable Name

Specifies the variable name. Variable names are used to identify the variable between rules. They can be anything you like, but be sure the name is meaningful or you may forget what it does.

TBD: Are there any limits or guidelines for variable names? Are they case sensitive? Are there any reserved or regularly used names?

TBD: What is the initial value of an unused variable?


In the add and subtract modes it is possible to have the addition/subtraction undone if the rule execution is stopped. This can be handy for performing tests such as whether a train is at a specific location.

TBD: What does 'stopped' mean in this context? How do I stop a rule?

Upper/Lower Limits

You can optionally have the rule specify a minimum and maximum value for your defined variable. This option is disabled by default.

TBD: Does this minimum and maximum apply only to this modification, or does it stay in force on the variable for future modifications? TBD: What happens if some modifications under- or overrun this limits?

Personal tools