How to Use Variables in Sessions (Examples)
From TrainzOnline
(Difference between revisions)
m (→Example 4: Train Status) |
m |
||
(One intermediate revision by one user not shown) | |||
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> | ||
<tr valign="top"> | <tr valign="top"> | ||
Line 117: | Line 114: | ||
<td>[[image:DotPoint.JPG|10px|link=]]</td> | <td>[[image:DotPoint.JPG|10px|link=]]</td> | ||
<td>The '''[[Session_Rule_List_with_Parameters#Variable_Random_Rule|Variable Random Rule]]''' is used to create a variable, '''stopID''', with an integer random value from 1 to 3. Each number representing one of the stops</td> | <td>The '''[[Session_Rule_List_with_Parameters#Variable_Random_Rule|Variable Random Rule]]''' is used to create a variable, '''stopID''', with an integer random value from 1 to 3. Each number representing one of the stops</td> | ||
+ | </tr> | ||
+ | <tr valign="top"> | ||
+ | <td colspan=2>[[image:VariableRandom.jpg|link=]]</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
Line 133: | Line 133: | ||
<table> | <table> | ||
<tr valign="top"> | <tr valign="top"> | ||
− | <td | + | <td width=10>[[image:DotPoint.JPG|10px|link=]]</td> |
+ | <td>'''[[Session_Rule_List_with_Parameters#Navigation_Display_Rule|Navigation Display Rule]]''' to create three Navigation Point Sets (in '''Preconditions''' above)</td> | ||
</tr> | </tr> | ||
<tr valign="top"> | <tr valign="top"> | ||
− | <td | + | <td>[[image:DotPoint.JPG|10px|link=]]</td> |
+ | <td>'''[[Session_Rule_List_with_Parameters#Navigation_Set_Hide/Show_Rule|Navigation Set Hide/Show Rule]]''' to hide all three navigation sets (in '''Preconditions''' above) and to reveal one set identified by the random variable</td> | ||
+ | </tr> | ||
+ | <tr valign="top"> | ||
+ | <td>[[image:DotPoint.JPG|10px|link=]]</td> | ||
+ | <td>'''[[Session_Rule_List_with_Parameters#Randomize_Rule|Randomize Rule]]''' to create a different sequence of random values each time the session is run (in '''Preconditions''' above)</td> | ||
+ | </tr> | ||
+ | <tr valign="top"> | ||
+ | <td>[[image:DotPoint.JPG|10px|link=]]</td> | ||
+ | <td>'''[[Session_Rule_List_with_Parameters#Variable_Random_Rule|Variable Random Rule]]''' to create the variable '''stopID''' (in '''Preconditions''' above)</td> | ||
+ | </tr> | ||
+ | <tr valign="top"> | ||
+ | <td>[[image:DotPoint.JPG|10px|link=]]</td> | ||
<td>'''[[Session_Rule_List_with_Parameters#Trigger_Check_Rule|Trigger Check Rule]]''' to trigger the decision and message event</td> | <td>'''[[Session_Rule_List_with_Parameters#Trigger_Check_Rule|Trigger Check Rule]]''' to trigger the decision and message event</td> | ||
</tr> | </tr> | ||
Line 151: | Line 164: | ||
</table> | </table> | ||
</td> | </td> | ||
− | |||
− | |||
− | |||
− | |||
</tr> | </tr> | ||
<tr valign="top"> | <tr valign="top"> | ||
Line 172: | Line 181: | ||
<tr valign="top"> | <tr valign="top"> | ||
<!-- <td> </td> --> | <!-- <td> </td> --> | ||
− | <td>[[image:AppRandomStop1.jpg|link=]]</td> | + | <td>[[image:AppRandomStop1.jpg|link=]]<br> |
+ | The '''Trigger Check''' sequence</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
Line 322: | Line 332: | ||
<tr valign="top"> | <tr valign="top"> | ||
<!-- <td> </td> --> | <!-- <td> </td> --> | ||
− | <td>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. | + | <td>Lines <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;"> 9 </span> and <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;"> 10 </span> 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. |
</td> | </td> | ||
</tr> | </tr> | ||
Line 609: | Line 619: | ||
<td> | <td> | ||
<span style="font-size: 17px;">'''More Tutorials and Guides to Using Trainz'''</span><br> | <span style="font-size: 17px;">'''More Tutorials and Guides to Using Trainz'''</span><br> | ||
− | *'''<span class=" | + | *'''<span class="plain;s">[http://online.ts2009.com/mediaWiki/index.php/HowTo How to Guides]</span>''' |
*'''[[Driver Commands List]]''' | *'''[[Driver Commands List]]''' | ||
*'''[[Session Rule List with Parameters|Session Rules List (Alphabetical) with Parameters]]''' | *'''[[Session Rule List with Parameters|Session Rules List (Alphabetical) with Parameters]]''' | ||
Line 617: | Line 627: | ||
</table> | </table> | ||
---- | ---- | ||
− | This page was created by Trainz user '''<span class=" | + | This page was created by Trainz user '''<span class="plain;s">[http://online.ts2009.com/mediaWiki/index.php/User:Pware pware]</span>''' in April 2018 and was last updated as shown below. |
---- | ---- | ||
[[Category:How-to guides]] | [[Category:How-to guides]] |
Latest revision as of 10:30, 2 August 2024
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.
[edit] 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: | |
The Trigger Check sequence |
Description: | |
Line 1 : Trigger Check The event is triggered when the consist passes over a track trigger. This executes the following rules:-
|
[edit] 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. |
[edit] 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:-
|
[edit] 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:-
|
[edit] 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.
|
[edit] 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.