Meteor 2 Scripting Functions
Mission
bool getSinglePlayerRespawnEnabled()
Determine if single player respawn is enabled.

Example
if(getSinglePlayerRespawnEnabled())
{
    print("Single player respawn is enabled");
}
else
{
    print("Single player respawn is disabled");
}

See also
setSinglePlayerRespawnEnabled

void setSinglePlayerRespawnEnabled(bool enable)
Enable or disable single player respawn instead of reloading the level.

Example
// enable single player respawn
setSinglePlayerRespawnEnabled(true);

Comments
Single player respawn is disabled by default so the level reloads and restarts.
Enable single player respawn to teleport the player back to the start of the mission (player items will not be changed on restart).

See also
getSinglePlayerRespawnEnabled onPlayerSpawn

bool getSwimmingEnabled()
Determine if swimming is enabled.

Example
if(getSwimmingEnabled())
{
    print("Swimming is enabled");
}
else
{
    print("Swimming is disabled");
}

See also
setSwimmingEnabled isSwimming

void setSwimmingEnabled(bool enable)
Enable or disable swimming (server only).

Example
// enable swimming for duration of mission
if(isServer())
{
    setSwimmingEnabled(true);
}

Comments
Swimming is enabled by default meaning that human characters can cross water.
Disable swimming to restore classic Meteor 2 behaviour for the duration of the mission.
Swimming can be disabled in the Map Editor without the need for scripting in "Map Properties".
If swimming is enabled:
- Human characters (including players) can cross water to get across rivers and get to islands.
- Characters can exit boats when not near a shore.
- Characters can survive if their aircraft engine stops over water.
- Human characters cannot fire weapons while in water.
If swimming is disabled:
- Human characters (including players) cannot cross water.
- Characters will not survive if their aircraft engine stops over water.
- Characters cannot exit boats if not near shore (e.g. if the boat runs out of fuel you cannot exit the boat).


See also
getSwimmingEnabled isSwimming

void endLevel()
End the current level (server only).

Example
if(isServer())
{
    endLevel();
}

Comments
Same as typing "endlevel" in the game console.

See also
gameOver runMap

void gameOver(string message)
Kill the local player.

Example
gameOver("Why?");

Comments
Same as typing "kill" in the game console.
In single player this causes level restart, in multiplayer this prompts a respawn.
message is not net synced.

See also
gameOver runMap

void runMap(string mapFilename)
Play a map (server only).

Example
runMap("start");

Comments
Same as typing "map <filename>" in the game console.

See also
endlevel gameOver

void playMovieClip(string clipFilename, string soundName)
Play a FLC movie clip from the base folder.

Example
// example 1: intro with sound
playMovieClip("intro.flc", "intro");

// example 2: intro without sound
playMovieClip("intro.flc", "");

Comments
Movie clips cannot be played in multiplayer.

void setSideID(uint8 sideNumber, int sideID)
Set side ID of an entire side (faction) for the duration of the mission.

Example
Use this function to set faction allegiances.
Sides with matching side IDs will not attack each other.
sideNumber must match the side number in game.ini, for example [side0] is 0.
sideID corresponds to SideId=? in each side's section in game.ini.

void setMissionMoveToPos(vector2 pos, string name="", int playerID=-1)
Display a distance and direction indicator to the specified position.

Example
setMissionMoveToPos(vector2(2000, 2000), "Objective");

Comments
name is optional, default is empty string.
playerID is optional, default is local player.
If run from a client this function can only affect the local player.
If run from a server this function can affect any player (use playerID to specifiy which player).
The move to pos does not clear after multiplayer respawn. Use the onObjectSpawn event to clear if required.
The move to pos is cleared when starting a new mission (changing map).
The move to pos and name are network synced to all players.

See also
clearMissionMoveToPos getMissionMoveToPos getMissionMoveToName

void clearMissionMoveToPos(int playerID=-1)
Clear the current mission move to position (stops displaying the distance/direction indicators).

Example
clearMissionMoveToPos();

Comments
playerID is optional, default is local player.
If run from a client this function can only affect the local player.
If run from a server this function can affect any player (use playerID to specifiy which player).

See also
setMissionMoveToPos clearMissionMoveToPos getMissionMoveToName

vector2 getMissionMoveToPos(int playerID=-1)
Get the current mission move to position.

Example
print(getMissionMoveToPos());

Comments
playerID is optional, default is local player.
Returns 0,0 if no move to pos is active.

See also
setMissionMoveToPos clearMissionMoveToPos getMissionMoveToName

vector2 getMissionMoveToName(int playerID=-1)
Get the current mission move to name.

Example
print(getMissionMoveToName());

Comments
playerID is optional, default is local player.
name parameter is optional.

See also
setMissionMoveToPos clearMissionMoveToPos getMissionMoveToPos

int createTriggerBox(vector2 pos, vector2 size, string tag)
Create a trigger box (local only).

Example
// create a 60x30 pixels trigger box centred around position 500,500 with a tag of "base_entrance".
int trigger_baseEntrance = createTriggerBox(vector2(500,500), vector2(60,20), "base_entrance");

Comments
This function creates a trigger box locally only (not network replicated).
size is in pixels.
The returned triggerBoxID is local to this computer.
The trigger box is enabled by default.
Returns -1 if no trigger box was created (invalid size or too many triggers).
Store the returned triggerBoxID if you need to alter or delete the trigger box later on.
Use the "triggers" console command to toggle showing trigger boxes in-game.

See also
deleteTriggerBox setTriggerBoxEnabled getTriggerBoxEnabled onTriggerBoxEnter onTriggerBoxExit

void deleteTriggerBox(int trigerBoxID)
Delete a trigger box (local only).

Example
// delete trigger box ID 1
deleteTriggerBox(1);

Comments
The trigger box will be deleted. The ID number will not be reused.

See also
createTriggerBox setTriggerBoxEnabled getTriggerBoxEnabled onTriggerBoxEnter onTriggerBoxExit

void setTriggerBoxEnabled(int triggerBoxID)
Create a trigger box (local only).

Example
// disable trigger box ID 1
setTriggerBoxEnabled(1, false);

See also
createTriggerBox deleteTriggerBox getTriggerBoxEnabled onTriggerBoxEnter onTriggerBoxExit

bool getTriggerBoxEnabled(int triggerBoxID)
Get the enabled status of a trigger box.

Example
print(getTriggerBoxEnabled(1));

See also
createTriggerBox deleteTriggerBox setTriggerBoxEnabled onTriggerBoxEnter onTriggerBoxExit

bool getMinimapOpen()
Get whether the minimap is currently open on the local computer.

Example
print(getMinimapOpen());

See also
setMinimapOpen

void setMinimapOpen(bool open)
Open or close the minimap on the local computer.

Example
setMinimapOpen(false);

See also
getMinimapOpen

bool getMinimapEnabled()
Get the enabled status of the minimap.

Example
print(getMinimapEnabled());

See also
setMinimapEnabled

void setMinimapEnabled(bool enable)
Set the enabled status of the minimap (server only).

Example
setMinimapEnabled(false);

Comments
Enables or disables the minimap for the duration of the level for all players.

See also
getMinimapEnabled

int getCorpseLimit()
Get the maximum number of corpses allowed on the map.

Example
// display corpse limit
print(getCorpseLimit());

See also
setCorpseLimit setWreckLimit getWreckLimit

void setCorpseLimit(int count)
Set the maximum number of corpses allowed on the map (server only).

Example
// set corpse limit
setCorpseLimit(20);

Comments
Corpse sprites are deleted in creation order.
Corpses placed in the Map Editor are not deleteed.
Set count to 0 for unlimited.
Passing a negative value will be clamped to 0.

See also
getCorpseLimit setWreckLimit getWreckLimit

int getWreckLimit()
Get the maximum number of wrecks allowed on the map.

Example
// display wreck limit
print(getWreckLimit());

See also
setWreckLimit setCorpseLimit getCorpseLimit

void setWreckLimit(int count)
Set the maximum number of wrecks allowed on the map (server only).

Example
// set wreck limit
setWreckLimit(10);

Comments
Wreck sprites are deleted in creation order.
Wreck sprites placed in the Map Editor are not deleted.
Set count to 0 for unlimited.
Passing a negative value will be clamped to 0.

See also
getWreckLimit setCorpseLimit getCorpseLimit

int getSkillLevel()
Get the game skill level.

Example
print(getSkillLevel());

See also
setSkillLevel

void setSkillLevel(int level)
Set the game skill level.

Example
// set very hard skill
setSkillLevel(4);

Comments
Valid values are between 0 and 4.
The default (normal) is 2.
Changes to the skill level persist for the entire game and won't full take effect until the the next map is loaded.
In multiplayer only the server can set the skill level.

See also
getSkillLevel

int getTimeLimit()
Get the remaining mission time limit in seconds.

Example
print(getTimeLimit());

See also
setTimeLimit

void setTimeLimit(int level)
Set the mission time remaining in seconds.

Example
// 1 minute to complete the mission
setTimeLimit(60);

Comments
Set to -1 to cancel the time limit.
In multiplayer only the server can set the time limit.

See also
getTimeLimit

vector2 getFlashlightSize()
Get the current player flashlight size.

Example
print(getFlashlightSize());

See also
setFlashlightSize getFlashlightColour setFlashlightColour

void setFlashlightSize(vector2 size)
Change the player flashlight colour.

Example
setFlashlightSize(vector2(100, 100));

See also
getFlashlightSize getFlashlightColour setFlashlightColour

string getFlashlightColour()
Get the current player flashlight size.

Example
print(getFlashlightColour());

Comments
colour is returned as an HTML string (e.g. red = "#ff0000").

See also
setFlashlightSize setFlashlightSize getFlashlightColour setFlashlightColour

void setFlashlightColour(string colour)
Set the player flashlight colour for the duration of the mission.

Example
// blue
setFlashlightColour("#0000ff");

Comments
The colour parameter is passed as an HTML string (e.g. red = "#ff0000").

See also
setFlashlightSize setFlashlightSize getFlashlightColour


Index