...
Conditions with results: If the instantiating cue has conditions with results, those results are stored in variables - but in the variables of the static cue, not of the instance! So in the <actions> you have to access the variables via the static keyword:
<debug_text text="static.$foo"/>
It may even be necessary to copy the variables over to the instance because the static variables can be overwritten by the next condition check:<set_value name="$foo" exact="static.$foo"/>
Resetting completed/cancelled instances: As explained above, sub-instances are only created when needed (when going to the waiting state) and are destroyed when they are not needed any more (when they are completed or cancelled, including all sub-cues). There are cases in which you want to access cues that don’t exist any more - it simply doesn’t work. In some cases you are safe: You can be sure that all your ancestors exist, and instantiating cues won’t be removed until they are cancelled. In some other cases you simply don’t know and have to check if the instance is already (or still) there.
Lifetime of instances: Do not make assumptions about when an instance is removed! Just looking at it in the Debug Manager keeps it alive for the time being. So, sometimes you could still have a completed instance that wouldn’t exist under other circumstances.
...
Most of the attribute values in actions and conditions are interpreted as script expressions and parsed accordingly. An expression is a phrase that can be evaluated to a single value. The simplest expressions are actual numeric values and strings, so called literals:
0
(integer number)0772
(leading 0 means octal integer number)3.14159
(floating point number)5e12
(float in exponent notation, “times ten to the power of”)0xCAFE
(hexadecimal integer number)
...
You can write string literals by putting the string in single quotes:
'Hello world'
''
(empty string)'String with a line break\n'
Note |
---|
Since expressions are written in XML attribute values, you have to use the single quotes inside the double quotes for the actual attribute value. To write characters like < > " & in an expression string (or anywhere else in an XML attribute value), you’ll have to escape them as < > " & respectively. The backslash \ can be used in strings for escape characters like in C/C++. Most important are \' for a single quote as part of the string, and \\ for the backslash itself. |
...
Numbers can have a suffix that determines their numeric type. There are also numerical data types like “money” or “time” which can only be expressed by using an appropriate unit suffix:
5000000000L
(large integer)1f
(floating point number, same as 1.0, just 1 would be an integer)1000Cr
(Money in Credits, converted to 100000 cents automatically)500m
(Length in metres)10s
(Time in seconds)1h
(Time in hours, which is converted to 3600s automatically)
...
Operator / Delimiter / Constant | Type | Example | Result of example | Description |
---|---|---|---|---|
null | constant |
|
| Null value, see above |
false | constant |
|
| Integer value 0, useful in Boolean expressions |
true | constant |
|
| Integer value 1, useful in Boolean expressions |
pi | constant |
|
| π as an angle (same as 180deg) |
() | delimiter |
|
| Parentheses for arithmetic grouping |
[] | delimiter |
|
| List of values (see below) |
table[] | delimiter | table[$foo='bar', {1+1}=40+2] | table[$foo='bar', {2}=42] | Table of values (see below) |
{} | delimiter |
|
| Text lookup (page ID and text ID) from TextDB |
+ | unary |
|
| Denotes positive number (no effect) |
- | unary |
|
| Negates the following number |
not | unary |
|
| Yields true if the following expression is false (equal to zero), false otherwise |
typeof | unary |
|
| Yields the data type of the following sub-expression |
sin | unary |
|
| Sine (function-style, parentheses required) |
cos | unary |
|
| Cosine (function-style, parentheses required) |
sqrt | unary |
|
| Square root (function-style, parentheses required) |
exp | unary |
|
| Exponential function (function-style, parentheses required) |
log | unary |
|
| Natural logarithm (function-style, parentheses required) |
^ | binary |
|
| Power |
* | binary |
|
| Multiplication |
/ | binary |
|
| Division |
% | binary |
|
| Modulus (remainder of integer division) |
+ | binary |
|
| Addition String concatenation |
- | binary |
|
| Subtraction |
lt < (<) | binary |
|
| Less than |
le <= | binary |
|
| Less than or equal to |
gt > (>) | binary |
|
| Greater than |
ge >= | binary |
|
| Greater than or equal to |
== | binary |
|
| Equal to |
!= | binary |
|
| Not equal to |
and | binary |
|
| Logical AND (short-circuit semantics) |
or | binary |
|
| Logical OR (short-circuit semantics) |
if ... then ... if ... then ... else ... | ternary |
|
| Conditional operator ("inline if") |
...
$list.{5}
⟹ The fifth element of a list - however, if $list has less than 5 elements (and if it's also not a table with the key 5), there will be an error$list.{5}?
⟹ true if $list exists and has the property 5, false otherwise$table.$key?
⟹ Analogously, true if the $table exists and has the string property '$key'
...