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

An Integer variable is an integer number (Z\mathbb{Z} in mathematics) between 2147483648-2147483648 (231-2^{31}) and 21474836472147483647(23112^{31}-1).

Real

A Real variable is a real number (R\mathbb{R} in mathematics). It can represent values much higher than Integer.

Boolean

A Boolean variable can be either True or False.

Text

Text represents a string of characters.

Vec2

Vec2 is a two dimensional vector (R2\mathbb{R^2} in mathematics). The two values can be accessed with X and Y respectively.

Vec3

Vec3 is a three dimensional vector (R3\mathbb{R^3} in mathematics). The third value can be accessed with the Z property.

Int3

Int3 is a three dimensional vector (Z3\mathbb{Z^3} in mathematics).

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