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
.
Type
Description
Void
Void
is a type that means empty. You cannot create variables of that type, it is used to declare functions that returns nothing.
Integer
Real
Boolean
A Boolean
variable can be either True
or False
.
Text
Text
represents a string of characters.
Vec2
Vec3
Int3
Ident
Ident
is the type of an Id. Every class in ManiaScript has a unique Id
property that can be used to identify it.
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