Skip to content

QS0 Expressions

maybites edited this page Sep 12, 2022 · 1 revision

home/reference v0.x/{expressions}

{expressions} can be used inisde quescript. {expressions} are in realtime evaluated operations and functions that can use variables.

{expressions} always need to be inside a {} bracket. They can use variables, strings, operands and functions. Strings can be added to each other like numbers, and if the result is a string, a string is returned.

TIP: If {expressions} dont behave as you would expect, send a reset message. This clears all the variables.

SystemVariables

static Variables

PI
TRUE
FALSE

frame dependent variables (script-node memory)

$HOUR   current hours
$MIN    current minutes
$SEC    current seconds
$MILLI  current millis

timer Variable - requires the use of <timer> (que-node memory)

$TIMER  milliseconds since the timer was started

Operators

^   power of
%   modulo
*   multiply
/   division
+   addition
-   substraction
==  equal
!=  not equal
gt  (>) greater than        \  Carefull: using < or > inside an {expr} will cause
st  (<) smaller than         \     a parsing error of Quescript. This is due to
ge  (>=) greater equal than  /     the fact that those characters are reserved
se  (<=) smaller equal than /      for xml-tags.
&&  logical AND
||  logical OR

=   assign value to a variable: var = value

Functions

RANDOM()      returns 0..1
SIN(rad)      sine of angle
COS(rad)      cosine of angle
TAN(rad)      tangens of angle
ASIN(val)     ArcSine of value
ACOS(val)     ArcCosin of value
ATAN(val)     ArcTangens of value
SINH(val)     Hyperbolic Sine
COSH(val)     Hyperbolic Cosine
TANH(val)     Hyperbolic Tangens
RAD(deg)      returns radian
DEG(rad)      returns degrees
LOG(val)      natural logarithm (base e)
LOG10(val)    base 10 logarithm
ROUND(val)    returns to the closest integer
FLOOR(val)    returns to the closest integer <= val
CEILING(val)  returns to the closest integer >= val
SQRT(val)     square root
MAX(val, ...) returns the biggest value
MIN(val, ...) returns the smallest value

IF(<condition>, <execute if true>, <execute if false>)

ARRAY(e1, e2, ...) creates an array
LENGTH(arrayVar) returns the size of an array or 0 if it isn't

Examples

for example if index has the value of 5:

{'text[' + (index * 3) + ']'} returns 'text[15]'

but in this case (if value is 'text'):

{if('text' == value, 1, 0)} returns 1

further examples:

{sin(rad(angle))}

{if(value == 10, value / 2, value ^ 2)}

if var1=1, var2=10, var3=9 then

{max(var1, var2, var3, 7)} returns 10
Clone this wiki locally