# Expressions

Home

Expressions allow one to do computations in scripts or to retrieve numerical values. They use simple arithmetic to do the calculations, nothing too fancy. Anywhere that a number is usually accepted, an expression expansion can be used, even within an expansion!

The basic syntax:
\$[ term op term ... op term ]

A term can be any of the following:
 numeric unsigned integer values string references integer variables, all other types default to 0 [ifcheck] calls a numeric ifcheck, botched ifcheck calls result in 0Example: [vnum \$n] (expression) grouped by parenthesis, they are the result of sub expressions, such as (3+cnt)

Operators:

 !x boolean NOT x : y random range from x to y x / y division ** x % y modulo ** x * y multiplication x + y addition x - y subtraction
** NOTE: division or modulo by zero computes to zero for the entire expression.

Simple constant:
\$

Referencing a variable:
\$[foo]
\$[foo+2]
\$[foo-bar]

Random Numbers:
\$[3:10]
\$[3:foo]
\$[foo:bar]

Groupings:
\$[x*y+x]
\$[x*(y+1)]
\$[(x*3):(x*10)]
\$[x*(3:10)]

Ifcheck calls:
\$[[vnum \$n]]
\$[3*[tokenvalue \$n 1234 0]]
\$[[tokenvalue \$n 1234 0]+[tokenvalue \$n 1234 2]]

These calls can be nested too: (Remember, \$[ ] can be used pretty much anywhere numbers can be used)
\$[[dice \$[[tokenvalue \$n 1234 0]] \$[[tokenvalue \$n 1234 1]]]]

Back to Top