Arcweave introduces basic scripting capabilities through **Arcscript**. Scripts may be put in element content as a series of statemens and in branches as conditions.

Arcscript currently supports only **assignment** and **conditional** statements.

A simple Arcscript assignment statement is of the form: `variable = expression`

Any variable must have been declared beforehand in Global variables.

Example:

`x = y + 5`

Arcscript also supports addition, subtraction, multiplication and division assignments using the operators: `+=`

, `-=`

, `*=`

, `/=`

respectively.

Example:

`x += 2`

Inside a conditional statement you may have other statements (e.g. assignments or conditionals) or simple text.
Example of a conditional statement containing an assignment:

`if (x == 5)`

`y = 4`

`endif`

Example of a conditional statement containing text:

`if wielding_shield`

The knight is wielding a large shield.`endif`

There is also the option to execute statements when the condition is false:

`if hasKey`

`door_unlocked = true`

`else`

You cannot open the door`endif`

or choose between multiple outcomes:

`if age >= 20`

`type = "adult"`

`elseif`

`age > 0`

`type = "child"`

`else`

`type = "invalid"`

`endif`

Arcsript supports the creation of expressions using the following arithmetic operators:
`+`

, `-`

, `*`

, `/`

and `(`

, `)`

. Expressions may combine litterals, function calls and variables.

Conditions in **Arcscript** may be formed by using the following conditional operators:
`==`

(or `is`

), `!=`

(or `is not`

), `>`

, `>=`

, `<`

, `<=`

.

Combining conditions may be achieved by using the following logical operators:
`&&`

(or `and`

), `||`

(or `or`

), `!`

(or `not`

).

The functions that are currently supported in Arcscript:

Function | Returns |
---|---|

abs(n) | The absolute value of a number |

sqr(n) | The square of a number |

sqrt(n) | The square root of a number |

random() | A random decimal in [0, 1) |

roll(d, n) | A random integer in [1, d]. If n is specified the dice is rolled n times |

show(e1, e2, ...) | Display the evaluation of one or more expressions |

When a script has a compile-time error this is denoted by an exclamation mark image.