Types
ManiaScript is a strongly typed language which means that every value has to be of a certain type and a value of different type will not be accepted in it's place.
Primitive Types
There are 9 different types in ManiaScript: Void
, Integer
, Real
, Boolean
, Text
, Vec2
, Vec3
,Int3
and Ident
.
Lists and Arrays
List
A List is a type that can store multiple values. You can declare list by adding two square brackets after a type.
There are several basic functions to manipulate them, and you can access one element by its index. The indexes start at 0, so the first index is 0
and the last one is MyList.count-1
. Accessing an invalid index will result in an Out of bounds
error.
Array
An array is similar to a list, except that you can specify a type for the index.
The array above is not a list! There is no add
function for arrays, instead you directly assign a value for the given key.
You can even nest them!
API Arrays
access by Integer or Ident
Structs
Vectors
Vectors are declared with pointing angles: declare Vec2 V = <1.0, 2.0>
.
Vector-elements can be accessed either with X
, Y
and Z
(as V.Y
) or like an array with the indices 0
to 2
(like V[1]
) (depending on the vector having 2 or 3 elements). Vectors are initialized with the initial value for Integer
or Real
respectively, e.g. declare Vec3 V; log(V);
will log as <0., 0., 0.>
.
Last updated