Arrays are used to store multiple variables in an organized way. Before you can use an array, you must declare it. Example:
int myArray[8]
This declares a static array called myArray with 8 elements. (It is called a static array because the number of elements is fixed. To declare a dynamic array that allows the number of elements to be changed later, see Dynamic arrays.)
You can use the elements in the array like normal variables:
myArray[0] = 1 myArray[myArray[0]] = 2 * myArray[0] + 1
You access an element in an array by specifying the index of the element between square brackets [ ]. The index must be an integer expression, ranging from 0 to the number of elements - 1 (the value 0 corresponds to the first element in the array).
You can also declare and use multi-dimensional arrays by specifying multiple values between the brackets. When declaring an array, the size of each dimension must be a constant integer expression. Parameters and most predefined symbols also qualify as constants. Example:
float a[10, 2 * 6 - 2] bool flags[#width, #height] a[3, 5 - 3] = 1.5 flags[0, 0] = a[1 + 2, 2] > 0
You can directly assign arrays with the same size to one another:
color x[10] color y[10] x = y
Notes
Next: Dynamic arrays