How to Use Parent and Child Rules

From TrainzOnline
(Difference between revisions)
Jump to: navigation, search
(Trainz Creation Tutorials:)
Line 1: Line 1:
=='''Parent and Child Rules'''==
+
='''Parent and Child Rules'''=
  
==='''Parent Rules:'''===
+
==Parent Rules==
  
 
*Rules that act as '''Parent Rules''' can have one or more sub-rules or '''Child Rules''' indented under them.
 
*Rules that act as '''Parent Rules''' can have one or more sub-rules or '''Child Rules''' indented under them.
 
*Only certain rules can be Parent Rules. See the Trainz Wiki page '''[[Parent Rule List]]''' for details.
 
*Only certain rules can be Parent Rules. See the Trainz Wiki page '''[[Parent Rule List]]''' for details.
  
==='''Child Rules:'''===
+
==Child Rules==
  
 
*Rules that act as '''Child Rules''' are indented under a Parent Rule.  
 
*Rules that act as '''Child Rules''' are indented under a Parent Rule.  
Line 19: Line 19:
 
*Child Rules are only executed if the Parent Rule returns a ''True'' result from the condition or test it is examining.
 
*Child Rules are only executed if the Parent Rule returns a ''True'' result from the condition or test it is examining.
  
==='''Example:'''===
+
===Example===
 
<table>
 
<table>
 
<tr>
 
<tr>
Line 81: Line 81:
 
</table>
 
</table>
  
==='''Sequence of Events:'''===
+
===Sequence of Events===
  
 
*When the consist identified in the '''Trigger Check Rule''' reaches the set trigger, then the Trigger Event is activated and its child rules are executed.
 
*When the consist identified in the '''Trigger Check Rule''' reaches the set trigger, then the Trigger Event is activated and its child rules are executed.
Line 89: Line 89:
 
****The '''Close Message Popup Rule''' is executed. This closes the Message window created by the '''Message Popup Rule'''. Since it is the last rule under the '''Simultaneous List Rule''' it terminates that rule. Since it is the last rule under the '''Trigger Check Rule''', it also terminates that rule.
 
****The '''Close Message Popup Rule''' is executed. This closes the Message window created by the '''Message Popup Rule'''. Since it is the last rule under the '''Simultaneous List Rule''' it terminates that rule. Since it is the last rule under the '''Trigger Check Rule''', it also terminates that rule.
  
=='''Ordered Lists vs Simultaneous Lists'''==
+
='''Ordered Lists vs Simultaneous Lists'''=
  
 
The majority of sibling Child Rules, rules that are at the same indent level under a Parent Rule, will be executed in order (an '''Ordered List''') or simultaneously (a '''Simultaneous List''').
 
The majority of sibling Child Rules, rules that are at the same indent level under a Parent Rule, will be executed in order (an '''Ordered List''') or simultaneously (a '''Simultaneous List''').
  
==='''Ordered Lists: [[Session_Rule_List_with_Parameters#Ordered_List_Rule|Ordered List Rule]]'''===
+
==Ordered Lists: [[Session_Rule_List_with_Parameters#Ordered_List_Rule|Ordered List Rule]]==
 
----
 
----
 
<table>
 
<table>
Line 121: Line 121:
 
*If possible, place Child Rules that are event dependent at the end of an ordered list.
 
*If possible, place Child Rules that are event dependent at the end of an ordered list.
  
==='''Simultaneous Lists: [[Session_Rule_List_with_Parameters#Simultaneous_List_Rule|Simultaneous List Rule]]'''===
+
==Simultaneous Lists: [[Session_Rule_List_with_Parameters#Simultaneous_List_Rule|Simultaneous List Rule]]==
 
----
 
----
 
<table>
 
<table>
Line 141: Line 141:
 
**any one of the Child Rules has been completed.
 
**any one of the Child Rules has been completed.
  
==''' Other Types of Lists'''==
+
='''Other Types of Lists'''=
  
==='''Progressive Lists: [[Session_Rule_List_with_Parameters#Progressive_List_Rule|Progressive List Rule]]'''===
+
==Progressive Lists: [[Session_Rule_List_with_Parameters#Progressive_List_Rule|Progressive List Rule]]==
  
 
----
 
----
Line 160: Line 160:
 
</table>
 
</table>
  
==='''Random Lists: [[Session_Rule_List_with_Parameters#Random_List_Rule|Random List Rule]]'''===
+
==Random Lists: [[Session_Rule_List_with_Parameters#Random_List_Rule|Random List Rule]]==
  
 
----
 
----
Line 177: Line 177:
 
</table>
 
</table>
  
==='''Reset Lists: [[Session_Rule_List_with_Parameters#Reset_List_Rule|Reset List Rule]]'''===
+
==Reset Lists: [[Session_Rule_List_with_Parameters#Reset_List_Rule|Reset List Rule]]==
  
 
----
 
----
Line 194: Line 194:
 
</table>
 
</table>
  
=='''Trainz Creation Tutorials:'''==
+
='''Trainz Creation Tutorials:'''=
 
*'''<span class="plainlinks">[http://online.ts2009.com/mediaWiki/index.php/HowTo How to Guides]</span>'''
 
*'''<span class="plainlinks">[http://online.ts2009.com/mediaWiki/index.php/HowTo How to Guides]</span>'''
 
<font size="3">'''Route Creation Tutorials:'''</font>
 
<font size="3">'''Route Creation Tutorials:'''</font>

Revision as of 23:17, 5 June 2018

Contents

Parent and Child Rules

Parent Rules

  • Rules that act as Parent Rules can have one or more sub-rules or Child Rules indented under them.
  • Only certain rules can be Parent Rules. See the Trainz Wiki page Parent Rule List for details.

Child Rules

  • Rules that act as Child Rules are indented under a Parent Rule.
  • To indent a rule, highlight (select) it and click the Right Arrow Indent tool at the bottom of the Session Editor.
SessionRuleIndent.JPG SessionRuleIndented.JPG
  • Any rule can be a Child Rule.
  • Child Rules are only executed if the Parent Rule returns a True result from the condition or test it is examining.

Example

Message Popup.jpg

In the screenshot above, the

  • Trigger Check Rule is a Parent Rule. It has rules indented below it.
    • Simultaneous List Rule is indented under the Trigger Check Rule so it is a Child of that rule. It is also a Parent Rule as it has rules indented below it
      • Message Popup Rule is indented under the Simultaneous List Rule so it is a Child of that rule.
      • Wait Rule is indented under the Simultaneous List Rule so it is a Child of that rule. It is also a Parent Rule as it has rules indented below it
        • Close Message Popup Rule is indented under the Wait Rule so it is a Child of that rule.

You can think of this as a family tree.

Trigger Check Rule
  • Parent of Simultaneous List Rule
  • Grand Parent of Message Popup Rule
  • Grand Parent of Wait Rule
  • Great Grand Parent of Close Message Popup Rule
Simultaneous Check Rule
  • Child of Trigger Check Rule
  • Parent of Message Popup Rule
  • Parent of Wait Rule
  • Grand Parent of Close Message Popup Rule
Message Popup Rule
  • Grand Child of Trigger Check Rule
  • Child of Simultaneous List Rule
  • Sibling of Wait Rule
Wait Rule
  • Grand Child of Trigger Check Rule
  • Child of Simultaneous List Rule
  • Sibling of Message Popup Rule
  • Parent of Close Message Popup Rule
Close Message Popup Rule
  • Great Grand Child of Trigger Check Rule
  • Grand Child of Simultaneous Rule
  • Child of Wait Rule

Sequence of Events

  • When the consist identified in the Trigger Check Rule reaches the set trigger, then the Trigger Event is activated and its child rules are executed.
    • The Simultaneous List Rule (which has no conditional test) is then executed. It executes all its child rules simultaneously.
      • The Message Popup Rule is executed. This waits until its message window is closed. At the same time ...
      • The Wait Rule is executed. This is set to force a 20 second wait, after which ...
        • The Close Message Popup Rule is executed. This closes the Message window created by the Message Popup Rule. Since it is the last rule under the Simultaneous List Rule it terminates that rule. Since it is the last rule under the Trigger Check Rule, it also terminates that rule.

Ordered Lists vs Simultaneous Lists

The majority of sibling Child Rules, rules that are at the same indent level under a Parent Rule, will be executed in order (an Ordered List) or simultaneously (a Simultaneous List).

Ordered Lists: Ordered List Rule


DotPoint.JPG Ordered Lists are shown with numbered icons on each Child Rule which indicates the order in which they will be executed.

OrderedListRule.JPG

DotPoint.JPG Each Child Rule in the sequence must be completed before the next Child Rule can be executed.

  • Because some rules will wait for an event (such as a mouse click, timer, consist trigger, load trigger, etc) before they are completed, it is possible for the Ordered List to hang indefinitely waiting for the event.
  • An Ordered List is completed when the last Child Rule is completed.
  • If possible, place Child Rules that are event dependent at the end of an ordered list.

Simultaneous Lists: Simultaneous List Rule


DotPoint.JPG Simultaneous Lists are shown with equality ("=") icons on each Child Rule which indicates that they will be executed at the same time.

SimultaneousListRule.JPG
  • A Simultaneous List can be set to complete when:-
    • all the Child Rules are completed, OR
    • any one of the Child Rules has been completed.

Other Types of Lists

Progressive Lists: Progressive List Rule


DotPoint.JPG On the first run of a Progressive List, only the first Child Rule is executed. On the second run, the second Child Rule is executed, on the third run the third Child Rule is executed, etc.

ProgressiveListRules.JPG

Random Lists: Random List Rule


DotPoint.JPG A Random List will run ONLY ONCE and will randomly select a single Child Rule to execute.

RandomListRules.JPG

Reset Lists: Reset List Rule


DotPoint.JPG A Reset List will execute continuously, it will never terminate. Each time through the list all the Child Rules will be reset and executed again.

ResetListRules.JPG

Trainz Creation Tutorials:

Route Creation Tutorials:

Session Creation Tutorials:

Personal tools