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 (server only).

Example
int objectID = createObject(
    "Soldier_Pvt_Rifle.ob",
    vector2(100, 100),
    0.0,
    AI_ROAMING,
    1,
    "",
    false,
    false,
    false
);
print("Created object " + objectID);

Comments
Pass angle as -1 to assign a random angle

See also
deleteObject getSide

void deleteObject(int objectID)
Delete an object (server only).

Example
// Delete object ID 10
deleteObject(10);

See also
moveAwayVanish createObject

void moveAwayVanish(int objectID)
Tell an object to move away before being deleted when out of sight (server only).

Example
// Delete object ID 10 once it has moved out of sight (or becomes out of sight)
moveAwayVanish(10);

See also
deleteObject

bool getHidden(int objectID)
Get the hidden status of an object.

Example
if (getHidden(0))
{
    print("Object is hidden");
}
else
{
    print("Object is visible");
}

See also
setHidden

void setHidden(int objectID, bool value)
Set the hidden status of an object.

Example
// Hide object ID 0
setHidden(0, true);

Comments
Works from server and client.

See also
getHidden

bool getSimulate(int objectID)
Get the simulate status of an object.

Example
if (getSimulate(0))
{
    print("Object is not simulated");
}
else
{
    print("Object is simulated");
}

See also
setSimulate

void setSimulate(int objectID, bool simulate)
Start or stop simulating an object.

Example
// Stop simulating object ID 0
setSimulate(0, faalse);

Comments
Works from server and client.
Objects with simulate set to false do nothing and have no physics.

See also
getSimulate

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.

Example
showTeleport(0);

uint8 getSide(int objectID)
Get the side of an object.

Example
uint8 side = getSide(0);
print("Object is on side " + side);

See also
setSide setSideID getHostile

void setSide(int objectID, uint8 side)
Set the side of an object.

Example
// Set object ID 0 to side 1
setSide(0, 1);

See also
getSide setSideID

bool getHostile(int objectID)
Determine if an object is hostile/enemy.

See also
getSide

float getHits(int objectID)
Get the hits (health) of an object.

Example
float hits = getHits(0);
print("Object has " + hits + " health");

See also
setHits getMaxHits

void setHits(int objectID, float hits)
Set the hits (health) of an object.

Example
setHits(0, 500);

Comments
Works from server and client.

See also
getHits

float getMaxHits(int objectID)
Get the maximum hits (hp) of an object.

Example
float hp = getMaxHits(0);
print("Object has " + hp + " max hits");

See also
getHits getArmour

float getArmour(int objectID)
Get the armour of an object in the range (0 to 90).

Example
float amour = getArmour(0);
print("Object has " + armour + " armour");

Comments
Armour is returned in the range 0 to 90. The result could be normalised by dividing by 100.

See also
getMaxHits

bool getIndestructible(int objectID)
Get the indestructible status of an object.

Example
if (getIndestructible(0))
{
    print("Object is indestructible");
}
else
{
    print("Object is destructible");
}

See also
setIndestructible

void setIndestructible(int objectID, bool indestructible)
Set the indestructible status of an object.

Example
// Make object ID 0 indestructible
setIndestructible(0, true);

Comments
Can be called from server or client.

See also
getIndestructible

void damageObject(int objectID, float damage, float armourPenetration, int ownerID=-1)
Damage an object.

Example
// Damage player
damageObject(PLAYER_OBJECT, 10, 0);

Comments
Can be called from server or client.

See also
getIndestructible setIndestructible

float getSpeed(int objectID)
Get the current speed of an object.

Example
float speed = getSpeed(PLAYER_OBJECT);
print("Player is moving at " + speed + " km/h");

Comments
The speed is returned in kilometres per hour.

See also
setMaxSpeed getMaxSpeed

float getMaxSpeed(int objectID)
Get the maximum speed of an object.

Example
float maxSpeed = getMaxSpeed(PLAYER_OBJECT);
print("Player maximum speed is " + maxSpeed + " km/h");

Comments
The maximum speed is returned in kilometres per hour.

See also
setMaxSpeed getDefaultMaxSpeed

void setMaxSpeed(int objectID, float speed)
Set the maximum speed of an object.

Example
// Set the player maximum speed to 100 km/h
setMaxSpeed(PLAYER_OBJECT, 100.0f);

Comments
The maximum speed is expected in kilometres per hour.

See also
getMaxSpeed getDefaultMaxSpeed

float getDefaultMaxSpeed(int objectID)
Get the default maximum speed of an object.

Example
float defaultMaxSpeed = getDefaultMaxSpeed(PLAYER_OBJECT);
print("Player default maximum speed is " + defaultMaxSpeed + " km/h");

Comments
The default maximum speed is returned in kilometres per hour.

See also
getMaxSpeed

uint8 getAiType(int objectID)
Get the AI type of an object.

Example
uint8 aiType = getAiType(0);
print("Object AI type is " + aiType);

Comments
The possible values of aiType are AI_NONE, AI_ROAMING, AI_GUARDING, AI_IDLE and AI_GOTO.

See also
setAiType

void setAiType(int objectID, uint8 aiType)
Set the AI type of an object.

Example
setAiType(0, AI_GUARDING);

Comments
The possible values of aiType are AI_NONE, AI_ROAMING, AI_GUARDING, AI_IDLE and AI_GOTO.
Setting the AI type of a vehicle will also update all of its occupants.

See also
getAiType moveTo

void moveTo(int objectID, vector destPos, int destAiType=AI_GUARDING)
Tell an object to move to a position.

Example
// tell object ID 1 to move to position 100,100
moveTo(1, vector2(100,100));

Comments
Objects will need to be able to move (e.g. a route must exist for ground/sea units and vehicle units must have a driver)

See also
setAiType onMoveToComplete

int getWanderChance(int objectID)
Get an object's wander chance (0 to 100).

Example
print(getWanderChance(0));

See also
setWanderChance

void setWanderChance(int objectID, int wanderChance)
Set an object's wander chance.

Example
setWanderChance(0, 50);

Comments
wanderChance value must be between 0 (never wanders) and 100 (always wanders).

See also
getWanderChance

float getWanderDistance(int objectID)
Get how far an object can wander from it's home position.

Example
print(getWanderDistance(0));

See also
setWanderDistance getHomePos setHomePos

void setWanderDistance(int objectID, float wanderDistance)
Set how far an object can wander from it's home position.

Example 1
// wander up to 20 metres
setWanderDistance(0, metresToPixels(20));

Example 2
// wander an unlimited distance
setWanderDistance(0, -1);

Comments
wanderDistance is in pixels.
A wanderDistance of -1 is unlimited.

See also
getWanderDistance getHomePos setHomePos

vector2 getHomePos(int objectID)
Get an object's home position.

Example
print(getHomePos(0));

See also
setHomePos getWanderDistance setWanderDistance

void setHomePos(int objectID, vector2 homePos)
Set an object's home position.

Example
setHomePos(0, vector2(100,100));

See also
getHomePos getWanderDistance setWanderDistance

bool getLocked(int objectID)
Get the locked status of an object.

Example
if (getLocked(0))
{
    print("Object is locked");
}
else
{
    print("Object is unlocked");
}

See also
setLocked

void setLocked(int objectID, bool locked)
Set the locked status of an object.

Example
setLocked(0, true);

Comments
Locked vehicles cannot be used by players.
Can be called from server or client.

See also
getLocked

bool getActive(int objectID)
Get the active status of an object.

Example
if (getActive(0))
{
    print("Object is active");
}
else
{
    print("Object is inactive");
}

See also
getForceActive setForceActive

bool getForceActive(int objectID)
Get the force active status of an object.

Example
if (getForceActive(0))
{
    print("Object is force active");
}
else
{
    print("Object is not force active");
}

See also
setForceActive getActive

void setForceActive(int objectID, bool forceActive)
Set the force active status of an object (server only).

Example
setForceActive(0, true);

Comments
Setting forceActive prevents an object from sleeping when out of view.

See also
getForceActive getActive

float getWeaponsRange(int objectID)
Get the maximum weapons range of an object.

Example
print(getWeaponsRange(PLAYER_OBJECT));

Comments
Returns the longest weapons range of an object in pixels.
If an object has multiple weapons the longest weapon range is returned.

See also
getSightRange

float getSightRange(int objectID)
Get the sight range/distance of an object.

Example
print(getSightRange(PLAYER_OBJECT));

Comments
Returns the distance an object can see in pixels.

See also
getWeaponsRange

bool isEnemyNear(int objectID, float maxDistance=-1)
Determine if any enemies are nearby an object.

Example
if (isEnemyNear(PLAYER_OBJECT))
{
    print("One or more enemies are nearby");
}
else
{
    print("No enemies are nearby");
}

Comments
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.

See also
isEnemyVisible

bool isEnemyVisible(int objectID)
Determine if an object can see any enemies.

Example
if (isEnemyVisible(PLAYER_OBJECT))
{
    print("One or more enemies are visible");
}
else
{
    print("No enemies are visible");
}

Comments
Underwater enemies are not detected.

See also
isEnemyNear

int getTarget(int objectID)
Get enemy that this object is currently targeting.

Example
print(getTarget(100));

Comments
Returns -1 if there if there is no current target.

See also
isTarget getTargetingObjects getNoTarget setNoTarget

bool isTarget(int objectID)
Determine if an object is currently being targeted by an enemy.

Example
if (isTarget(PLAYER_OBJECT))
{
    print("Player is being targeted");
}
else
{
    print("Player is not being targeted");
}

Comments
Does not detect healing by medics or engineers.
This function can be slow and should not be called every frame from onUpdate etc. Use onTick or check at intervals instead.

See also
getTarget getTargetingObjects getNoTarget setNoTarget

array<int> getTargetingObjects(int targetObjectID, bool firingOnly)
Get all objects currently targeting an object.

Example
// show all objects targeting player
array<int> objects = getTargetingObjects(PLAYER_VEHICLE);
for(uint i=0; i<objects.length(); i++)
{
    print(objects[i] + ": " + getDisplayName(objects[i]));
}

Comments
This function can be slow and should not be called every frame from onUpdate etc. Use onTick or check at intervals instead.
Set firingOnly to true to only get objects that are engaging the target.

See also
getTarget isTarget

bool getNoTarget(int objectID)
Get the no target status of an object.

Example
if (getNoTarget(PLAYER_OBJECT))
{
    print("Player cannot be targeted");
}
else
{
    print("Player can be targeted");
}

Comments
Works from server and client.

See also
setNoTarget isTarget getHoldFire setHoldFore

void setNoTarget(int objectID, bool noTarget)
Set the no target status of an object.

Example
setNoTarget(PLAYER_OBJECT, true);

Comments
Setting noTarget prevents an object from being targeted by other other objects.
Works from server and client.

See also
getNoTarget isTarget getHoldFire setHoldFore

bool getHoldFire(int objectID)
Get the hold fire status of an object.

Example
if (getHoldFire(10))
{
    print("Object 10 is holding fire");
}
else
{
    print("Object 10 can engage");
}

Comments
Works from server and client.

See also
setHoldFire getNoTarget setNoTarget

void setHoldFire(int objectID, bool holdFire)
Set the hold fire status of an object.

Example
// tell object 10 to hold fire
setHoldFire(10, true);

Comments
Setting holdFire prevents an object from targeting other objects.
Works from server and client.

See also
getHoldFire getNoTarget setNoTarget

void getUnitHasFlashlight(bool hasFlashlight)
Determine if the specified unit has a flashlight.

Example
bool playerHasFlashlight = getUnitHasFlashlight(PLAYER_OBJECT);
print("playerHasFlashlight = " + playerHasFlashlight);

See also
setUnitHasFlashlight getFlashlightOn setFlashlightOn

void setUnitHasFlashlight(bool hasFlashlight)
Give or take a flashlight from the specified unit.

Example
// give player flashlight
setUnitHasFlashlight(PLAYER_OBJECT, true);
print("playerHasFlashlight = " + getUnitHasFlashlight(PLAYER_OBJECT));

Comments
Server only.
Works for any unit or player.

See also
getUnitHasFlashlight getFlashlightOn setFlashlightOn

bool getFlashlightOn(int objectID)
Determine if a unit's flashlight is on.

Example
// show player flashlight status
print(getFlashlightOn(PLAYER_VEHICLE));

See also
setFlashlightOn getUnitHasFlashlight setUnitHasFlashlight

void setFlashlightOn(int objectID, bool on)
Switch a unit's flashlight on or off.

Example
// switch player flashlight on
setFlashlightOn(PLAYER_OBJECT, true);

Comments
Can be called from server or client.

See also
getFlashlightOn getUnitHasFlashlight setUnitHasFlashlight

bool getLightMountEnabled(int objectID, int mountIndex)
Get the local enabled status of an object light mount (local only).

Example
// get the local enabled status of the first light for the current player vehicle
print(getLightMountEnabled(PLAYER_VEHICLE, 0));

Comments
Light mounts enabled are local only (not network synced).
mountIndex is zero based.

See also
setLightMountEnabled

void setLightMountEnabled(int objectID, int mountIndex, bool enabled)
Set the local enabled status of an object light mount (local only).

Example
// Locally disable the first light for current player vehicle
setLightMountEnabled(PLAYER_VEHICLE, 0, false);

Comments
Only affects light mounts locally (not network synced).
mountIndex is zero based.

See also
getLightMountEnabled

int getDrawOrder(int objectID)
Get the draw order of an object.

Example
print(getDrawOrder(1));

See also
setDrawOrder getOriginalDrawOrder setOriginalDrawOrder

void setDrawOrder(int objectID, int drawOrder)
Manually set the draw order of an object (server and clients).

Example
setDrawOrder(1, 0);

Comments
Note: Draw orders can be swapped automatically but are normally swapped back later (e.g. when getting on and then off a Rocket Bike).
Note: Draw orders can be shuffled up and down as objects are added and removed (they normally remain relative to each other).
Changing the draw order only affects an object's layer (e.g. the player cannot appear under drain cover because that is on a different layer).
Flat objects (e.g. drain covers) have a negative draw order.
Changes are automatically network synced, this function can be called from the server or clients.
Use the drawOrders console command to view all objects draw orders on screen during the game.

See also
getDrawOrder getOriginalDrawOrder setOriginalDrawOrder

int getOriginalDrawOrder(int objectID)
Get the original/initial draw order of an object.

Example
print(getOriginalDrawOrder(1));

See also
setOriginalDrawOrder getDrawOrder setDrawOrder

void setOriginalDrawOrder(int objectID, int originalDrawOrder)
Manually override the original/initial draw order of an object (server and clients).

Example
setOriginalDrawOrder(1, 0);

Comments
Changes are automatically network synced, this function can be called from the server or clients.

See also
getOriginalDrawOrder getDrawOrder setDrawOrder

bool objectExists(int objectID)
Check if an object exists.

Example
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.

Example
int typeNumber = getTypeNumber(PLAYER_VEHICLE);
print("Player vehicle is type number " + typeNumber);

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

See also
getTypeNameNumber getTypeName

string getTypeName(int objectID)
Get an object type name from an object ID.

Example
string playerVehicleTypeName = getTypeName(PLAYER_VEHICLE);
print("Player vehicle object type filename: " + playerVehicleTypeName);

See also
getTypeNumber getTypeNameLowerHash

uint getTypeNameLowerHash(int objectID)
Get an object type lower hash name from an object ID.

Example
uint playerVehicleFileHash = getTypeNameLowerHash(PLAYER_VEHICLE);
print("Player vehicle object type filename lower hash: " + playerVehicleFileHash);

See also
getTypeNumber getTypeName

int objectTypeNameToNumber(string objectTypeName)
Resolve an object type name to an object type number.

Example
int typeNumber = objectTypeNameToNumber("hoverboard.ob");
print("Hoverboard is type number " + typeNumber);

See also
objectTypeNumberToName

string objectTypeNumberToName(int objectTypeNumber)
Resolve an object type number to an object type name.

Example
string typeName = objectTypeNumberToName(1);
print(typeName);

See also
objectTypeNameToNumber

string getClassName(int objectID)
Get the class name for an object (e.g. "Car" or "Helicopter")

Example
string className = getClassName(1);
print(typeName);

See also
getClassLowerHash getTypeClassName

uint getTypeClassLowerHash(int objectID)
Get an object class name lower hash from an object ID.

Example
uint classHash = getTypeClassLowerHash(1);
print(classHash);

See also
getClassName getTypeClassName

string getTypeClassName(string resourceName)
Get the class name of an object type.

Example
string className = getTypeClassName("Car01.ob");
print(className); // Car

Comments
An "object type" is a type of object not an actual object instance so no existing object is required.

See also
getClassName getClassLowerHash

void setFollow(int objectID, int leaderID)
Set an object to follow another object.

Example
// Make object ID 0 follow object ID 1
setFollow(0, 1);

Comments
Set objectToFollowID to -1 to stop following.

array getFollowingObjects(int leaderID)
Get list object IDs that are following the specified object (leader).

Example
// print object IDs following player
array<int> objectIDs = getFollowingObjects(PLAYER_OBJECT);
for (uint i = 0; i < objectIDs.length(); i++)
{
    print(objectIDs[i]);
}

See also
setFollow getLeader

void getLeader(int objectID)
Get the leading object being followed by the specified object.

Example
print(getLeader(1));

Comments
Returns -1 if not following an object.

See also
setFollow getFollowingObjects

bool isOverWater(int objectID)
Is an object entirely over water?

Example
print(isOverWater(PLAYER_OBJECT));

Comments
Entirely all 4 corners and the centre of the object are over water.

See also
isSwimming isUnderwater isSubmerged getOverWaterScore

float getOverWaterScore(int objectID)
Get an object over water score.

Example
print(getOverWaterScore(PLAYER_OBJECT));

Comments
Result is between 0 and 1 and depends on how much the object is over water. For example: 0 is not in water, 0.5 is half in water and 1 is entirely in water.

See also
isOverWater isSwimming isUnderwater isSubmerged

bool isSwimming(int objectID)
Is an object swimming?

Example
print(isSwimming(PLAYER_OBJECT));

Comments
Only applies to human objects.

See also
isOverWater isUnderwater isSubmerged getSwimmingEnabled setSwimmingEnabled

bool isUnderwater(int objectID)
Is an object underwater?

Example
print(isUnderwater(PLAYER_OBJECT));

Comments
Does not apply to submerged vehicles. Use isSubmerged to detect if a vehicle is submerged.

See also
isOverWater isSwimming isSubmerged getSwimmingEnabled setSwimmingEnabled

bool isSubmerged(int objectID)
Is an object submerged?

Example
print(isSubmerged(PLAYER_VEHICLE));

Comments
Only applies to vehicles.

See also
isOverWater isSwimming isUnderwater getSwimmingEnabled setSwimmingEnabled

bool isMoving(int objectID)
Is an object moving?

Example
print(isMoving(PLAYER_OBJECT));

void getHasWetsuit(bool hasWetsuit)
Determine if the specified unit has a wetsuit.

Example
bool playerHasWetsuit = getHasWetsuit(PLAYER_OBJECT);
print("playerHasWetsuit = " + playerHasWetsuit);

See also
setHasWetsuit

void setHasWetsuit(bool hasWetsuit)
Give or take wetsuit from the specified unit.

Example
// give player wetsuit
setHasWetsuit(PLAYER_OBJECT, true);
print("playerHasWetsuit = " + getHasWetsuit(PLAYER_OBJECT));

Comments
Server only.
Works for any unit or player.

See also
getHasWetsuit

void resetRespawnCoords(int objectID)
Update the respawn coordinates of an object to it's current coordinates (server only).

Example
resetRespawnCoords(0);

string getDisplayName(int objectID)
Get the display name of an object.

Example
string displayName = getDisplayName(PLAYER_VEHICLE);
print("Player vehicle display name is " + displayName);

Comments
This function will return the callsign/override name if present otherwise the description is returned. To get the description name in all cases use getDescription().

See also
getDescription getPlayerName

string getDescription(int objectID)
Get the description of an object.

Example
string desc = getDisplayName(PLAYER_VEHICLE);
print("Player vehicle description is " + desc);

Comments
This function will return the object description of the object as specified in the Object Editor (e.g. "Rocket Soldier" or "Tank");

See also
getDisplayName

vector2 getTypeSize(string resourceName)
Get the size of an object type in pixels.

Example
// show non-rotated image size and largest rotated bounds size of Car01.ob
vector2 carSize = getTypeSize("Car01.ob");
print("Non-rotated size = " + carSize);
vector2 carMaxRotatedSize = carSize * 1.41;
print("Max rotated size = " + carMaxRotatedSize);

Comments
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.

Example
if (getInteractionEnabled(0))
{
    print("Object is interactable");
}
else
{
    print("Object is not interactable");
}

Comments
An object without interaction cannot be controlled with group control.

See also
setInteractionEnabled

void setInteractionEnabled(int objectID, bool interactionEnabled)
Set whether interaction is enabled for an object.

Example
// Disable interaction for object ID 0
setInteractionEnabled(0, false);

Comments
An object without interaction cannot be controlled with group control.
Can be called from server or client.

See also
getInteractionEnabled

bool getMultiplayerRespawnEnabled(int objectID)
Get whether an object respawns in multiplayer.

Example
if (getMultiplayerRespawnEnabled(0))
{
    print("Object respawns in multiplayer");
}
else
{
    print("Object does not respawn in multiplayer");
}

See also
setMultiplayerRespawnEnabled

void setMultiplayerRespawnEnabled(int objectID, bool multiplayerRespawnEnabled)
Set whether an object respawns in multiplayer. (server only)

Example
// Enable multiplayer respawn for object ID 0
setMultiplayerRespawnEnabled(0, true);

Comments
The object must have an AI type of AI_NONE to enable multiplayer respawn.

See also
getMultiplayerRespawnEnabled

bool isLocal(int objectID)
Determine if an object is local.

Example
if(isLocal(123))
    print("Object is local");
else
    print("Object is not local");

Comments
AI objects are local to the server.

bool getPaintEnabled(int objectID)
Determine if paint is enabled for an object.

Example
if(getPaintEnabled(PLAYER_OBJECT))
    print("Player object paint is enabled");
else
    print("Player object paint is disabled");

See also
setPaintEnabled

void setPaintEnabled(int objectID, bool enabled)
Enable or disable paint for an object.

Example
// Disable painting for player object
setPaintEnabled(PLAYER_OBJECT, false);

Comments
Can be called from server or client.

See also
getPaintEnabled

string getPaintColour(int objectID)
Get the paint colour of an object.

Example
print("Object ID 0 is " + getPaintColour(0));

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

See also
setPaintColour

void setPaintColour(int objectID, string paintColour)
Set the paint colour of an object.

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

Comments
paintColour is specified in HTML style ("#RRGGBB" hex values), colours may also contain 2 additional optional characters for alpha (e.g. "#FFFFFF80" is transparent white).
Can be called from server or client.

See also
getPaintColour

string getPaintTexture(int objectID)
Get the paint texture of an object.

Example
print("Player paint texture is " + getPaintTexture(PLAYER_OBJECT));

See also
setPaintTexture

void setPaintTexture(int objectID, string textureName)
Set the paint texture of an object.

Example
// Change player paint texture to urban camouflage
setPaintTexture(PLAYER_OBJECT, "MTP_Urban01");

// also change colour to white so texture renders untinted
setPaintColour(PLAYER_OBJECT, "#FFFFFF");

Comments
Can be called from server or client.

See also
getPaintTexture

float getPaintTextureScale(int objectID)
Get the paint texture scale of an object.

Example
print("Player paint texture scale is " + getPaintTextureScale(PLAYER_OBJECT));

See also
setPaintTextureScale

void setPaintTextureScale(int objectID, float scale)
Set the paint texture scale of an object.

Example
// scale player paint texture to 0.1
setPaintTextureScale(PLAYER_OBJECT, 0.1);

Comments
Can be called from server or client.

See also
getPaintTextureScale

void attachObject(int objectID, int parentID, vector2 offset, float offsetAngle)
Attach an object to another object (server and clients).

Example
// attach object ID 10 to player
attachObject(10, PLAYER_OBJECT, vector2(0,0), 0);

Comments
Attached objects have no physics.
Objects cannot be attached to already attached objects.

See also
detachObject getAttachedObjects getAttachedToParent

void detachObject(int objectID)
Detach an attached object from it's parent (server and clients).

Example
// detach object ID 10 from it's parent
detachObject(10);

Comments


See also
attachObject getAttachedObjects getAttachedToParent

array getAttachedObjects(int parentID)
Get a list of object IDs that are attached to the specified parent object (server and clients).

Example
// print object IDs attached to player
array<int> objectIDs = getAttachedObjects(PLAYER_OBJECT);
for (uint i = 0; i < objectIDs.length(); i++)
{
    print(objectIDs[i]);
}

See also
attachObject detachObject getAttachedToParent

int getAttachedToParent(int objectID)
Get an attached object's parent object ID.

Example
// print parent object ID for object ID 10
int parentObjectID = getAttachedToParent(10);
print(parentObjectID);

Comments
Returns -1 if not attached to a parent object.

See also
attachObject detachObject getAttachedObjects

bool getIsVivTransport(int objectID)
Determine if an object is a vehicle in vehicle (VIV) transport (e.g. LCVP boat).

Example
bool isViv = getIsVivTransport(PLAYER_VEHICLE);
if(isViv)
    print("Vehicle can carry other vehicles");
else
    print("Vehicle cannot carry other vehicles");

Comments
Essentially checks if "VIV Attach" object type helper exists.

See also
getVivObject getVivParent vivLoad vivUnload

int getVivObject(int parentID)
Get the object currently loaded onto the specified VIV transport vehicle.

Example
bool vivChildID = getVivObject(PLAYER_VEHICLE);
if(vivChildID != -1)
    print("Object " + vivChildID + " is loaded on the vehicle");
else
    print("No object is loaded onto the vehicle");            

Comments
Returns -1 is no object is loaded onto the vehicle.
Remote computers can take a few moments to show changes from loading/unloading.

See also
getIsVivTransport getVivParent vivLoad vivUnload

int getVivParent(int objectID)
Get the VIV transport vehicle that the specified object is loaded onto

Example
bool vivParentID = getVivParent(PLAYER_VEHICLE);
if(vivParentID != -1)
    print("Vehicle is loaded onto parent vehicle " + vivParentID);
else
    print("Vehicle is not loaded onto another vehicle");            

Comments
Returns -1 is not loaded onto a parent vehicle.
Remote computers can take a few moments to show changes from loading/unloading.

See also
getIsVivTransport getVivObject vivLoad vivUnload

void vivLoad(int objectID, bool parentID, bool hidden)
Load object onto parent VIV transport vehicle. Will fail is another vehicle is already loaded.

Example
// load vehicle 10 onto viv transport vehicle 100 keeping the vehicle visible.
vivLoad(10, 100, false);

Comments
This function can fail (no space on parent vehicle etc), use getVivParent if checking is required.

See also
getIsVivTransport getVivObject getVivParent vivUnload

void vivUnload(int objectID, bool front)
Unload object from parent VIV transport vehicle.

Example
// unload vehicle 10 in front of the current parent viv transport vehicle.
vivUnload(10, true)

Comments
Set front to false to unload to behind the object's parent VIV transport vehicle.
This function can fail (no space, not loaded etc), use getVivParent if checking is required.

See also
getIsVivTransport getVivObject getVivParent vivLoad

int getTrailerObject(int parentID)
Get the current trailer object by the specified parent object (server and clients).

Example
print("Player vehicle trailer is " + getTrailerObject(PLAYER_VEHICLE));

Comments
Returns -1 if no trailer is attached.

See also
setTrailerObject getTrailerParent getTrailerFront

int getTrailerParent(int objectID)
Get the parent object for the specified trailer object (server and clients).

Example
print("Player vehicle is being pulled by " + getTrailerParent(PLAYER_VEHICLE));

Comments
Returns -1 if the specified object is not a trailer.

See also
setTrailerObject getTrailerObject getTrailerFront

int getTrailerFront(int objectID)
Get the front parent object for the specified trailer object (server and clients).

Example
print("The front of the player train is object " + getTrailerFront(PLAYER_VEHICLE));

Comments
Gets the frontmost parent object in the trailer chain.
Returns the specified object if the object is at the front, or if the object is not a trailer.

See also
setTrailerObject getTrailerObject getTrailerParent

void setTrailerObject(int parentID, int objectID)
Set the trailer object of the specified parent object (server and clients).

Example
// Set object 2 as the trailer of object 1
setTrailerObject(1, 2);

Comments
Specify -1 as the objectID to detach a trailer.

See also
buildTrailers getTrailerObject getTrailerParent getTrailerFront

void createTrailerChain(array trailerObjectIDs)
Creates a chain of trailer objects (server and clients).

Example
// Set object 2 as the trailer of object 1, and set object 3 as the trailer of object 2
createTrailerChain({ 1, 2, 3 });

Comments
The object IDs should be from front to back.

See also
setTrailerObject getTrailerObject getTrailerParent getTrailerFront

void carryObject(int parentID, int objectID)
Pick up a carriable object (server and clients).

Example
// player picks up and carries object ID 10
carryObject(PLAYER_OBJECT, 10);

Comments
Carried objects have no physics.
Only carriable objects that are not already being carried can be picked up.
Units cannot use weapons while carrying an object.
If a unit is already carrying and object it will be dropped.

See also
dropCarryingObject getCarryingObject getCarryingParent

void dropCarryingObject(int parentID)
Drop a carried object (server and clients).

Example
// drop current player carrying object
dropCarryingObject(PLAYER_OBJECT);

Comments
parentID is the unit carrying the object (not the object being carried).

See also
carryObject getCarryingObject getCarryingParent

int getCarryingObject(int parentID)
Get the current object carried by the specified parent object (server and clients).

Example
// print player carrying object
print(getCarryingObject(PLAYER_OBJECT));

Comments
Returns -1 if no carrying object.

See also
carryObject dropCarryingObject getCarryingParent

int getCarryingParent(int objectID)
Get the parent for an object that is being carried.

Example
// print parent object ID for carried object ID 10
int parentObjectID = getCarryingParent(10);
print(parentObjectID);

Comments
Returns -1 if object is not being carried.

See also
carryObject dropCarryingObject getCarryingObject

int addAction(int objectID, string name, string code, float useDistance, string colour="", bool autoClose=true)
Add an object action.

Example
void onObjectSpawn(int objectID)
{
    code = "print("ID: " + OBJECT + ");";
    addAction(OBJECT, "Show ID, code, 32);
}

Comments
Actions are local only.
useDistance is in pixels added to the radius (based on largest sprite dimension) of the object.
Returns -1 if the action could not be created.
Try to use the playerIO instead of the player object ID for action code because the player ID persists after player respawn in multiplayer.

See also
removeAction addMenuItem

void removeAction(int objectID, int actionID)
Remove an object action.

See also
addAction removeAllActions

void removeAllActions(int objectID)
Remove all actions from an object.

See also
removeAction

bool getActionEnabled(int objectID, int actionID)
Determine if an object action is enabled.

See also
setActionEnabled

void setActionEnabled(int objectID, int actionID, bool enabled)
Enable to disable an object action.

See also
getActionEnabled

bool getActionEnabled(int objectID, int actionID)
Determine if an object action exists.

bool getActionsCount(int objectID)
The the count of actions for an object.


Index