Meteor 2 Scripting Functions
Sprite
int createSprite(string spriteTypeName, vector2 pos, uint8 side)
Create a map sprite (server only).

Example
int spriteID = createSprite("objects\\arrow.spr", getPos(PLAYER_OBJECT), 0, 0);
print("Created sprite ID " + spriteID);

See also
deleteSprite

void deleteSprite(int spriteID)
Delete a map sprite (server only).

Example
// create an arrow sprite
int sprite = createSprite("objects\\arrow.spr", getPos(PLAYER_OBJECT), 0, 0);

// immediately delete the sprite
deleteSprite(sprite);

See also
createSprite

vector2 getSpritePos(int spriteID)
Get a map sprite position (in pixels).

Example
print(getSpritePos(1));

See also
setSpritePos

void setSpritePos(int spriteID, vector2 pos)
Set a map sprite position (server only).

Example
setSpritePos(1, getPos(PLAYER_OBJECT));

See also
getSpritePos

float getSpriteAngle(int spriteID)
Get a map sprite angle (in degrees).

Example
print(getSpriteAngle(1));

See also
setSpriteAngle

void setSpriteAngle(int spriteID, float angle)
Set a map sprite angle (server only).

Example
setSpriteAngle(1, 45);

See also
getSpriteAngle

bool getSpriteHidden(int spriteID)
Get sprite hidden status.

Example
print(getSpriteHidden(1));

See also
setSpriteHidden

void setSpriteHidden(int spriteID, bool hidden)
Show or hide a sprite.

Example
// hide sprite ID 1
setSpriteHidden(1, true);

See also
getSpriteHidden

float getSpriteLifetime(int spriteID)
Get a sprite's remaining lifetime (server only).

Example
print(getSpriteLifetime(1));

Comments
lifetime is in seconds (0 for no lifetime specified).

See also
setSpriteLifetime

void setSpriteLifetime(int spriteID, bool hidden)
Set a sprite's remaining lifetime in seconds (server only).

Example
// create an arrow sprite
int sprite = createSprite("objects\\arrow.spr", getPos(PLAYER_OBJECT), 0, 0);

// Delete the sprite in 5.25 seconds
setSpriteLifetime(sprite, 5.25);

Comments
Set lifetime to 0 to not automatically delete.
Note that wrecks and corpses are deleted automatically once map limits are reached.

See also
getSpriteLifetime

string getPaintColour(int spriteID)
Get the paint colour of a sprite.

Example
print("Sprite ID 0 is " + getSpritePaintColour(0));

Comments
paintColour is specfified in HTML style ("#RRGGBB" hex values), colours may also contain 2 additional optional characters for alpha (e.g. "#FFFFFF80" is transparent white).

See also
setSpritePaintColour

void setSpritePaintColour(int spriteID, string paintColour)
Set the paint colour of a sprite.

Example
// Set paint colour of sprite ID 0 to red
setSpritePaintColour(0, "#FF0000");

Comments
paintColour is specfified in HTML style ("#RRGGBB" hex values), colours may also contain 2 additional optional characters for alpha (e.g. "#FFFFFF80" is transparent white).

See also
getSpritePaintColour

bool spriteExists(int spriteID)
Check if a map sprite exists.

Example
if (spriteExists(1))
{
    print("Sprite 1 exists");
}
else
{
    print("Sprite 1 does not exist");
}

int getSpriteTypeNumber(int spriteID)
Get a sprite type number from a map sprite ID.

Example
int spriteTypeNumber = getSpriteTypeNumber(1);
print("Map sprite ID 1 is sprite type number " + spriteTypeNumber);

Comments
Sprite type numbers are the index of a loaded sprite asset. They are local and can differ for each game session.

See also
getSpriteTypeName getSpriteTypeNameLowerHash

string getSpriteTypeName(int spriteID)
Get a sprite type name from a map sprite ID.

Example
string spriteTypeName = getSpriteTypeName(1);
print("Sprite ID 1 type name is " + spriteTypeName);

See also
getSpriteTypeNumber getSpriteTypeNameLowerHash

uint getSpriteTypeNameLowerHash(int spriteID)
Get a sprite type name lower case hash from a map sprite ID.

Example
uint spriteTypeNameHash = getSpriteTypeNameLowerHash(1);
print("Sprite ID 1 type name hash is " + spriteTypeNameHash);

See also
getSpriteTypeNumber getSpriteTypeName

string spriteTypeNumberToName(int spriteTypeNumber)
Resolve a sprite type number to a sprite type name.

Example
string typeName = spriteTypeNumberToName(10);
print("Sprite type number 10 type name is " + typeName);

See also
getSpriteTypeNameNumber

int spriteTypeNameToNumber(string spriteTypeName)
Get a sprite type number from a sprite type name.

Example
int spriteTypeNumber = spriteTypeNameToNumber("objects\\arrow.spr");
print("Sprite type number " + spriteTypeNumber);

See also
spriteTypeNumberToName


Index