Meteor 2 Scripting Functions
Object
int createObject(string objectName, vector2 pos, float angle, uint8 aiType, uint8 side, string overrideName, bool moving, bool locked, bool multiplayerRespawn)
Create an object.
int objectID = createObject(
"Solider_Pvt_Rifle.ob",
vector2(100, 100),
0.0,
AI_ROAMING,
1,
"",
false,
false,
false
);
print("Created object " + objectID);
void deleteObject(int objectID)
Delete an object (server only).
deleteObject(10);
void setHidden(int objectID, bool value)
Set the hidden status of an object.
setHidden(0, true);
bool getHidden(int objectID)
Get the hidden status of an object.
if (getHidden(0))
{
print("Object is hidden");
}
else
{
print("Object is visible");
}
void showTeleport(int objectID)
Perform a teleport effect on an object.
This function:
- Plays a teleport sound effect.
- Shows the object.
- Damages objects underneath the object.
showTeleport(0);
uint8 getSide(int objectID)
Get the side of an object.
uint8 side = getSide(0);
print("Object is on side " + side);
void setSide(int objectID, uint8 side)
Set the side of an object.
setSide(0, 1);
bool getHostile(int objectID)
Determine if an object is hostile/enemy.
float getHits(int objectID)
Get the hits (health) of an object.
float hits = getHits(0);
print("Object has " + hits + " health");
void setHits(int objectID, float hits)
Set the hits (health) of an object.
setHits(0, 500);
bool getIndestructible(int objectID)
Get the indestructible status of an object.
if (getIndestructible(0))
{
print("Object is indestructible");
}
else
{
print("Object is destructible");
}
void setIndestructible(int objectID, bool indestructible)
Set the indestructible status of an object.
setIndestructible(0, true);
float getSpeed(int objectID)
Get the current speed of an object.
float speed = getSpeed(PLAYER_OBJECT);
print("Player is moving at " + metresPerSecond + " km/h");
The speed is returned in kilometres per hour.
void setSpeed(int objectID, float speed)
Set the current speed of an object.
setSpeed(PLAYER_OBJECT, 50.0f);
The speed is expected in kilometres per hour.
float getMaxSpeed(int objectID)
Get the maximum speed of an object.
float maxSpeed = getMaxSpeed(PLAYER_OBJECT);
print("Player maximum speed is " + maxSpeed + " km/h");
The maximum speed is returned in kilometres per hour.
void setMaxSpeed(int objectID, float speed)
Set the maximum speed of an object.
setMaxSpeed(PLAYER_OBJECT, 100.0f);
The maximum speed is expected in kilometres per hour.
float getDefaultMaxSpeed(int objectID)
Get the default maximum speed of an object.
float defaultMaxSpeed = getMaxSpeed(PLAYER_OBJECT);
print("Player default maximum speed is " + defaultMaxSpeed + " km/h");
The default maximum speed is returned in kilometres per hour.
uint8 getAiType(int objectID)
Get the AI type of an object.
uint8 aiType = getAiType(0);
print("Object AI type is " + aiType);
The possible values of aiType are AI_NONE, AI_ROAMING, AI_GUARDING, AI_IDLE and AI_GOTO.
void setAiType(int objectID, uint8 aiType)
Set the AI type of an object.
setAiType(0, AI_GUARDING);
The possible values of aiType are AI_NONE, AI_ROAMING, AI_GUARDING, AI_IDLE and AI_GOTO.
int getWanderChance(int objectID)
Get an object's wander chance (0 to 100).
print(getWanderChance(0));
void setWanderChance(int objectID, int wanderChance)
Set an object's wander chance.
setWanderChance(0, 50);
wanderChance value must be between 0 (never wanders) and 100 (always wanders).
bool getLocked(int objectID)
Get the locked status of an object.
if (getLocked(0))
{
print("Object is locked");
}
else
{
print("Object is unlocked");
}
void setLocked(int objectID, bool locked)
Set the locked status of an object.
setLocked(0, true);
bool getActive(int objectID)
Get the active status of an object.
if (getActive(0))
{
print("Object is active");
}
else
{
print("Object is inactive");
}
bool getForceActive(int objectID)
Get the force active status of an object.
if (getForceActive(0))
{
print("Object is force active");
}
else
{
print("Object is not force active");
}
void setForceActive(int objectID, bool forceActive)
Set the force active status of an object (server only).
setForceActive(0, true);
Setting forceActive prevents an object from sleeping when out of view.
float getWeaponsRange(int objectID)
Get the maximum weapons range of an object.
print(getWeaponsRange(PLAYER_OBJECT));
Returns the longest weapons range of an object in pixels.
If an object has multiple weapons the longest weapon range is returned.
float getSightRange(int objectID)
Get the sight range/distance of an object.
print(getSightRange(PLAYER_OBJECT));
Returns the distance an object can see in pixels.
bool isEnemyNear(int objectID, float maxDistance=-1)
Determine if any enemies are nearby an object.
if (isEnemyNear(PLAYER_OBJECT))
{
print("One or more enemies are nearby");
}
else
{
print("No enemies are nearby");
}
maxDistance is optional (leave blank to use default value).
Similar to isEnemyVisible except without line of sight test.
Underwater enemies are detected.
Range will differ between object types.
bool isEnemyVisible(int objectID)
Determine if an object can see any enemies.
if (isEnemyVisible(PLAYER_OBJECT))
{
print("One or more enemies are visible");
}
else
{
print("No enemies are visible");
}
Underwater enemies are not detected.
bool isTarget(int objectID)
Determine if an object is currently being targeted by an enemy.
if (isTarget(PLAYER_OBJECT))
{
print("Player is being targeted");
}
else
{
print("Player is not being targeted");
}
Does not detect healing by medics or engineers.
This function can be slow and should not be called every frame from onUpdate. Use onTick or check at intervals instead.
bool getNoTarget(int objectID)
Get the no target status of an object.
if (getNoTarget(PLAYER_OBJECT))
{
print("Player cannot be targeted");
}
else
{
print("Player can be targeted");
}
void setNoTarget(int objectID, bool noTarget)
Set the no target status of an object.
setNoTarget(PLAYER_OBJECT, true);
Setting noTarget prevents AI from targeting an object.
bool objectExists(int objectID)
Check if an object exists.
if (objectExists(1))
{
print("Object 1 exists");
}
else
{
print("Object 1 does not exist");
}
int getTypeNumber(int objectID)
Get an object type number from an object ID.
int typeNumber = getTypeNumber(PLAYER_OBJECT);
print("Player is type number " + typeNumber);
Object type numbers are the index of a loaded object type asset. They are local and can differ for each game session.
string getTypeName(int objectID)
Get an object type name from an object ID.
string playerTypeName = getTypeName(PLAYER_OBJECT);
print("Player object type filename: " + playerTypeName);
uint getTypeNameLowerHash(int objectID)
Get an object type lower hash name from an object ID.
uint playerFileHash = getTypeNameLowerHash(PLAYER_OBJECT);
print("Player object type filename lower hash: " + playerFileHash);
int objectTypeNameToNumber(string objectTypeName)
Resolve an object type name to an object type number.
int typeNumber = objectTypeNameToNumber("hoverboard.ob");
print("Hoverboard is type number " + typeNumber);
string objectTypeNumberToName(int objectTypeNumber)
Resolve an object type number to an object type name.
string typeName = objectTypeNumberToName(1);
print(typeName);
void setFollow(int objectID, int objectToFollowID)
Set an object to follow another object (server only).
setFollow(0, 1);
Set objectToFollowID to -1 to stop following.
bool isOverWater(int objectID)
Is an object over water?
print(isOverWater(PLAYER_OBJECT));
bool isSwimming(int objectID)
Is an object swimming?
print(isSwimming(PLAYER_OBJECT));
Only applies to human objects.
bool isMoving(int objectID)
Is an object moving?
print(isMoving(PLAYER_OBJECT));
void getHasWetsuit(bool hasWetsuit)
Determine if the specified unit has a wetsuit.
bool playerHasWetsuit = getHasWetsuit(PLAYER_OBJECT);
print("playerHasWetsuit = " + playerHasWetsuit);
void setHasWetsuit(bool hasWetsuit)
Give or take wetsuit from the specified unit.
setHasWetsuit(PLAYER_OBJECT, true);
print("playerHasWetsuit = " + getHasWetsuit(PLAYER_OBJECT));
Server only.
Works for any unit or player.
void resetRespawnCoords(int objectID)
Update the respawn coordinates of an object to it's current coordinates (server only).
resetRespawnCoords(0);
string getDisplayName(int objectID)
Get the display name of an object.
string displayName = getDisplayName(PLAYER_OBJECT);
print("Player display name is " + displayName);
vector2 getTypeSize(string resourceName)
Get the size of an object type in pixels.
vector2 carSize = getTypeSize("Car01.ob");
print("Non-rotated size = " + carSize);
vector2 carMaxRotatedSize = carSize * 1.41;
print("Max rotated size = " + carMaxRotatedSize);
An "object type" is a type of object not an actual object instance so no existing object is required.
Returned size is simply the still sprite size without rotation.
bool getInteractionEnabled(int objectID)
Get whether interaction is enabled for an object.
if (getInteractionEnabled(0))
{
print("Object is interactable");
}
else
{
print("Object is not interactable");
}
An object without interaction cannot be controlled with group control.
void getInteractionEnabled(int objectID, bool interactionEnabled)
Set whether interaction is enabled for an object.
setInteractionEnabled(0, false);
An object without interaction cannot be controlled with group control.
bool getPaintEnabled(int objectID)
Determine if paint is enabled for an object.
if(getPaintEnabled(PLAYER_OBJECT))
print("Player object paint is enabled");
else
print("Player object paint is disabled");
void setPaintEnabled(int objectID, string paintColour)
Enable or disable paint for an object (server only).
setPaintEnabled(PLAYER_OBJECT, false);
string getPaintColour(int objectID)
Get the paint colour of an object.
print("Object ID 0 is " + getPaintColour(0));
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).
void setPaintColour(int objectID, string paintColour)
Set the paint colour of an object (server only).
setPaintColour(0, "#FF0000");
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).
string getPaintTexture(int objectID)
Get the paint texture of an object.
print("Player paint texture is " + getPaintTexture(PLAYER_OBJECT));
void setPaintTexture(int objectID, string textureName)
Set the paint texture of an object (server only).
setPaintTexture(PLAYER_OBJECT, "MTP_Urban01");
setPaintColour(PLAYER_OBJECT, "#FFFFFF");
float getPaintTextureScale(int objectID)
Get the paint texture scale of an object.
print("Player paint texture scale is " + getPaintTextureScale(PLAYER_OBJECT));
void setPaintTextureScale(int objectID, float scale)
Set the paint texture of an object (server only).
setPaintTextureScale(PLAYER_OBJECT, 0.1);
void attachObject(int objectID, int parentID, vector2 offset)
Attach an object to another object.
attachObject(10, getLocalPlayerObject(), vector2(0,0));
Attached objects have no physics.
Objects cannot be attached to already attached objects.
void detachObject(int objectID)
Detach an attached object from it's parent.
detachObject(10);
array getAttachedObjects(int parentID)
Get a list of object IDs that are attached to the specified parent object.
array<int> objectIDs = getAttachedObjects(getLocalPlayerObject());
for (uint i = 0; i < objectIDs.length(); i++)
{
print(objectIDs[i]);
}
int getAttachedToParent(int objectID)
Get an attached object's parent object ID.
int parentObjectID = getAttachedToParent(10);
print(parentObjectID);
Returns -1 if not attached to a parent object.
Index