Meteor 2 Scripting Functions
System
int getScriptPlayerID()
Get the player ID that instigated the current script code.

Comments
Returns -1 if no player ID was found.
This function is intended for trigger based code (e.g. sector triggers and trigger boxes) and it not reliable events (where the script player is always local).

See also
getScriptPlayerNumber getScriptPlayerObject netExec gameMessage

int getScriptPlayerNumber()
Get the player index that instigated the current script code.

Comments
Player number is an index not an ID.
Return can be invalid so check is at least 0 and less than players count.
This function is intended for trigger based code (e.g. sector triggers and trigger boxes) and it not reliable events (where the script player is always local).

See also
getScriptPlayerID getScriptPlayerObject

int getScriptPlayerObject()
Get the object for the player that instigated the current script code.

Comments
Returns -1 if player or object is not found.
This function is intended for trigger based code (e.g. sector triggers and trigger boxes) and it not reliable events (where the script player is always local).

See also
getScriptPlayerNumber getScriptPlayerID

void passToConsole(string text)
Run console command.

Example
passToConsole("god");
passToConsole("teleport");
passToConsole("nt");
passToConsole("giveitem all");

bool isGamePaused()
Check whether the game is paused.

Example
if (isGamePaused())
{
    print("The game is paused!");
}

See also
gameHasFocus playerHasControl

bool gameHasFocus()
Check whether the game is focused.

Example
if (gameHasFocus())
{
    print("The game has focus");
}
else
{
    print("The game does not have focus");
}

Comments
Game has focus if no menus or dialogs are open and the game is not paused.

See also
isGamePaused playerHasControl

bool playerHasControl()
Check whether the local player currently has control.

Example
if (playerHasControl())
{
    print("Player has control");
}
else
{
    print("Player does not have control");
}

Comments
Player has control if the screen is not fading and is not showing cinematic movie bars.

See also
isGamePaused gameHasFocus fade setCinematicBarsEnabled

float getElapsedTime()
Gets the time, in seconds, since the mission started.

Example
print("It has been " + getElapsedTime() + " seconds since the mission started.");

void saveGameVar(string varName, variant value)
Sasve a game variable to a saved game file.
Only works within onGameSave() event.

Comments
Supported types are int, float, bool, string and vector2.

See also
loadGameVar onGameSave onGameLoad

variant loadGameVar(string varName, variant defaultValue)
Load a game variable from a saved game file.
Only works within onGameLoad() event.

Comments
defaultValue is optional. If not specfied then numbers are 0 and bool is false etc.

See also
saveGameVar onGameSave onGameLoad


Index