Content

Introduction

This documentation is not a tutorial in any way. You need to have both knowledge about ManiaScript in general and some basic knowledge about its usage. I'm trying to give a complete and correct reference about ManiaScript, but I can't guarantee anything. If you see a mistake or something missing, you are welcome to contact me listed on the right or any other way you know.

You are also welcome to donate some Planets to me. My login is konte. Thanks for every donation and have fun with ManiaScript :)
Konte

Legend

  • function() – function/method
  • function() – function/method without return value (void)
  • variable – readable and writable variable/property
  • variable – read-only variable/property
  • Object - object
  • CGameClass - class
  • enum::value - enum variable (and its selected type)
  • Integer/Text/… - variable type
  • argument - list of arguments

Links opened in new tab

ManiaScript Tutorials

[English] Syntax Basics by Gugli
[English] Tutorial/Reference by AK
[German] Tutorial by destroflyer

Further Links

[English/German] Manialink Tutorial by Marcel
Variable overview by destroflyer
List of BlockModels
List of Syntax Elements

Contact

In-game PM (login konte)
Maniaplanet PM
ManiaCommunity PM
Topic on Maniaplanet
Topic on ManiaCommunity

General

Array Functions

You can apply methods to arrays and get properties (like in JavaScript; okay, there's only one property). Attention: remove(), removekey() and add() affect the array (and thus the variable) directly, unlike sort(). Example:
declare myarray = [3, 7, 5]; myarray.add(4); myarray.removekey(0); myarray = myarray.sort(); log(myarray); // [4, 5, 7]
Top

MathLib

You need to load the Math object in order to access the math functions:
#Include "MathLib" as MathLib
Top

TextLib

You need to load the TextLib object in order to access the Text functions (it does not work in editor plugins):
#Include "TextLib" as TextLib
Top

Manialinks

#RequireContext CGameManialinkScriptHandler

Events

There is this following standard construct to react on events:
while(True) { foreach(Event in PendingEvents) { switch(Event.Type) { // case blabliblubb and so on } } yield; }
Event has the following properties: Top

Page

Page is also a predefined object to select elements and get their properties or change properties. Top

Element Classes

Both MainFrame.Controls and GetFirstChild() return an object. The class of this object is CGameManialinkControl. In addition, this object can be cast as one of the following derivatives of CGameManialinkControl (so, all the methods and properties of the base class can still be used). CGameManialinkControl CGameManialinkQuad CGameManialinkEntry CGameManialinkFileEntry CGameManialinkLabel CGameManialinkFrame Top

Key and Mouse States

There are several predefined variables (returning a Boolean) which state whether a certain key or mouse button is pressed or not: Top

Other Variables and Functions

Top

Editor Plugins

#RequiredContext CGameCtnEditorPluginScriptHandler
For the position of blocks there is a type called Int3. Syntax:
declare Int3 coord = <0, 1, 2>;
You can access (read and write) the values like arrays, coord[0] e.g. coordinates are in the form <CoordX, CoordY, CoordZ>, this means, width, height, depth seen parallelly to the ground. By the way, I didn't test everything, especially nothing concerning MacroBlocks. Top

Events

As well as in Manialinks, there is an array called PendingEvents. Its elements (I call it Event again) have the property Type. Values of Type: Every placement of a block triggers both a CursorSelectionBegin and CursorSelectionEnd event. If it is only a normal block, the events occur just one after the other. But it's still like with placing a terrain or road block: CursorSelectionBegin is triggered when pressing the mouse button, CursorSelectionEnd when leaving the mouse button. CursorChange can also be triggered between SelectionBegin and -End, of course. Top

Manialinks

Top

Directions and Position

MapUnits

The MapUnits object provides some advanced functions for the directions and positions. You need to load the MapUnits object in order to access those functions:
#Include "MapUnits" as MapUnits
Top

Map

CGameCtnChallenge Map - Map properties. Top

Block Models

Pay attention to the writing of macroblocks: The class is CGameCtnMacroBlockInfo, the object MacroblockModels[]. CGameCtnBlockInfo CGameCtnMacroBlockInfo CGameCtnBlockInfoVariant Top

Block functions

Top

Place and Edit mode

(PlaceMode and EditMode don't work at all) Top

Other variables and functions

Top

MediaTracker Camera Effect Scripts

#RequireContext CGameCtnMediaBlockCameraEffectScript
Camera Effect Scripts have another new type called Vec3, which is the same as Int3, but with the difference that the values are Reals and not Integers.
declare Vec3 MyPersonalVector = <12.333, 2., 0.5>;

Variables

Example:
OffsetPos[1] = A*0.1*sin(1.*Now*20);