User Tools

Site Tools


Sidebar

Translations of this page:
en

Index

en:traffic:documentation:conditional_evaluations


You can customize your Timetable file by using conditional evaluations to base actions on conditions.  Commonly known as “if/then” statements, conditional evaluations ask “what if,” the operative part of the evaluation being “if” and then assign an action based on that “if.”  The syntax of these conditional evaluations is as follows:

{ <Condition> ? <true_part> ? <false_part> }

These conditions are evaluated first, and only the lines or line parts passed through the conditional evaluation will be analyzed and acted upon. You can modify any element of a Timetable file (commands, Movements, single parameters, vehicle names, modification commands) with these conditional expressions.

The configuration options must be referenced in the first few lines of the Timetable file by using the $OPT-commands ( or setting them in the timetable file by the $SET command).  The value of these options (selected or unselected) can then be chosen from the Traffic Configuration window using the Options menu commands.

Individual configuration strings can be linked together to create combinations of their outcomes.  The linking process is similar to an algebraic equation.  The individual options are combined in parentheses and combined with the elements & (meaning „ and“) or | (meaning „ or”).  Placing a ! (exclamation point) in front of the string returns the opposite or negative value of the string.  If you place a ! in front of a string contained in parentheses, it will return the negative value of whatever the outcome of it inside the parentheses is.

The second question mark and the <false_part> parameter are optional.  Individual parts of the expression can be nested inside one another.  For example: {Norway?E116|E117{Diesel?|Di6}} . If both optiones “Norway” and “Diesel” are checked in the option menu, than this snippet can change from 3 types of engines, when Diesel is not checked, than

The “conditional evaluations” described here and the “conditional modifiers” controlled by criteria are completely different things. The conditional modifiers ( [<Condition> ! <Command>:…] or [< <Command>:…]) base their outcome on the existence of criteria modifiers in the train expressions.  In the Timetable file you can choose among the possibilities (to obey a modifier or not) which you defined in macro definitions elsewhere in the same Timetable file, in an included Timetable file or in the Stock List.  In addition, you can select among the possibilities based on the actual direction of the trains - which can be the result of a random decision made by the computer.  The conditional modifiers help to define the vehicles in general: with or without smoke, with or without load, which pictures are used for vehicles travelling left or right (or by mirroring a single vehicle picture or only certain parts of it).

On the contrary, the conditional evaluation ( { <condition> ? <true_part> ? <false_part> } ) based on the options relies on the decision of the human user - as the options can be set and cleared in the program's Configuration menu. A conditional modifier can behave differently during each screensaver run as its definition is based on the actual environment – that is, which context the vehicle macro is invoked.  The same conditional evaluation behaves the same way in every run because the value of the options is analyzed at the start of the program and only the parts of the Timetable file will acted upon that fulfill the conditions in the { ? } constructs.

The conditional evaluation happens during reading the timetable files: the parts, which are selected to omit, won't be read in at all.

This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.
More information
en/traffic/documentation/conditional_evaluations.txt · Last modified: 2018/09/09 17:51 (external edit)