Session Rules Overview

From TrainzOnline
(Difference between revisions)
Jump to: navigation, search
(Created page with "Session Rules Overview This page provides a brief theoretical overview of the components that make up a Trainz session and the rules that control the session. For more in...")
 
 
(14 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[Session Rules Overview]]
+
This page provides a brief overview of Session Rules (AKA Behaviors), which are the driving force behind gameplay logic in structured Trainz Sessions. If you are unfamiliar with Sessions or Rules, see the [[HowTo/Create a session]] guide for an example of how to create a simple Session using some of the builtin Rules.
 
+
This page provides a brief theoretical overview of the components that make up a Trainz session and the rules that control the session. For more information about session
+
 
+
implementation and structure see [[HowTo/Create a session]].
+
  
 
=Anatomy of a Session=
 
=Anatomy of a Session=
A session is a Surveyor-created asset that groups together a variety of components to create a playable environment for Driver. This includes the route, rules, consists and custom
+
A Session is a Surveyor-created asset that groups together a variety of components to create a playable environment for Driver. This asset type is overlaid atop the Route asset, and can add trains, objects, track etc, alter environmental data such as lighting and weather, modify the properties of objects within the Route, hide Route objects using layer bindings, and/or implement complex gameplay logic using Session Rules. Put simply, Session Rules are scripted Trainz assets which are used to govern and control the gameplay behavior of a Session.
  
configuration properties. Rules are scripted Trainz assets used to govern and control the behavior of the session.
+
'''Fig.1 Conceptual view of a session and it's primary components...'''
  
Fig.1 Conceptual view of a session and it's primary components.
+
[[Image:SessionRulesOverview1.jpg]]
  
The session has a properties database for each rule instance it uses so that rule’s particular configuration for the session can be saved/loaded. Multiple instances of the same type of
 
  
rule can exist in a session, each with its own unique configuration. This works in the same way that multiple instances of a specific type of locomotive can exist in the session where  
+
The Session has a properties database for each rule instance it uses so that rule's particular configuration for the Session can be saved/loaded. Multiple instances of the same type of rule can exist in a Session, each with its own unique configuration. This works in the same way that multiple instances of a specific type of locomotive can exist in the Session where each locomotive can have its own name and running number.
  
each locomotive can have its own name and road number.
+
Rules are designed to perform specific tasks such as monitoring and reacting to events, enabling the session creator to direct gameplay. Rules are added, configured or removed from a Session via Surveyor's Edit Session dialog.
  
Rules can be added, configured or removed from a session via Surveyor's Edit Session dialogue. Rules are designed to perform specific tasks such as monitoring and reacting to
+
=Rule Hierarchy and Child Rules=
  
events, enabling the session creator to direct gameplay.
+
Rule hierarchy is established in order to pause certain Rules unless specific criteria have been met. Top level or "parent" Rules are started automatically when the session is launched in Driver. Child Rules are executed only when explicitly started by their parent Rule.
  
=Rule Hierarchy and Child Rules=
+
'''Fig.2 When Driver is launched, top level rules are initialized and run immediately using the settings defined in Surveyor...'''
  
Rule hierarchy is established in order to pause certain rules unless specific criteria have been met. Top level or "parent" rules are started automatically when the session is launched in
+
[[Image:SessionRulesOverview2.jpg]]
  
Driver. Child rules are executed only when explicitly started by the parent rule.
+
'''Fig.3 Child rules are not run until specific criteria defined in the parent rule are met...'''
  
Fig.2 When Driver is launched, top level rules are initialized and run immediately using the settings defined in Surveyor.  
+
[[Image:SessionRulesOverview3.jpg]]
  
Fig.3 Child rules are not run until specific criteria defined in the parent rule are met.
+
'''Fig.4 Child Rules are indented below the parent Rule. Note the order of execution is displayed to the left of the child Rules. In this example nothing happens until a train enters a particular trigger, at which time a sound is played and then a popup message is displayed...'''
 +
 
 +
[[Image:SessionRulesOverview4.jpg]]
  
Fig.4 Child rules are indented below the parent rule. Note the order of execution is displayed to the left of the child rules. In this example nothing happens until a train enters a a
 
  
particular trigger, at which time a sounds is played and then a popup message is displayed.
 
  
 
=Rule Behaviour=
 
=Rule Behaviour=
  
A rule's behaviour depends upon the nature of it's task. Some rules complete their task immediately, some check only once for specific criteria, while others wait for a specific event or  
+
A Rule's behaviour depends upon the nature of its task. Some Rules complete their task immediately, some check only once for specific criteria, while others wait for a specific event or situation. Generally the behavior of a Rule is outlined in its configuration dialog, where it may even allow this behavior to be modified. For more information about a specific rule refer, you can refer to the list of documented Session Rules [[:Category:Rules|here]].
 
+
situation. Generally the behaviour of a rule is outlined in it's configuration dialogue. For detailed information about specific rules refer to the list of documented Surveyor Rules.
+
  
 
==Task Rules==
 
==Task Rules==
  
Task rules perform their function the instant the rule is started and then remain idle unless reset by a parent rule. These rules are generally executed at startup or by a parent rule once  
+
Task Rules perform their function the instant the rule is started and then remain idle unless reset by a parent Rule. These Rules can be executed at startup in order to set initial Session state, or by a parent Rule once specific criteria have been met.
 
+
specific criteria have been met.
+
  
 
==Event and Check Rules==
 
==Event and Check Rules==
  
Once started these rules generally wait for specific events to occur before proceeding to execute their task or their child rules. In some cases these rules perform no other function  
+
Once started these Rules generally wait for specific events to occur before proceeding to execute their task or their child rules. In many cases these Rules perform no other function beyond executing their child Rules.
  
beyond executing their child rules.
+
'''Fig.5  Generally an event Rule completes only once all child Rules have been executed...'''
 
+
Fig.5  Generally an event rule completes once it's task and/or any child rules have been executed.
+
  
 +
[[Image:SessionRulesOverview5.jpg]]
  
 
==List Rules==
 
==List Rules==
  
Some rules do not support child rules, and rules indented below them will be executed simultaneously. List rules are designed specifically to execute and manage the running of child  
+
Some Rules do not support child rules, and Rules indented below them will not be executed at all. List rules are designed specifically to execute and manage the running of child Rules, and can themselves be child Rules. See [[Ordered List]], [[Progressive List]], [[Random List]], [[Reset List]] and [[Simultaneous List]].
 +
 
 +
'''Fig.6 A list Rule with its own child Rules can be parented to an event or check Rule...'''
 +
 
 +
[[Image:SessionRulesOverview6.jpg]]
 +
 
 +
==Further Reading==
 +
 
 +
Like all Trainz assets, it is possible to create your own Session Rules if you cannot find one that suits your needs. As Rules are scripted assets this task is quite complex, and requires some basic knowledge of programming. If you are interested in creating your own Session Rule assets, read the guide on [[Session Rule Implementation]].
  
rules, and can themselves be child rules.
+
SEE ALSO:
 +
*[[Session_Rule_Implementation|Session Rule Implementation]]
  
Fig.6 A list rule with it's own child rules can be parented to an event or check rule.
+
[[Category:Help]]
 +
[[Category:Session Rules]]

Latest revision as of 15:32, 11 October 2019

This page provides a brief overview of Session Rules (AKA Behaviors), which are the driving force behind gameplay logic in structured Trainz Sessions. If you are unfamiliar with Sessions or Rules, see the HowTo/Create a session guide for an example of how to create a simple Session using some of the builtin Rules.

Contents

[edit] Anatomy of a Session

A Session is a Surveyor-created asset that groups together a variety of components to create a playable environment for Driver. This asset type is overlaid atop the Route asset, and can add trains, objects, track etc, alter environmental data such as lighting and weather, modify the properties of objects within the Route, hide Route objects using layer bindings, and/or implement complex gameplay logic using Session Rules. Put simply, Session Rules are scripted Trainz assets which are used to govern and control the gameplay behavior of a Session.

Fig.1 Conceptual view of a session and it's primary components...

SessionRulesOverview1.jpg


The Session has a properties database for each rule instance it uses so that rule's particular configuration for the Session can be saved/loaded. Multiple instances of the same type of rule can exist in a Session, each with its own unique configuration. This works in the same way that multiple instances of a specific type of locomotive can exist in the Session where each locomotive can have its own name and running number.

Rules are designed to perform specific tasks such as monitoring and reacting to events, enabling the session creator to direct gameplay. Rules are added, configured or removed from a Session via Surveyor's Edit Session dialog.

[edit] Rule Hierarchy and Child Rules

Rule hierarchy is established in order to pause certain Rules unless specific criteria have been met. Top level or "parent" Rules are started automatically when the session is launched in Driver. Child Rules are executed only when explicitly started by their parent Rule.

Fig.2 When Driver is launched, top level rules are initialized and run immediately using the settings defined in Surveyor...

SessionRulesOverview2.jpg

Fig.3 Child rules are not run until specific criteria defined in the parent rule are met...

SessionRulesOverview3.jpg

Fig.4 Child Rules are indented below the parent Rule. Note the order of execution is displayed to the left of the child Rules. In this example nothing happens until a train enters a particular trigger, at which time a sound is played and then a popup message is displayed...

SessionRulesOverview4.jpg


[edit] Rule Behaviour

A Rule's behaviour depends upon the nature of its task. Some Rules complete their task immediately, some check only once for specific criteria, while others wait for a specific event or situation. Generally the behavior of a Rule is outlined in its configuration dialog, where it may even allow this behavior to be modified. For more information about a specific rule refer, you can refer to the list of documented Session Rules here.

[edit] Task Rules

Task Rules perform their function the instant the rule is started and then remain idle unless reset by a parent Rule. These Rules can be executed at startup in order to set initial Session state, or by a parent Rule once specific criteria have been met.

[edit] Event and Check Rules

Once started these Rules generally wait for specific events to occur before proceeding to execute their task or their child rules. In many cases these Rules perform no other function beyond executing their child Rules.

Fig.5 Generally an event Rule completes only once all child Rules have been executed...

SessionRulesOverview5.jpg

[edit] List Rules

Some Rules do not support child rules, and Rules indented below them will not be executed at all. List rules are designed specifically to execute and manage the running of child Rules, and can themselves be child Rules. See Ordered List, Progressive List, Random List, Reset List and Simultaneous List.

Fig.6 A list Rule with its own child Rules can be parented to an event or check Rule...

SessionRulesOverview6.jpg

[edit] Further Reading

Like all Trainz assets, it is possible to create your own Session Rules if you cannot find one that suits your needs. As Rules are scripted assets this task is quite complex, and requires some basic knowledge of programming. If you are interested in creating your own Session Rule assets, read the guide on Session Rule Implementation.

SEE ALSO:

Personal tools