Arcscript


Overview

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 Basics

Arcscript currently supports only assignment and conditional statements.

Assignment Statements

An Arcscript assignment statement should end with the ; terminator character. An assignment is of the form:
variable = expression;
Any variable must have been declared beforehand in Global variables.

Conditional Statements

An example of a conditional statement:

if (x == 5) { 
  y = 4;
  show(x); 
}

or if there is only one statement:

if (x == 2) y = 6;

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

if (hasKey) { 
  show("You may open the door");
} else { 
  show("You cannot open the door"); 
}

or even:

if (age >= 20) {
  type = "adult"; 
} else if (age > 0) { 
  type = "child" 
} else { 
  type = "invalid"; 
}

Expressions

Arcsript supports the creation of expressions using the following arithmetic operators: +, -, *, / and (, ). Expressions may combine litterals, function calls and variables.

Conditions

Conditions in Arcscript may be formed by using the following conditional operators: ==, !=, >, >=, <, <=.

Combining conditions may be achieved by using the following logical operators: &&, ||, !.

Built-in functions

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 number in [0, 1)
show(s) Display the given argument in play mode

Errors

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