YesNoOk
avatar

Expressions in trigger arguments (CNS) (Read 2887 times)

Started by JustNoPoint, October 07, 2015, 02:26:42 pm
Share this topic:
Expressions in trigger arguments (CNS)
#1  October 07, 2015, 02:26:42 pm
  • ******
    • www.justnopoint.com/
Most function-type triggers either take no arguments or take arguments in a parameter list. For instance, the time trigger takes no arguments, whereas the ifelse trigger takes three arguments

ifelse(exp1,exp2,exp3)

where exp1, exp2, and exp3 are all valid expressions. In this kind of situation, exp1, exp2, and exp3 are all considered separate subexpressions, so intervals can appear on the rightmost end of each of those subexpressions. The order of evaluation of parameter lists is from left to right.

Due to irregular syntax, some old function-type triggers cannot take expressions as their arguments. Because of this, they cannot be integrated into expressions in the standard manner. For nonstandard triggers of this type, the triggers can only appear with certain sets of operators and arguments (which are outlined in trigger.doc). In particular, these triggers cannot take expressions as their arguments. For instance,

Code:
trigger1 = AnimElem = (1+1)
is an invalid expression.

Old-style function-type triggers appear only in "clauses" of the form "trigger, relational operator, argument". These clauses are treated as a single unit (specifically, a single nullary trigger) for the purposes of expression evaluation. This means, among other things, that the concept of operator precedence is not applicable to operators appearing within an old-style function-type trigger clause. For instance, in

Code:
trigger1 = AnimElem = 5 + 4
the expression is broken down into three units:

Code:
 AnimElem=5    +    4
|__________|  |_|  |_|
The "AnimElem=5" unit is treated as the name of a nullary trigger, hence the + operator does not have precedence over the = appearing within the name "AnimElem=5". In other words, this expression means something like "Execute the trigger called 'AnimElem=5', then add 4 to the result."

Some old-style function-type triggers have expression-capable replacements. These are as follows:

  • AnimElem, superseded by AnimElemTime
  • TimeMod, superseded by the % operator
  • ProjHit, ProjContact, ProjGuarded; superseded by ProjHitTime, ProjContactTime, and ProjGuardedTime

For the complete list of irregular triggers, see trigger.html. Irregular triggers are marked with ***.