How to Use Variables in Sessions (Examples): Difference between revisions

From TrainzOnline
Jump to navigationJump to search
Pware (talk | contribs)
mNo edit summary
Pware (talk | contribs)
No edit summary
Line 1: Line 1:
The information in this Wiki Page applies to '''TANE''', '''TRS19''', '''Trainz Plus''' and '''TRS22'''. It gives examples of using variables in Sessions.
The information in this Wiki Page applies to '''TANE''', '''TRS19''', '''Trainz Plus''' and '''TRS22'''. It gives examples of using variables in Sessions.
 
<table width=1000>
<tr valign="top">
<td width=350>
__TOC__
__TOC__
<br>
</td>
<table cellpadding=4 bgcolor=#c1e7e7>
<td>
<table bgcolor="lightcyan" cellpadding=2>
<tr valign="top">
<td width=10>[[image:BlueDot10x10.png|link=]]</td>
<td>Variables store '''integer values''' in Sessions that can be used to:-
<table>
<tr valign="top">
<tr valign="top">
<td colspan=2><span style="font-size: 17px; font-weight: 700;">Main Points:</span></td>
<td width=10>[[image:BlueDot10x10.png|link=]]</td>
<td>'''Test''' for certain events (e.g. if something has occurred a set number of times)</td>
</tr>
</tr>
<tr valign="top">
<tr valign="top">
<td>[[file:DotPoint.JPG|link=]]</td>
<td>[[image:BlueDot10x10.png|link=]]</td>
<td>'''Variables store integer values in Sessions''' that can be used to:-
<td>Make decisions according to the value held by a variable</td>
*'''Test''' for certain events (e.g. if something has occurred a set number of times) and '''make decisions''' according to the value held by a variable
*Act as '''counters''' or '''score keepers'''</td>
</tr>
</tr>
<tr valign="top">
<tr valign="top">
<td>[[file:DotPoint.JPG|link=]]</td>
<td>[[image:BlueDot10x10.png|link=]]</td>
<td>'''Variables can be used for basic arithmetic by having set values added or subtracted'''</td>
<td>Act as '''counters''' or '''score keepers'''</td>
</tr>
</table>
</td>
</tr>
</tr>
<tr valign="top">
<tr valign="top">
<td>[[file:DotPoint.JPG|link=]]</td>
<td>[[image:BlueDot10x10.png|link=]]</td>
<td>'''Variables can have random values assigned to them'''</td>
<td>Variables can be used for basic arithmetic by having set values added or subtracted</td>
</tr>
<tr valign="top">
<td>[[image:BlueDot10x10.png|link=]]</td>
<td>Variables can have random values assigned to them</td>
</tr>
</table>
</td>
</tr>
</tr>
</table>
</table>
Line 25: Line 41:
The scenarios shown below give examples of how variables can be used to control the operation of a session.
The scenarios shown below give examples of how variables can be used to control the operation of a session.
<br>
<br>
<table> <!-- BEGIN Nav Buttons Table -->
<table width=1000> <!-- BEGIN Nav Buttons Table NO SKIPS -->
<tr valign="top">
<tr valign="top">
<td width=729><span id="stepEx1"></span>&nbsp;</td>
<td width=629><span id="stepEx1"></span>
<td width=46>[[file:BackToTop.png|link=#top|alt=Top|Top]]</td>
='''Example 1: Random Passenger Stop'''=
</td>
<td width=50>&#160;</td> <!-- Skip Down -->
<td width=50>&#160;</td> <!-- Skip Up -->
<td width=46>[[image:BackToTop.png|link=#top|alt=Top|Top]]</td>
<td width=75>&nbsp;</td>
<td width=75>&nbsp;</td>
<td width=75>[[file:NextDown.png|link=#stepEx2|alt=Next Down|Next Down]]</td>
<td width=75>[[image:NextDown.png|link=#stepEx2|alt=Next Down|Next Down]]</td>
<td width=75>[[file:BackToBottom.png|link=#bottom|alt=Bottom|Bottom]]</td>
<td width=75>[[image:BackToBottom.png|link=#bottom|alt=Bottom|Bottom]]</td>
</tr>
</tr>
</table> <!-- END Nav Buttons Table -->
</table> <!-- END Nav Buttons Table -->
='''Example 1: Random Passenger Stop'''=


<table cellpadding=4 bgcolor=#ffffff>
<table width=1000 cellpadding=2 bgcolor=#ffffff>
<tr valign="top">
<tr valign="top">
<td>[[file:magnifier.png|link=]]</td>
<td width=60 rowspan=4>[[image:magnifier.png|link=]]</td>
<td width="640"><span style="font-size: 17px;">'''The Scenario:'''</span><br>
<td><span style="font-weight: 700; font-size: 17px;">The Scenario:</span></td>
----</td>
</tr>
</tr>
</table>
<table width=1000>
<tr valign="top">
<tr valign="top">
<!-- <td>&#160;</td> -->
<td>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.
<td>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.</td>
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.</td>
</tr>
<tr valign="top">
<!-- <td>&#160;</td> -->
<td>[[image:RandomLogic.jpg|link=]]</td>
</tr>
<tr valign="top">
<!-- <td>&#160;</td> -->
<td>
<table>
<tr valign="top">
<td width=10>[[image:DotPoint.JPG|10px|link=]]</td>
<td>If a stop is required then a predefined '''Navigation Point''' is shown to indicate the stopping place</td>
</tr>
<tr valign="top">
<td>[[image:DotPoint.JPG|10px|link=]]</td>
<td>The same logic is repeated for the other two stations with '''stopID''' values of "2" and "3"</td>
</tr>
</tr>
</table>
</table>
 
</td>
</tr>
</table>
<br>
<table width=1000 cellpadding=2 bgcolor=#ffffff>
<tr valign="top">
<td width=60 rowspan=4>[[image:conditions.PNG|link=]]</td>
<td colspan=2><span style="font-size: 17px;">'''Preconditions:'''</span></td>
</tr>
<tr valign="top">
<!-- <td>&#160;</td> -->
<td>
<table>
<table>
<tr>
<tr valign="top">
<td>[[file:RandomLogic.jpg|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>
</tr>
<tr valign="top">
<td>[[image:DotPoint.JPG|10px|link=]]</td>
<td>The '''[[Session_Rule_List_with_Parameters#Navigation_Display_Rule|Navigation Display Rule]]''' is used to create three Navigation Point Sets, one for each stopping place</td>
</tr>
<tr valign="top">
<td>[[image:DotPoint.JPG|10px|link=]]</td>
<td>The '''[[Session_Rule_List_with_Parameters#Navigation_Set_Hide/Show_Rule|Navigation Set Hide/Show Rule]]''' is used to initially hide all three navigation sets</td>
</tr>
</tr>
</table>
If a stop is required then a predefined '''Navigation Point''' is shown to indicate the stopping place.
The same logic is repeated for the other two stations with '''stopID''' values of "2" and "3".
<br><br>
<table cellpadding=4 bgcolor=#ffffff>
<tr valign="top">
<tr valign="top">
<td>[[file:conditions.PNG|link=]]</td>
<td>[[image:DotPoint.JPG|10px|link=]]</td>
<td width="640"><span style="font-size: 17px;">'''Preconditions:'''</span><br>
<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>
</tr>
</tr>
</table>
</table>
*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>
*The '''[[Session_Rule_List_with_Parameters#Navigation_Display_Rule|Navigation Display Rule]]''' is used to create three Navigation Point Sets, one for each stopping place.
</tr>
*The '''[[Session_Rule_List_with_Parameters#Navigation_Set_Hide/Show_Rule|Navigation Set Hide/Show Rule]]''' is used to initially hide all three navigation sets.
<tr valign="top">
*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>&#160;</td> -->
<table>
<td>[[image:VariableRandom.jpg|link=]]</td>
<tr>
<td>[[file:VariableRandom.jpg|link=]]</td>
</tr>
</tr>
<tr>
<tr valign="top">
<!-- <td>&#160;</td> -->
<td>Setting the random variable '''stopID'''</td>
<td>Setting the random variable '''stopID'''</td>
</tr>
</tr>
</table>
</table>
<br>
<br>
<table cellpadding=4 bgcolor=#ffffff>
<table width=1000 cellpadding=2 bgcolor=#ffffff>
<tr valign="top">
<td width=60 rowspan=2>[[image:RulesWiki.PNG|link=]]</td>
<td><span style="font-size: 17px;">'''Rules Used:'''</span></td>
</tr>
<tr valign="top">
<!-- <td>&#160;</td> -->
<td>
<table>
<tr valign="top">
<td colspan=2>In addition to those used in the '''Preconditions''' above:-</td>
</tr>
<tr valign="top">
<tr valign="top">
<td width="58">[[file:RulesWiki.PNG|link=]]</td>
<td width=10>[[image:DotPoint.JPG|10px|link=]]</td>
<td width="640"><span style="font-size: 17px;">'''Rules Used:'''</span><br>
<td>'''[[Session_Rule_List_with_Parameters#Trigger_Check_Rule|Trigger Check Rule]]''' to trigger the decision and message event</td>
----</td>
</tr>
</tr>
</table>
<tr valign="top">
In addition to those described in the '''Preconditions''' above:-
<td>[[image:DotPoint.JPG|10px|link=]]</td>
*'''[[Session_Rule_List_with_Parameters#Trigger_Check_Rule|Trigger Check Rule]]''' to trigger the decision and message event.
<td>'''[[Session_Rule_List_with_Parameters#Variable_Check_Rule|Variable Check Rule]]''' to check the value held in a session variable
*'''[[Session_Rule_List_with_Parameters#Variable_Check_Rule|Variable Check Rule]]''' to check the value held in a session variable.
<table>
<table>
<tr>
<tr>
<td>[[file:VariableCheck.jpg|link=]]</td>
<td>[[image:VariableCheck.jpg|link=]]</td>
</tr>
</tr>
<tr>
<tr>
Line 100: Line 152:
</tr>
</tr>
</table>
</table>
*'''[[Session_Rule_List_with_Parameters#Navigation_Set_Hide/Show_Rule|Navigation Set Hide/Show Rule]]''' to show the navigation set identified by the random variable.
</td>
*'''[[Session_Rule_List_with_Parameters#Message_Popup_Rule|Message Popup Rule]]''' to open a message window on the screen.
</tr>
<tr valign="top">
<td>[[image:DotPoint.JPG|10px|link=]]</td>
<td>'''[[Session_Rule_List_with_Parameters#Navigation_Set_Hide/Show_Rule|Navigation Set Hide/Show Rule]]''' to show the navigation set identified by the random variable</td>
</tr>
<tr valign="top">
<td>[[image:DotPoint.JPG|10px|link=]]</td>
<td>'''[[Session_Rule_List_with_Parameters#Message_Popup_Rule|Message Popup Rule]]''' to open a message window on the screen</td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<br>
<table cellpadding=4 bgcolor=#ffffff>
<table width=1000 cellpadding=2 bgcolor=#ffffff>
<tr valign="top">
<tr valign="top">
<td>[[file:screenshot.PNG|link=]]</td>
<td width=60 rowspan=2>[[image:screenshot.PNG|link=]]</td>
<td width="640"><span style="font-size: 17px;">'''Session Editor Screenshot:'''</span><br>
<td><span style="font-size: 17px;">'''Session Editor Screenshot:'''</span></td>
----</td>
</tr>
</tr>
</table>
<tr valign="top">
<table>
<!-- <td>&#160;</td> -->
<tr>
<td>[[image:AppRandomStop1.jpg|link=]]</td>
<td>[[file:AppRandomStop1.jpg|link=]]</td>
</tr>
</tr>
</table>
</table>
<br>
<br>
<table cellpadding=4 bgcolor=#ffffff>
<table width=1000 cellpadding=2 bgcolor=#ffffff>
<tr valign="top">
<tr valign="top">
<td>[[file:explanation.PNG|link=]]</td>
<td width=60 rowspan=2>[[image:explanation.PNG|link=]]</td>
<td width="640"><span style="font-size: 17px;">'''Description:'''</span><br>
<td><span style="font-size: 17px;">'''Description:'''</span></td>
----</td>
</tr>
<tr valign="top">
<!-- <td>&#160;</td> -->
<td>'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;1&#160;</span>''': Trigger Check''' The event is triggered when the consist passes over a track trigger. This executes the following rules:-
:'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;2&#160;</span>''': Variable Check''' The value stored in the variable '''stopID''' is tested "=1". Lines 3 and 4 are executed only if '''stopID''' is '''equal to''' "1"
::'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;3&#160;</span>''': Navigation Set Hide/Show''' Displays a navigation point showing the stopping location
::'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;4&#160;</span>''': Message Popup''' Displays a message window showing that a stop has to be made at Sandplace
:'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;5&#160;</span>''': Variable Check''' The value stored in the variable '''stopID''' is tested "&lt;&gt;1". Line 6 is executed only if '''stopID''' is '''not equal''' to "1".
::'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;6&#160;</span>''': Message Popup''' Displays a message window showing that no stop has to be made at Sandplace</td>
</tr>
</tr>
</table>
</table>
*'''Line 1: Trigger Check''' The event is triggered when the consist passes over a track trigger.
**'''Line 2: Variable Check''' The value stored in the variable '''stopID''' is tested "=1". Lines 3 and 4 are executed only if '''stopID''' is '''equal to''' "1"
***'''Line 3: Navigation Set Hide/Show''' Displays a navigation point showing the stopping location.
***'''Line 4: Message Popup''' Displays a message window showing that a stop has to be made at Sandplace.
**'''Line 5: Variable Check''' The value stored in the variable '''stopID''' is tested "&lt;&gt;1". Line 6 is executed only if '''stopID''' is '''not equal''' to "1".
***'''Line 6: Message Popup''' Displays a message window showing that no stop has to be made at Sandplace.
<br>
<br>
<table> <!-- BEGIN Nav Buttons Table -->
<table width=1000> <!-- BEGIN Nav Buttons Table NO SKIPS -->
<tr valign="top">
<tr valign="top">
<td width=729><span id="stepEx2"></span>&nbsp;</td>
<td width=629><span id="stepEx2"></span>
<td width=46>[[file:BackToTop.png|link=#top|alt=Top|Top]]</td>
='''Example 2: Event Counter and Message Selection'''=
<td width=75>[[file:NextUp.png|link=#stepEx1|alt=Next Up|Top]]</td>
</td>
<td width=75>[[file:NextDown.png|link=#stepEx3|alt=Next Down|Next Down]]</td>
<td width=50>&#160;</td> <!-- Skip Down -->
<td width=75>[[file:BackToBottom.png|link=#bottom|alt=Bottom|Bottom]]</td>
<td width=50>&#160;</td> <!-- Skip Up -->
<td width=46>[[image:BackToTop.png|link=#top|alt=Top|Top]]</td>
<td width=75>[[image:NextUp.png|link=#stepEx1|alt=Next Up|Top]]</td>
<td width=75>[[image:NextDown.png|link=#stepEx3|alt=Next Down|Next Down]]</td>
<td width=75>[[image:BackToBottom.png|link=#bottom|alt=Bottom|Bottom]]</td>
</tr>
</tr>
</table> <!-- END Nav Buttons Table -->
</table> <!-- END Nav Buttons Table -->
='''Example 2: Event Counter and Message Selection'''=


<table cellpadding=4 bgcolor=#ffffff>
<table width=1000 cellpadding=2 bgcolor=#ffffff>
<tr valign="top">
<tr valign="top">
<td width="58">[[file:magnifier.png|link=]]</td>
<td width=60 rowspan=4>[[image:magnifier.png|link=]]</td>
<td width="640"><span style="font-size: 17px;">'''The Scenario:'''</span><br>
<td><span style="font-weight: 700; font-size: 17px;">The Scenario:</span></td>
----</td>
</tr>
</tr>
</table>
<table width=1000>
<tr valign="top">
<tr valign="top">
<!-- <td>&#160;</td> -->
<td>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.</td>
<td>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.</td>
</tr>
</tr>
</table>
</table>
<br>
<br>
<table cellpadding=4 bgcolor=#ffffff>
<table width=1000 cellpadding=2 bgcolor=#ffffff>
<tr valign="top">
<td width=60 rowspan=4>[[image:conditions.PNG|link=]]</td>
<td colspan=2><span style="font-size: 17px;">'''Preconditions:'''</span></td>
</tr>
<tr valign="top">
<!-- <td>&#160;</td> -->
<td>
<table>
<tr valign="top">
<td width=10>[[image:DotPoint.JPG|10px|link=]]</td>
<td>A variable, '''SetSPAD''' (value "0" or "1"), is used to indicate whether a SPAD event is to be counted and responded to or not. This is set to "0" or "1" by track triggers</td>
</tr>
<tr valign="top">
<tr valign="top">
<td width="58">[[file:conditions.PNG|link=]]</td>
<td>[[image:DotPoint.JPG|10px|link=]]</td>
<td width="640"><span style="font-size: 17px;">'''Preconditions:'''</span><br>
<td>A variable, '''SPADCounter''', is used to count the SPAD events and is initially set at 0</td>
----</td>
</tr>
</table>
</td>
</tr>
</tr>
</table>
</table>
*A variable, '''SetSPAD''' (value "0" or "1"), is used to indicate whether a SPAD event is to be counted and responded to or not. This is set to "0" or "1" by track triggers.
*A variable, '''SPADCounter''', is used to count the SPAD events and is initially set at 0.
<br>
<br>
<table cellpadding=4 bgcolor=#ffffff>
<table width=1000 cellpadding=2 bgcolor=#ffffff>
<tr valign="top">
<tr valign="top">
<td width="58">[[file:RulesWiki.PNG|link=]]</td>
<td width=60 rowspan=2>[[image:RulesWiki.PNG|link=]]</td>
<td width="640"><span style="font-size: 17px;">'''Rules Used:'''</span><br>
<td><span style="font-size: 17px;">'''Rules Used:'''</span></td>
----</td>
</tr>
<tr valign="top">
<!-- <td>&#160;</td> -->
<td>
<table>
<tr valign="top">
<td width=10>[[image:DotPoint.JPG|10px|link=]]</td>
<td>'''[[Session_Rule_List_with_Parameters#Signal_Passed_At_Danger_Check_Rule|Signal Passed At Danger Check Rule]]''' set to trigger on every SPAD event</td>
</tr>
<tr valign="top">
<td>[[image:DotPoint.JPG|10px|link=]]</td>
<td>'''[[Session_Rule_List_with_Parameters#Variable_Check_Rule|Variable Check Rule]]''' to check the value held in a session variable</td>
</tr>
<tr valign="top">
<td>[[image:DotPoint.JPG|10px|link=]]</td>
<td>'''[[Session_Rule_List_with_Parameters#Driver_Schedule_Rule|Driver Schedule Rule]]''' used to immediately stop the train</td>
</tr>
</tr>
</table>
</table>
*'''[[Session_Rule_List_with_Parameters#Signal_Passed_At_Danger_Check_Rule|Signal Passed At Danger Check Rule]]''' set to trigger on every SPAD event.
*'''[[Session_Rule_List_with_Parameters#Variable_Check_Rule|Variable Check Rule]]''' to check the value held in a session variable.
*'''[[Session_Rule_List_with_Parameters#Driver_Schedule_Rule|Driver Schedule Rule]]''' used to immediately stop the train.
<table>
<table>
<tr>
<tr>
<td>[[file:DriverSchedule.jpg|link=]]</td>
<td>[[image:DriverSchedule.jpg|link=]]</td>
</tr>
</tr>
<tr>
<tr>
Line 183: Line 271:
</tr>
</tr>
</table>
</table>
*'''[[Session_Rule_List_with_Parameters#Simultaneous_List_Rule|Simultaneous List Rule]]''' to force all rules to run simultaneously for speed.
<table>
*'''[[Session_Rule_List_with_Parameters#Variable_Modify_Rule|Variable Modify Rule]]''' to alter the value held in a session variable.
<tr valign="top">
*'''[[Session_Rule_List_with_Parameters#Variable_Show_Rule|Variable Show Rule]]''' adds a session variable to the Heads Up Display.
<td>[[image:DotPoint.JPG|10px|link=]]</td>
*'''[[Session_Rule_List_with_Parameters#Message_Popup_Rule|Message Popup Rule]]''' to open a message window on the screen.
<td>'''[[Session_Rule_List_with_Parameters#Simultaneous_List_Rule|Simultaneous List Rule]]''' to force all rules to run simultaneously for speed</td>
<br>
</tr>
<table cellpadding=4 bgcolor=#ffffff>
<tr valign="top">
<td>[[image:DotPoint.JPG|10px|link=]]</td>
<td>'''[[Session_Rule_List_with_Parameters#Variable_Modify_Rule|Variable Modify Rule]]''' to alter the value held in a session variable</td>
</tr>
<tr valign="top">
<td>[[image:DotPoint.JPG|10px|link=]]</td>
<td>'''[[Session_Rule_List_with_Parameters#Variable_Show_Rule|Variable Show Rule]]''' adds a session variable to the Heads Up Display</td>
</tr>
<tr valign="top">
<tr valign="top">
<td width="58">[[file:screenshot.PNG|link=]]</td>
<td>[[image:DotPoint.JPG|10px|link=]]</td>
<td width="640"><span style="font-size: 17px;">'''Session Editor Screenshot:'''</span><br>
<td>'''[[Session_Rule_List_with_Parameters#Message_Popup_Rule|Message Popup Rule]]''' to open a message window on the screen</td>
----</td>
</tr>
</tr>
</table>
</table>
<table>
</td>
<tr>
<td>[[file:VariableSPADWarnings.jpg|link=]]</td>
</tr>
</tr>
</table>
</table>
<br>
<br>
<table cellpadding=4 bgcolor=#ffffff>
<table width=1000 cellpadding=2 bgcolor=#ffffff>
<tr valign="top">
<td width=60 rowspan=2>[[image:screenshot.PNG|link=]]</td>
<td><span style="font-size: 17px;">'''Session Editor Screenshot:'''</span></td>
</tr>
<tr valign="top">
<tr valign="top">
<td width="58">[[file:explanation.PNG|link=]]</td>
<!-- <td>&#160;</td> -->
<td width="640"><span style="font-size: 17px;">'''Description:'''</span><br>
<td>[[image:VariableSPADWarnings.jpg|link=]]</td>
----</td>
</tr>
</tr>
</table>
</table>
<table width=1000>
<br>
<table width=1000 cellpadding=2 bgcolor=#ffffff>
<tr valign="top">
<td width=60 rowspan=3>[[image:explanation.PNG|link=]]</td>
<td><span style="font-size: 17px;">'''Description:'''</span></td>
</tr>
<tr valign="top">
<!-- <td>&#160;</td> -->
<td>'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;1&#160;</span>''': 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:-
:'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;2&#160;</span>''': Variable Check''' The value stored in the variable '''SetSPAD''' is tested "=1". If true then the following lines are executed. This executes the following lines:-
::'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;3&#160;</span>''': Driver Schedule''' The current schedule (if any) for the user controlled driver is replaced with a '''Halt Train''' command to bring the train to an immediate stop
::'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;4&#160;</span>''': Variable Modify''' The value stored in the variable '''SPADCounter''' is increased by 1
::'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;5&#160;</span>''': Simultaneous List''' This forces all the '''Variable Check Rules''' to be run simultaneously. This is not strictly necessary but without it all the '''Variable Check Rules''' will be tested, one after the other, when only one (or none) of them will be executed. This will (marginally) speed up the processing. This will execute the following lines:-
:::'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;6&#160;</span>''': Variable Check''' The value stored in the variable '''SPADCounter''' is tested "=1". If true then the first SPAD event has occurred and the following lines are executed:-
::::'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;7&#160;</span>''': Variable Show''' The value stored in the variable '''SPADCounter''' is added to the '''Custom HUD'''. Each time the value changes it will be updated in the HUD
::::'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;8&#160;</span>''': Message Popup''' The first warning message is shown on the screen
:::'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;9&#160;</span>''': Variable Check''' The value stored in the variable '''SPADCounter''' is tested "=2". If true then the second SPAD event has occurred and the following line is executed:-
::::'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;10&#160;</span>''': Message Popup''' The second warning message is shown on the screen</td>
</tr>
<tr valign="top">
<tr valign="top">
<td>
<!-- <td>&#160;</td> -->
*'''Line 1: Signal Passed At Danger''' The event is triggered every time a consist passes a signal (or stop sign) set at STOP.
<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.
**'''Line 2: Variable Check''' The value stored in the variable '''SetSPAD''' is tested "=1". If true then the following lines are executed.
***'''Line 3: Driver Schedule:''' The current schedule (if any) for the user controlled driver is replaced with a '''Halt Train''' command to bring the train to an immediate stop.
***'''Line 4: Variable Modify''' The value stored in the variable '''SPADCounter''' is increased by 1.
***'''Line 5: Simultaneous List''' This forces all the '''Variable Check Rules''' to be run simultaneously. This is not strictly necessary but without it all the '''Variable Check Rules''' will be tested, one after the other, when only one (or none) of them will be executed. This will (marginally) speed up the processing.
****'''Line 6: Variable Check''' The value stored in the variable '''SPADCounter''' is tested "=1". If true then the first SPAD event has occurred and the following lines are executed.
*****'''Line 7: Variable Show''' The value stored in the variable '''SPADCounter''' is added to the '''Custom HUD'''. Each time the value changes it will be updated in the HUD.
*****'''Line 8: Message Popup''' The first warning message is shown on the screen.
****'''Line 9: Variable Check''' The value stored in the variable '''SPADCounter''' is tested "=2". If true then the second SPAD event has occurred and the following line is executed.
*****'''Line 10: Message Popup''' The second warning message is shown on the screen.
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>
</td>
</tr>
</tr>
</table>
</table>
<br>
<br>
<table> <!-- BEGIN Nav Buttons Table -->
<table width=1000> <!-- BEGIN Nav Buttons Table NO SKIPS -->
<tr valign="top">
<tr valign="top">
<td width=729><span id="stepEx3"></span>&nbsp;</td>
<td width=629><span id="stepEx3"></span>
<td width=46>[[file:BackToTop.png|link=#top|alt=Top|Top]]</td>
='''Example 3: Counting Consist Checks'''=
<td width=75>[[file:NextUp.png|link=#stepEx2|alt=Next Up|Top]]</td>
</td>
<td width=75>[[file:NextDown.png|link=#stepEx4|alt=Next Down|Next Down]]</td>
<td width=50>&#160;</td> <!-- Skip Down -->
<td width=75>[[file:BackToBottom.png|link=#bottom|alt=Bottom|Bottom]]</td>
<td width=50>&#160;</td> <!-- Skip Up -->
<td width=46>[[image:BackToTop.png|link=#top|alt=Top|Top]]</td>
<td width=75>[[image:NextUp.png|link=#stepEx2|alt=Next Up|Top]]</td>
<td width=75>[[image:NextDown.png|link=#stepEx4|alt=Next Down|Next Down]]</td>
<td width=75>[[image:BackToBottom.png|link=#bottom|alt=Bottom|Bottom]]</td>
</tr>
</tr>
</table> <!-- END Nav Buttons Table -->
</table> <!-- END Nav Buttons Table -->
='''Example 3: Counting Consist Checks'''=


<table cellpadding=4 bgcolor=#ffffff>
<table width=1000 cellpadding=2 bgcolor=#ffffff>
<tr valign="top">
<tr valign="top">
<td width="58">[[file:magnifier.png|link=]]</td>
<td width=60 rowspan=4>[[image:magnifier.png|link=]]</td>
<td width="640"><span style="font-size: 17px;">'''The Scenario:'''</span><br>
<td><span style="font-weight: 700; font-size: 17px;">The Scenario:</span></td>
----</td>
</tr>
</tr>
</table>
<table width=1000>
<tr valign="top">
<tr valign="top">
<td>The '''Consist Check Rule''' cannot be set to trigger only once but sometimes you want it triggered only once on (for example) the 1st, 2nd, 3rd, 4th, etc, 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.</td>
<!-- <td>&#160;</td> -->
<td>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.</td>
</tr>
</tr>
</table>
</table>
<br>
<br>
<table cellpadding=4 bgcolor=#ffffff>
<table width=1000 cellpadding=2 bgcolor=#ffffff>
<tr valign="top">
<tr valign="top">
<td width="58">[[file:conditions.PNG|link=]]</td>
<td width=60 rowspan=4>[[image:conditions.PNG|link=]]</td>
<td width="640"><span style="font-size: 17px;">'''Preconditions:'''</span><br>
<td colspan=2><span style="font-size: 17px;">'''Preconditions:'''</span></td>
----</td>
</tr>
<tr valign="top">
<!-- <td>&#160;</td> -->
<td>
<table>
<tr valign="top">
<td width=10>[[image:DotPoint.JPG|10px|link=]]</td>
<td>A variable, '''ConsistCount''', is initially set to "0"</td>
</tr>
</table>
</td>
</tr>
</tr>
</table>
</table>
*A variable, '''ConsistCount''' is initially set to "0".
<br>
<br>
<table cellpadding=4 bgcolor=#ffffff>
<table width=1000 cellpadding=2 bgcolor=#ffffff>
<tr valign="top">
<td width=60 rowspan=2>[[image:RulesWiki.PNG|link=]]</td>
<td><span style="font-size: 17px;">'''Rules Used:'''</span></td>
</tr>
<tr valign="top">
<!-- <td>&#160;</td> -->
<td>
<table>
<tr valign="top">
<td width=10>[[image:DotPoint.JPG|10px|link=]]</td>
<td>'''[[Session_Rule_List_with_Parameters#Consist_Check_Rule|Consist Check Rule]]''' set to trigger when a specific consist has been formed</td>
</tr>
<tr valign="top">
<td>[[image:DotPoint.JPG|10px|link=]]</td>
<td>'''[[Session_Rule_List_with_Parameters#Variable_Modify_Rule|Variable Modify Rule]]''' to set and increase the value held in a session variable</td>
</tr>
<tr valign="top">
<tr valign="top">
<td width="58">[[file:RulesWiki.PNG|link=]]</td>
<td>[[image:DotPoint.JPG|10px|link=]]</td>
<td width="640"><span style="font-size: 17px;">'''Rules Used:'''</span><br>
<td>'''[[Session_Rule_List_with_Parameters#Variable_Check_Rule|Variable Check Rule]]''' to check the value held in a session variable</td>
----</td>
</tr>
<tr valign="top">
<td>[[image:DotPoint.JPG|10px|link=]]</td>
<td>'''[[Session_Rule_List_with_Parameters#Message_Popup_Rule|Message Popup Rule]]''' to place a message on the screen</td>
</tr>
</table>
</td>
</tr>
</tr>
</table>
</table>
*'''[[Session_Rule_List_with_Parameters#Consist_Check_Rule|Consist Check Rule]]''' set to trigger when a specific consist has been formed.
*'''[[Session_Rule_List_with_Parameters#Variable_Modify_Rule|Variable Modify Rule]]''' to set and increase the value held in a session variable.
*'''[[Session_Rule_List_with_Parameters#Variable_Check_Rule|Variable Check Rule]]''' to check the value held in a session variable.
*'''[[Session_Rule_List_with_Parameters#Message_Popup_Rule|Message Popup Rule]]''' to place a message on the screen.
<br>
<br>
<table cellpadding=4 bgcolor=#ffffff>
<table width=1000 cellpadding=2 bgcolor=#ffffff>
<tr valign="top">
<tr valign="top">
<td width="58">[[file:screenshot.PNG|link=]]</td>
<td width=60 rowspan=2>[[image:screenshot.PNG|link=]]</td>
<td width="640"><span style="font-size: 17px;">'''Session Editor Screenshot:'''</span><br>
<td><span style="font-size: 17px;">'''Session Editor Screenshot:'''</span></td>
----</td>
</tr>
</tr>
</table>
<tr valign="top">
<table>
<!-- <td>&#160;</td> -->
<tr>
<td>[[image:VariableConsistCounter.JPG|link=]]</td>
<td>[[file:VariableConsistCounter.JPG|link=]]</td>
</tr>
</tr>
</table>
</table>
<br>
<br>
<table cellpadding=4 bgcolor=#ffffff>
<table width=1000 cellpadding=2 bgcolor=#ffffff>
<tr valign="top">
<tr valign="top">
<td width="58">[[file:explanation.PNG|link=]]</td>
<td width=60 rowspan=3>[[image:explanation.PNG|link=]]</td>
<td width="640"><span style="font-size: 17px;">'''Description:'''</span><br>
<td><span style="font-size: 17px;">'''Description:'''</span></td>
----</td>
</tr>
<tr valign="top">
<!-- <td>&#160;</td> -->
<td>'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;1&#160;</span>''': Consist Check Rule''' Triggered when the specified consist has been found. This executes the following lines:-
:'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;2&#160;</span>''': Variable Modify Rule''' Adds 1 to the variable '''ConsistCounter'''
:'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;3&#160;</span>''': Variable Check''' Compares the value stored in '''ConsistCounter''' to a set value (in this case 2). If it matches then the next line is executed:-
::'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;4&#160;</span>''': Places a message on the screen</td>
</tr>
</tr>
</table>
</table>
*'''Line 1: Consist Check Rule''' Triggered when the specified consist has been found.
**'''Line 2: Variable Modify Rule''' Adds 1 to the variable '''ConsistCounter'''.
**'''Line 3: Variable Check''' Compares the value stored in '''ConsistCounter''' to a set value (in this case 2). If it matches then the next lines are executed.
***'''Line 4: Message Popup''' Places a message on the screen.
<br>
<br>
<table> <!-- BEGIN Nav Buttons Table -->
<table width=1000> <!-- BEGIN Nav Buttons Table NO SKIPS -->
<tr valign="top">
<tr valign="top">
<td width=729><span id="stepEx4"></span>&nbsp;</td>
<td width=629><span id="stepEx4"></span>
<td width=46>[[file:BackToTop.png|link=#top|alt=Top|Top]]</td>
='''Example 4: Train Status'''=
<td width=75>[[file:NextUp.png|link=#stepEx3|alt=Next Up|Top]]</td>
</td>
<td width=75>[[file:NextDown.png|link=#stepRules|alt=Next Down|Next Down]]</td>
<td width=50>&#160;</td> <!-- Skip Down -->
<td width=75>[[file:BackToBottom.png|link=#bottom|alt=Bottom|Bottom]]</td>
<td width=50>&#160;</td> <!-- Skip Up -->
<td width=46>[[image:BackToTop.png|link=#top|alt=Top|Top]]</td>
<td width=75>[[image:NextUp.png|link=#stepEx3|alt=Next Up|Top]]</td>
<td width=75>[[image:NextDown.png|link=#stepRules|alt=Next Down|Next Down]]</td>
<td width=75>[[image:BackToBottom.png|link=#bottom|alt=Bottom|Bottom]]</td>
</tr>
</tr>
</table> <!-- END Nav Buttons Table -->
</table> <!-- END Nav Buttons Table -->
='''Example 4: Train Status'''=


<table cellpadding=4 bgcolor=#ffffff>
<table width=1000 cellpadding=2 bgcolor=#ffffff>
<tr valign="top">
<td width=60 rowspan=4>[[image:magnifier.png|link=]]</td>
<td><span style="font-weight: 700; font-size: 17px;">The Scenario:</span></td>
</tr>
<tr valign="top">
<tr valign="top">
<td width="58">[[file:magnifier.png|link=]]</td>
<!-- <td>&#160;</td> -->
<td width="640"><span style="font-size: 17px;">'''The Scenario:'''</span><br>
<td>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</td>
----</td>
</tr>
</tr>
</table>
</table>
Train 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.
<br>
<br><br>
<table width=1000 cellpadding=2 bgcolor=#ffffff>
<table cellpadding=4 bgcolor=#ffffff>
<tr valign="top">
<td width=60 rowspan=4>[[image:conditions.PNG|link=]]</td>
<td colspan=2><span style="font-size: 17px;">'''Preconditions:'''</span></td>
</tr>
<tr valign="top">
<tr valign="top">
<td width="58">[[file:conditions.PNG|link=]]</td>
<!-- <td>&#160;</td> -->
<td width="640"><span style="font-size: 17px;">'''Preconditions:'''</span><br>
<td>
----</td>
<table>
<tr valign="top">
<td width=10>[[image:DotPoint.JPG|10px|link=]]</td>
<td>A variable, '''T188Status''' is initially set to "1" signifying that the train is empty. This will be modified to "2" after it has been loaded</td>
</tr>
</table>
</td>
</tr>
</tr>
</table>
</table>
*A variable, '''T188Status''' is initially set to "1" signifying that the train is empty. This will be modified to "2" after it has been loaded.
<br>
<br>
<table cellpadding=4 bgcolor=#ffffff>
<table width=1000 cellpadding=2 bgcolor=#ffffff>
<tr valign="top">
<td width=60 rowspan=2>[[image:RulesWiki.PNG|link=]]</td>
<td><span style="font-size: 17px;">'''Rules Used:'''</span></td>
</tr>
<tr valign="top">
<!-- <td>&#160;</td> -->
<td>
<table>
<tr valign="top">
<td width=10>[[image:DotPoint.JPG|10px|link=]]</td>
<td>'''[[Session_Rule_List_with_Parameters#Trigger_Check_Rule|Trigger Check Rule]]''' to trigger the event when the consist reaches the trigger</td>
</tr>
<tr valign="top">
<td>[[image:DotPoint.JPG|10px|link=]]</td>
<td>'''[[Session_Rule_List_with_Parameters#Variable_Check_Rule|Variable Check Rule]]''' to check the value held in a session variable</td>
</tr>
<tr valign="top">
<tr valign="top">
<td width="58">[[file:RulesWiki.PNG|link=]]</td>
<td>[[image:DotPoint.JPG|10px|link=]]</td>
<td width="640"><span style="font-size: 17px;">'''Rules Used:'''</span><br>
<td>'''[[Session_Rule_List_with_Parameters#Message_Popup_Rule|Message Popup Rule]]''' to place a message on the screen</td>
----</td>
</tr>
</table>
</td>
</tr>
</tr>
</table>
</table>
*'''[[Session_Rule_List_with_Parameters#Trigger_Check_Rule|Trigger Check Rule]]''' to trigger the event when the consist reaches the trigger
*'''[[Session_Rule_List_with_Parameters#Variable_Check_Rule|Variable Check Rule]]''' to check the value held in a session variable.
*'''[[Session_Rule_List_with_Parameters#Message_Popup_Rule|Message Popup Rule]]''' to place a message on the screen.
<br>
<br>
<table cellpadding=4 bgcolor=#ffffff>
<table width=1000 cellpadding=2 bgcolor=#ffffff>
<tr valign="top">
<tr valign="top">
<td width="58">[[file:screenshot.PNG|link=]]</td>
<td width=60 rowspan=2>[[image:screenshot.PNG|link=]]</td>
<td width="640"><span style="font-size: 17px;">'''Session Editor Screenshot:'''</span><br>
<td><span style="font-size: 17px;">'''Session Editor Screenshot:'''</span></td>
----</td>
</tr>
</tr>
</table>
<tr valign="top">
<table>
<!-- <td>&#160;</td> -->
<tr>
<td>[[image:VariableTrainTrigger.JPG|link=]]</td>
<td>[[file:VariableTrainTrigger.JPG|link=]]</td>
</tr>
</tr>
</table>
</table>
<br>
<br>
<table cellpadding=4 bgcolor=#ffffff>
<table width=1000 cellpadding=2 bgcolor=#ffffff>
<tr valign="top">
<tr valign="top">
<td width="58">[[file:explanation.PNG|link=]]</td>
<td width=60 rowspan=3>[[image:explanation.PNG|link=]]</td>
<td width="640"><span style="font-size: 17px;">'''Description:'''</span><br>
<td><span style="font-size: 17px;">'''Description:'''</span></td>
----</td>
</tr>
<tr valign="top">
<!-- <td>&#160;</td> -->
<td>'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;1&#160;</span>''': Trigger Check Rule''' Triggered by the train. This is '''NOT''' set to trigger once only. When triggered it will execute the following lines:-
:'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;2&#160;</span>''': Variable Check''' Compares the value stored in '''T188Status''' to 1, indicating "empty". If it matches then the next line is executed:-
::'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;3&#160;</span>''': Message Popup''' Places a message on the screen
::'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;4&#160;</span>''': Variable Check''' Compares the value stored in '''T188Status''' to 2, indicating "loaded". If it matches then the next line is executed:-
:::'''Line''' <span style="font-weight: 700; font-size: 15px; color: white; background-color: black;">&#160;5&#160;</span>''': Message Popup''' Places a message on the screen</td>
</tr>
</tr>
</table>
</table>
*'''Line 1: Trigger Check Rule''' Triggered by the train. This is NOT set to trigger once only.
**'''Line 2: Variable Check''' Compares the value stored in '''T188Status''' to 1, indicating "empty". If it matches then the next line is executed.
***'''Line 3: Message Popup''' Places a message on the screen.
**'''Line 4: Variable Check''' Compares the value stored in '''T188Status''' to 2, indicating "loaded". If it matches then the next line is executed.
***'''Line 5: Message Popup''' Places a message on the screen.
<br>
<br>
<table> <!-- BEGIN Nav Buttons Table -->
<table width=1000> <!-- BEGIN Nav Buttons Table NO SKIPS -->
<tr valign="top">
<tr valign="top">
<td width=729><span id="stepRules"></span>&nbsp;</td>
<td width=629><span id="stepRules"></span>
<td width=46>[[file:BackToTop.png|link=#top|alt=Top|Top]]</td>
='''Variable Rules and Commands'''=
<td width=75>[[file:NextUp.png|link=#stepEx4|alt=Next Up|Top]]</td>
</td>
<td width=50>&#160;</td> <!-- Skip Down -->
<td width=50>&#160;</td> <!-- Skip Up -->
<td width=46>[[image:BackToTop.png|link=#top|alt=Top|Top]]</td>
<td width=75>[[image:NextUp.png|link=#stepEx4|alt=Next Up|Top]]</td>
<td width=75>&nbsp;</td>
<td width=75>&nbsp;</td>
<td width=75>[[file:BackToBottom.png|link=#bottom|alt=Bottom|Bottom]]</td>
<td width=75>[[image:BackToBottom.png|link=#bottom|alt=Bottom|Bottom]]</td>
</tr>
</tr>
</table> <!-- END Nav Buttons Table -->
</table> <!-- END Nav Buttons Table -->
='''Variable Rules and Commands'''=


<table cellpadding=4 bgcolor=#ffffff>
<table width=1000 cellpadding=2 bgcolor=#ffffff>
<tr valign="top">
<td width=50>[[image:RulesWiki.PNG|link=]]</td>
<td>These are the '''Session Rules''' that can access, create and/or modify Session variables
<table>
<tr valign="top">
<td width=10>[[image:DotPoint.JPG|10px|link=]]</td>
<td>'''[[Session_Rule_List_with_Parameters#Randomize_Rule|Randomize Rule]]''' - creates a different set of random numbers every time a session is run</td>
</tr>
<tr valign="top">
<td>[[image:DotPoint.JPG|10px|link=]]</td>
<td>'''[[Session_Rule_List_with_Parameters#Variable Check Rule|Variable Check Rule]]''' - executes child rules according to the value of a specified variable</td>
</tr>
<tr valign="top">
<td>[[image:DotPoint.JPG|10px|link=]]</td>
<td>'''[[Session_Rule_List_with_Parameters#Variable Modify Rule|Variable Modify Rule]]''' - changes the value of a specified variable and creates new variables by setting their initial values</td>
</tr>
<tr valign="top">
<tr valign="top">
<td width="50">[[file:RulesWiki.PNG|link=]]</td>
<td>[[image:DotPoint.JPG|10px|link=]]</td>
<td width="640">
<td>'''[[Session_Rule_List_with_Parameters#Variable Modify Continuous Rule|Variable Modify Continuous Rule]]''' - continuously changes the value of a specified variable</td>
These are the '''Session Rules''' that can access, create and/or modify Session variables</td>
</tr>
<tr valign="top">
<td>[[image:DotPoint.JPG|10px|link=]]</td>
<td>'''[[Session_Rule_List_with_Parameters#Variable Random Rule|Variable Random Rule]]''' - assigns a random value to a variable</td>
</tr>
<tr valign="top">
<td>[[image:DotPoint.JPG|10px|link=]]</td>
<td>'''[[Session_Rule_List_with_Parameters#Variable Show Rule|Variable Show Rule]]''' - adds or removes a specified variable and a descriptive label to the custom HUD</td>
</tr>
</table>
</td>
</tr>
</tr>
</table>
</table>
*'''[[Session_Rule_List_with_Parameters#Randomize_Rule|Randomize Rule]]''' - creates a different set of random numbers every time a session is run.
*'''[[Session_Rule_List_with_Parameters#Variable Check Rule|Variable Check Rule]]''' - executes child rules according to the value of a specified variable.
*'''[[Session_Rule_List_with_Parameters#Variable Modify Rule|Variable Modify Rule]]''' - changes the value of a specified variable and creates new variables by setting their initial values.
*'''[[Session_Rule_List_with_Parameters#Variable Modify Continuous Rule|Variable Modify Continuous Rule]]''' - continuously changes the value of a specified variable.
*'''[[Session_Rule_List_with_Parameters#Variable Random Rule|Variable Random Rule]]''' - assigns a random value to a variable.
*'''[[Session_Rule_List_with_Parameters#Variable Show Rule|Variable Show Rule]]''' - adds or removes a specified variable and a descriptive label to the custom HUD.
<br>
<br>
<table cellpadding=4 bgcolor=#ffffff>
<table width=1000 cellpadding=2 bgcolor=#ffffff>
<tr valign="top">
<tr valign="top">
<td width="50">[[file:CommandsWiki.png|link=]]</td>
<td width=50>[[image:CommandsWiki.png|link=]]</td>
<td width="640">
<td>These are the '''Driver Commands''' that can access Session variables. The [[image:WikiLink.PNG|link=]] '''[[Session Rule List with Parameters#InputTable Rule|InputTable Rule]]''' must be added to the Session and configured with the names of the variables before these Driver Commands can be used.
These are the '''Driver Commands''' that can access Session variables. The [[file:WikiLink.PNG|link=]] '''[[Session Rule List with Parameters#InputTable Rule|InputTable Rule]]''' must be added to the Session and configured with the names of the variables before these Driver Commands can be used.</td>
<table>
<tr valign="top">
<td width=10>[[image:DotPoint.JPG|10px|link=]]</td>
<td>'''[[Driver_Commands_List#Skip if Session-Variable|Skip if Session Variable]]''' - conditionally jumps to the named command label in the Driver Command Bar if a selected session variable meets a set condition</td>
</tr>
<tr valign="top">
<td>[[image:DotPoint.JPG|10px|link=]]</td>
<td>'''[[Driver_Commands_List#Wait Until S-Variable V3|Wait Until S-Variable V3]]''' - AI driver waits for the specified variable condition to occur</td>
</tr>
</tr>
</table>
</table>
*'''[[Driver_Commands_List#Skip if Session-Variable|Skip if Session Variable]]''' - conditionally jumps to the named command label in the Driver Command Bar if a selected session variable meets a set condition.
</td>
*'''[[Driver_Commands_List#Wait Until S-Variable V3|Wait Until S-Variable V3]]''' - AI driver waits for the specified variable condition to occur.
</tr>
<table> <!-- BEGIN Nav Buttons Table -->
</table>
<br>
 
<table width=1000> <!-- BEGIN Nav Buttons Table NO SKIPS -->
<tr valign="top">
<tr valign="top">
<td width=729><span id="bottom"></span>&nbsp;</td>
<td width=629><span id="bottom"></span>&#160;</td>
<td width=46>[[file:BackToTop.png|link=#top|alt=Top|Top]]</td>
<td width=50>&#160;</td> <!-- Skip Down -->
<td width=75>[[file:NextUp.png|link=#stepRules|alt=Next Up|Top]]</td>
<td width=50>&#160;</td> <!-- Skip Up -->
<td width=46>[[image:BackToTop.png|link=#top|alt=Top|Top]]</td>
<td width=75>[[image:NextUp.png|link=#stepRules|alt=Next Up|Top]]</td>
<td width=75>&nbsp;</td>
<td width=75>&nbsp;</td>
<td width=75>&nbsp;</td>
<td width=75>&nbsp;</td>
</tr>
</tr>
</table> <!-- END Nav Buttons Table -->
</table> <!-- END Nav Buttons Table -->
----
----
----
----
='''Trainz Wiki'''=
='''Trainz Wiki'''=
<table cellpadding=4 bgcolor=#ffffff>
<table cellpadding=2 bgcolor=#ffffff>
<tr valign="top">
<tr valign="top">
<td>[[file:TrainzWiki.png|link=]]</td>
<td>[[image:TrainzWiki.png|link=]]</td>
<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>

Revision as of 00:22, 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.

Variables store integer values in Sessions that can be used to:-
Test for certain events (e.g. if something has occurred a set number of times)
Make decisions according to the value held by a variable
Act as counters or score keepers
Variables can be used for basic arithmetic by having set values added or subtracted
Variables can have random values assigned to them


The scenarios shown below give examples of how variables can be used to control the operation of a session.

Example 1: Random Passenger Stop

    Top   Next Down Bottom
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.
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 If a stop is required then a predefined Navigation Point is shown to indicate the stopping place
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 The same logic is repeated for the other two stations with stopID values of "2" and "3"


Preconditions:
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 The Randomize Rule is used at the start of the session to create a different sequence of random values each time the session is run
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 The Navigation Display Rule is used to create three Navigation Point Sets, one for each stopping place
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 The Navigation Set Hide/Show Rule is used to initially hide all three navigation sets
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 The 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
Setting the random variable stopID


Rules Used:
In addition to those used in the Preconditions above:-
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Trigger Check Rule to trigger the decision and message event
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Variable Check Rule to check the value held in a session variable
Checking the variable stopID for the first stopping place
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Navigation Set Hide/Show Rule to show the navigation set identified by the random variable
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Message Popup Rule to open a message window on the screen


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:-
Line  2 : Variable Check The value stored in the variable stopID is tested "=1". Lines 3 and 4 are executed only if stopID is equal to "1"
Line  3 : Navigation Set Hide/Show Displays a navigation point showing the stopping location
Line  4 : Message Popup Displays a message window showing that a stop has to be made at Sandplace
Line  5 : Variable Check The value stored in the variable stopID is tested "<>1". Line 6 is executed only if stopID is not equal to "1".
Line  6 : Message Popup Displays a message window showing that no stop has to be made at Sandplace


Example 2: Event Counter and Message Selection

    Top Next Up Next Down Bottom
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:
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 A variable, SetSPAD (value "0" or "1"), is used to indicate whether a SPAD event is to be counted and responded to or not. This is set to "0" or "1" by track triggers
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 A variable, SPADCounter, is used to count the SPAD events and is initially set at 0


Rules Used:
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Signal Passed At Danger Check Rule set to trigger on every SPAD event
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Variable Check Rule to check the value held in a session variable
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Driver Schedule Rule used to immediately stop the train
Using the Driver Schedule Rule to halt the train
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Simultaneous List Rule to force all rules to run simultaneously for speed
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Variable Modify Rule to alter the value held in a session variable
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Variable Show Rule adds a session variable to the Heads Up Display
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Message Popup Rule to open a message window on the screen


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:-
Line  2 : Variable Check The value stored in the variable SetSPAD is tested "=1". If true then the following lines are executed. This executes the following lines:-
Line  3 : Driver Schedule The current schedule (if any) for the user controlled driver is replaced with a Halt Train command to bring the train to an immediate stop
Line  4 : Variable Modify The value stored in the variable SPADCounter is increased by 1
Line  5 : Simultaneous List This forces all the Variable Check Rules to be run simultaneously. This is not strictly necessary but without it all the Variable Check Rules will be tested, one after the other, when only one (or none) of them will be executed. This will (marginally) speed up the processing. This will execute the following lines:-
Line  6 : Variable Check The value stored in the variable SPADCounter is tested "=1". If true then the first SPAD event has occurred and the following lines are executed:-
Line  7 : Variable Show The value stored in the variable SPADCounter is added to the Custom HUD. Each time the value changes it will be updated in the HUD
Line  8 : Message Popup The first warning message is shown on the screen
Line  9 : Variable Check The value stored in the variable SPADCounter is tested "=2". If true then the second SPAD event has occurred and the following line is executed:-
Line  10 : Message Popup The second warning message is shown on the screen
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

    Top Next Up Next Down Bottom
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:
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 A variable, ConsistCount, is initially set to "0"


Rules Used:
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Consist Check Rule set to trigger when a specific consist has been formed
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Variable Modify Rule to set and increase the value held in a session variable
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Variable Check Rule to check the value held in a session variable
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Message Popup Rule to place a message on the screen


Session Editor Screenshot:


Description:
Line  1 : Consist Check Rule Triggered when the specified consist has been found. This executes the following lines:-
Line  2 : Variable Modify Rule Adds 1 to the variable ConsistCounter
Line  3 : Variable Check Compares the value stored in ConsistCounter to a set value (in this case 2). If it matches then the next line is executed:-
Line  4 : Places a message on the screen


Example 4: Train Status

    Top Next Up Next Down Bottom
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:
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 A variable, T188Status is initially set to "1" signifying that the train is empty. This will be modified to "2" after it has been loaded


Rules Used:
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Trigger Check Rule to trigger the event when the consist reaches the trigger
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Variable Check Rule to check the value held in a session variable
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Message Popup Rule to place a message on the screen


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:-
Line  2 : Variable Check Compares the value stored in T188Status to 1, indicating "empty". If it matches then the next line is executed:-
Line  3 : Message Popup Places a message on the screen
Line  4 : Variable Check Compares the value stored in T188Status to 2, indicating "loaded". If it matches then the next line is executed:-
Line  5 : Message Popup Places a message on the screen


Variable Rules and Commands

    Top Next Up   Bottom
These are the Session Rules that can access, create and/or modify Session variables
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Randomize Rule - creates a different set of random numbers every time a session is run
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Variable Check Rule - executes child rules according to the value of a specified variable
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Variable Modify Rule - changes the value of a specified variable and creates new variables by setting their initial values
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Variable Modify Continuous Rule - continuously changes the value of a specified variable
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Variable Random Rule - assigns a random value to a variable
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Variable Show Rule - adds or removes a specified variable and a descriptive label to the custom HUD


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.
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Skip if Session Variable - conditionally jumps to the named command label in the Driver Command Bar if a selected session variable meets a set condition
Error creating thumbnail: /bin/bash: line 1: /usr/bin/convert: No such file or directory Error code: 127 Wait Until S-Variable V3 - AI driver waits for the specified variable condition to occur
      Top Next Up    


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.