How to Use Variables in Sessions (Examples)
From TrainzOnline
(Difference between revisions)
m |
|||
Line 89: | Line 89: | ||
<table width=1000 cellpadding=2 bgcolor=#ffffff> | <table width=1000 cellpadding=2 bgcolor=#ffffff> | ||
<tr valign="top"> | <tr valign="top"> | ||
− | <td width=60 rowspan= | + | <td width=60 rowspan=2>[[image:conditions.PNG|link=]]</td> |
<td colspan=2><span style="font-size: 17px;">'''Preconditions:'''</span></td> | <td colspan=2><span style="font-size: 17px;">'''Preconditions:'''</span></td> | ||
</tr> | </tr> | ||
Line 99: | Line 99: | ||
<td width=10>[[image:DotPoint.JPG|10px|link=]]</td> | <td width=10>[[image:DotPoint.JPG|10px|link=]]</td> | ||
<td>The '''[[Session_Rule_List_with_Parameters#Randomize_Rule|Randomize Rule]]''' is used at the start of the session to create a different sequence of random values each time the session is run</td> | <td>The '''[[Session_Rule_List_with_Parameters#Randomize_Rule|Randomize Rule]]''' is used at the start of the session to create a different sequence of random values each time the session is run</td> | ||
+ | </tr> | ||
+ | <tr valign="top"> | ||
+ | <td colspan=2>[[image:VariableRandom.jpg|link=]]</td> | ||
+ | </tr> | ||
+ | <tr valign="top"> | ||
+ | <td colspan=2>Setting the random variable '''stopID'''</td> | ||
</tr> | </tr> | ||
<tr valign="top"> | <tr valign="top"> | ||
Line 114: | Line 120: | ||
</table> | </table> | ||
</td> | </td> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</tr> | </tr> | ||
</table> | </table> |
Revision as of 10:28, 3 October 2023
The information in this Wiki Page applies to TANE, TRS19, Trainz Plus and TRS22. It gives examples of using variables in Sessions.
|
|
The scenarios shown below give examples of how variables can be used to control the operation of a session.
Example 1: Random Passenger Stop |
The Scenario: | ||||
In the example shown below a random variable is to be used to decide which one of 3 stations a user controlled train will be required to stop at. The user will be informed of the decision, to stop or not, by a message placed on the screen before they reach each station. When the train approaches the first possible stopping place, Sandplace, the session checks the value stored in "stopID" and if it is "1" then a stop will be requested. | ||||
|
Preconditions: | ||||||||||||
|
Rules Used: | ||||||||||||
|
Session Editor Screenshot: | |
Description: | |
Line 1 : Trigger Check The event is triggered when the consist passes over a track trigger. This executes the following rules:-
|
Example 2: Event Counter and Message Selection |
The Scenario: | |
Each time a user causes a SPAD (Signal Passed At Danger) at specific locations, the event is counted and an appropriate message is displayed on the screen. The tone of the messages becomes more severe with each occurance. |
Preconditions: | ||||
|
Rules Used: | ||||||||||||||||
|
Session Editor Screenshot: | |
Description: | |
Line 1 : Signal Passed At Danger The event is triggered every time a consist passes a signal (or stop sign) set at STOP. This executes the following lines:-
|
|
Lines 9 and 10 are then repeated with variations as shown. If more than 5 SPADs occur, then no new messages will be shown (the driver is clearly taking no notice so what is the point?) but the SPADCounter will continue to be updated. |
Example 3: Counting Consist Checks |
The Scenario: | |
The Consist Check Rule cannot be set to trigger only once but sometimes you want it triggered only once on (for example) the 2nd time that a particular consist is formed. This example uses a variable to count the number of times the rule has been triggered and acts only when a set count has been reached. It could easily be modified to trigger a set number of times. |
Preconditions: | ||
|
Rules Used: | ||||||||
|
Session Editor Screenshot: | |
Description: | |
Line 1 : Consist Check Rule Triggered when the specified consist has been found. This executes the following lines:-
|
Example 4: Train Status |
The Scenario: | |
A consist identified by number 188 passes over the same trigger twice, once when empty and once when loaded. Each time the user needs to be given a different set of instructions |
Preconditions: | ||
|
Rules Used: | ||||||
|
Session Editor Screenshot: | |
Description: | |
Line 1 : Trigger Check Rule Triggered by the train. This is NOT set to trigger once only. When triggered it will execute the following lines:-
|
Variable Rules and Commands |
These are the Session Rules that can access, create and/or modify Session variables
|
These are the Driver Commands that can access Session variables. The InputTable Rule must be added to the Session and configured with the names of the variables before these Driver Commands can be used.
|
Trainz Wiki
More Tutorials and Guides to Using Trainz |
This page was created by Trainz user pware in April 2018 and was last updated as shown below.