Skyline Lua API  Version 1.0
Lua Script Reference for Skyline Game Engine.
entity Class Reference

#include <LUA_API_Entity.h>

Public Member Functions

int spawn (string meshFilename, float posX, float posY, float posZ, float scaleX, float scaleY, float scaleZ)
 This Function will spawn a new scene entity model with the provided meshFilename, position and scale. More...
 
void setPosition (int entityID, float posX, float posY, float posZ)
 This Function will let you set the given position of the given Entity with the id of entityID.See also setPos() More...
 
void setPos (int entityID, Table pos)
 This Function will let you set the position of an Entity with the id of entityID by pass in a table for the vector position. More...
 
float3 getPosition (int entityID)
 This Function will return the position of the specified Entity. More...
 
float3 getLocalPosition (int entityID)
 This will return the local position of the specified entity based on its parents node position. More...
 
float3 getWorldPosition (int entityID)
 This Function will return the world position of the specified Entity whether it is attached or not. More...
 
void setScale (int entityID, float scaleX, float scaleY, float scaleZ)
 Set the Scale of the Entity with the id of entityID. More...
 
float3 subtractPositions (int entityID_1, int entityID_2)
 This Function will provide the means to subtract one entity position from another entity. This can be used to work out directions or get the distance between 2 entities. More...
 
float3 subtractPositions_float3 (float x1, float y1, float z1, float x2, float y2, float z2)
 This function provides the means to subtract 1 float3 from another float3, useful for getting directions. More...
 
void delete (int entityID)
 Use this Function to Delete a specific entity from the scene which is specified by passing the Entity ID to be deleted. More...
 
void addScript (int entityID, string scriptName)
 This Function will Add a script referenced by scriptName to an entity with the id of entityID. More...
 
void setShadow (int entityID, int enabledState)
 This Function lets you cast shadows on the object you provide. More...
 
void setVisible (int entityID, int enabledState)
 Set the visibility of the entity you provide. More...
 
void setVisibleDistance (int entityID, float distance)
 Set the visibility distance of the entity of entityID. More...
 
void setStatic (int entityID, int state)
 Set the visibility distance of the entity of entityID. More...
 
void setRotation (int entityID, float rotX, float rotY, float rotZ)
 Set the Rotation of a specific scene entity. More...
 
void roll (int entityID, float angle, int DegreeOrRadian)
 set how much to roll a specific scene entity. This number will add to the current rotation of the entity. More...
 
void pitch (int entityID, float angle)
 set how much to pitch a specific scene entity. This number will add to the current rotation of the entity. More...
 
void yaw (int entityID, float angle)
 Set the Yaw of a specific scene entity. More...
 
void setFixedYaw (int entityID, int check[0 or 1])
 Fixes an entity to only rotate around the Y Axis, this will stop quaternion rotations from rolling. More...
 
void turn (int objID, float pitch, float yaw, float roll)
 Set the relative rotations of a specific scene entity. More...
 
void move (int objID, float pitch, float yaw, float roll)
 Move the specified object in the XYZ direction by the unit amounts passed in the argument. More...
 
float4 getRotationTo (float srcRotX, float srcRotY, float srcRotZ, float destRotX, float destRotY, float destRotZ)
 Gets the shortest arc quaternion to rotate this vector to the destination vector.
This can be used to smoothly transit between rotations from the source rotation to the Destination
rotation. More...
 
float3 getRadialOffset (int objID, float radiusOffset, float posx, float posy, float posz)
 Returns a poitional vector for an offset down the forward direction. More...
 
float3 getDirection (int entityID_1, int entityID_2)
 Simple and Fast Function for getting the Direction between two entities.
It Simply subtracts the main entities position from the target entities position. More...
 
float3 getForward (int entityID)
 Get the Forward direction of the specified object based on orientation. More...
 
float3 getRight (int entityID)
 Get the Right direction of the specified object based on orientation. More...
 
float3 getUp (int entityID)
 Get the UP direction of the specified object based on orientation. More...
 
float3 getDirectionOfEntity (int entityID)
 Simple and Fast Function for getting the direction of an entity without needing 2 ids or positions It simply uses the entity and retrieves the the direction from the orientation it is pointing. More...
 
void setDirection (int entityID, float dirX, float dirY, float dirZ)
 Set the Direction of an Entity by passing entitiy ID and the direction as a float3. More...
 
float4 getWorldOrientation (int entityID)
 Gets the Orientation in WORLD Space of the entity Provided. The values returned are a Quaternion. More...
 
float3 getWorldOrientationByAxis (int entityID, int axisX, int axisY, int axisZ)
 Gets the Orientation in WORLD Space of the entity Provided Multiplied by an axis.
This allows you to change the Orientation axis and work on a particular axis.
The values are returned as a float3 instead of a Quaternion. More...
 
void setWorldOrientation (int entityID, int rotW, int rotX, int rotY, int rotZ)
 Set the WORLD Orientation of the entity you provide to the function. More...
 
float4 getLocalOrientation (int entityID)
 Gets the Orientation in LOCAL Space of the entity Provided. The values returned are a Quaternion. More...
 
float3 getLocalOrientationByAxis (int entityID, int axisX, int axisY, int axisZ)
 Gets the Orientation in LOCAL Space of the entity Provided Multiplied by an axis.
This allows you to change the Orientation axis and work on a particular axis.
The values return as a float3 instead of a Quaternion. More...
 
void setLocalOrientation (int entityID, int rotW, int rotX, int rotY, int rotZ)
 Set the LOCAL Orientation of the entity you provide to the function. More...
 
void lookatObject (int entityID, int targetID, float rotProgress, int axisX, int axisY, int axisZ)
 Simple Function to make one entity lookat another entity. More...
 
void lookatPosition (int entityID, float lookAtPosX, float lookAtPosY, float lookAtPosZ, float rotProgress, int axisX, int axisY, int axisZ)
 Similar to the lookatObject Function, except this looks at a position which could be moving
or stationary. More...
 
void setQueryFlag_DoNotSelect (int entityID)
 Set the Query flag for DO_NOT_SELECT_MASK. Once an entity has had this mask applied,
it will be EXCLUDED in ray casts to objects. More...
 
void setQueryFlag_Model (int entityID)
 Set the Query flag for MODEL_MASK. Once an entity has had this mask applied,
it will be INCLUDED in all raycasts. More...
 
void setQueryFlag (int entityID, int QueryFlag)
 Set the Query flag for this object to the value pass in the second argument "QueryFlag". More...
 
int getIDFromTag (string entityTagName)
 Get the ID of the Entity from its Entity Tag. More...
 
int getTagFromID (int entityID)
 Get a Tag name from an entity ID. More...
 
int getDescription (int entityID)
 Get a description from an entity ID. More...
 
int setDescription (int entityID, string description)
 Set a description to an entity. More...
 
int setTag (int entityID, string tag)
 Set a tag name for the object. More...
 
String getName (int objID)
 Get the scene list name of the entity with the passed objID arg. More...
 
 setName (int objID, string name)
 Set the scene list name of the entity with the passed objID arg. More...
 
int getLastHitID ()
 Returns the ID of the last object hit with the ray cast system. More...
 
int isColliding (int objID, float direction_x, float direction_y, float direction_z, float range, int queryflag)
 Returns the value 1 if this ray collides with an object. More...
 
int exist (int entityID)
 Returns the value 1 if the entity ID pass in the arg exists in the scene. More...
 
void setMaterialName (int objId, string materialName)
 Call this command to set the material name of all sub materials. More...
 
void setSubMaterialName (int objId, int subentityIndex, string materialName)
 Call this command to set the material name of the specified sub entity. More...
 
void getMaterialName (int objId, int subentityIndex)
 Call this command to get the material name of the sub entity passed through. More...
 
int getNumSubEntities ()
 Call this command to get the number of sub entity the sceneEntity has. More...
 
void callPublicFn (entityID, targetID, value)
 Call this command to trigger an event in the target entities script. More...
 
void callFn (int entityID, int targetID, String functionName, String arg)
 Use entity.callFn(...) to call any function in any objects script, a direct script ot script communication. More...
 
void attach (int parentID, int childID)
 This function will allow you to attach a "sceneEntity" or "dynamic sceneEntity"(spawned) to another entity in the scene. More...
 
void detach (int parentID, int childID)
 This function will allow you to detach a "sceneEntity" or "dynamic sceneEntity"(spawned) from another entity in the scene.
Useful for detaching when the game is running. Skyline auto clears attachments when end the game button has been pressed. More...
 
float getElevation (int objectID, int TargetID)
 
float getHeading (int objectID, int TargetID)
 returns the yaw angle between the 2 objects More...
 
float getHeadingV3 (int objectID, float x, float y, float z)
 returns the yaw angle between the object and the provided position x,y,z More...
 
float getSquaredDistance (int objectID, int TargetID)
 returns the distance between the 2 objects but less accurate and faster then getDistance() More...
 
float getDistance (int objectID, int TargetID)
 returns the distance between the 2 objects More...
 
float3 inverseTransform (int entityID, float x, float y, float z)
 transforms a world space position to local position based on node orientation. This essentially makes the Z axis face the position you passed through. The returned X axis would give you how far left or right the object is. The Returned Y would give you how many units above or below the position is. This is a useful function when dealing with steering. More...
 
entity followPath (entityID, Pathname, Speed,(opt) useRoll)
 Follow a path. More...
 
int getDistanceToVector (obj, x, y, z)
 Position to vector. More...
 
int setAdvancedMaterial (id, materialname)
 Set material to advanced. More...
 
float getBoundingSize (objID)
 Get bounding box size. More...
 
float getBoundingRadius (objID)
 Get bounding box size. More...
 
float getBoundingMinimum (objID)
 Get bounding box minimum. More...
 
float getBoundingMaximum (objID) float getScale()
 Get bounding box maximum. More...
 
float getDynamicProperty (eID, paramName) float setDynamicProperty(eID
 getDynamicProperty More...
 
void entity refreshDynamicProperties ()
 Refresh dynamic properties. More...
 
void rotateToSurface (eID, normalx, normaly, normalz, qw, qx, qy, qz)
 Rortate to surface Rotate an entity to align with the surface of a physics object. More...
 
bool setStatic (bool state)
 set static distance from object to camera. More...
 
float setVisibleDistance (float distaance)
 set staticset visable distance distance from object to camera. More...
 
string getMeshName (objID)
 get mesh name distance from object to camera. More...
 
int registerTodEvent (int objID)
 Add this Object to the Time Of Day system so that its script can receive atod event. Great to turn on/off the lights at night. More...
 
int removeRegisteredTodEvent (int objID)
 Removes this object from the tod system and will no longer receive any tod event messages. More...
 

Public Attributes

float paramName
 
float paramValue
 
float distance = entity.getDistanceToCamera(objID)
 get distance to camera distance from object to camera. More...
 

Detailed Description

The Entity is one of Skylines most important features as it can become nay type of scene object. This Class provides many entity controlling functions.

For more information on how these functions can be used please visit the User Manual - https://home.aurasoft-skyline.co.uk

maxSpawnAmount          = 6
spawnHeightOffset       = 1
spawnEveryMilliseconds  = 1000

obj             = 0;
numSpawns       = 0;
spawnCounter    = 0;

function onInit(objID)
    obj = objID;

    time.startMultiTimer(1,obj,spawnEveryMilliseconds);
    time.startMultiTimer(2,obj,300);

    numSpawns = 0;
end

function onMultiTimer(timerID)
    -- timer 1 = spawn entity
    if(timerID==1)then  
        if( numSpawns < maxSpawnAmount)then
            -- get the position of the spawn point
            x,y,z = entity.getPosition(obj);
            
            -- Spawn the preset you want in the scene.
            spawnID = entity.spawnPreset( "SpawnedCharacter_Temp", x, y + spawnHeightOffset, z );

            -- then add it too its own manager
            numSpawns = numSpawns +1;
            activeSpawns[spawnCounter] = spawnID;
            spawnCounter = spawnCounter + 1;
        end
    end
    
    -- timer 2 = check number of active spawns and remove if deleted / destroyed
    if(timerID==2)then
        for key,value in pairs(activeSpawns) do
            local eID = value;
            if(entity.exist(eID) == 0)then
                activeSpawns[key] = nil

                numSpawns = numSpawns -1;
            end
        end 
    end
end

-- Function you can call from another script to reduce the spawned amount to spawn more.
function reduceSpawnAmount()
    numSpawns = numSpawns - 1;
end

Member Function Documentation

void entity::addScript ( int  entityID,
string  scriptName 
)

This Function will Add a script referenced by scriptName to an entity with the id of entityID.

Parameters
entityID: This is the Entity the script will be attached to. You can use the getIDFromTag
Method to enter an entities name and get the ID of that entity.
scriptName: The name of the script to attach to the Entity. If you have your scripts in folders
then you will need to path the folders and paths from scripts Folder location.

You can locate your Script Folder at Your_Project/Assets/Scripts. or Skyline/Assets Library/Scripts

Here is a Small Example of how to use this function:

function onInit(objID)
    -- load the first found reference in the resource list and load that script.
    -- This is great if you name your script file uniquely in your entire library as it will load the correct one.
    -- however, if there is another of the same name, depending on which one is first in the resource list, it may loads
    -- the wrong one. So spawning is best to use a unique named script.
    entity.addScript( entity.getIDFromTag("cube_1"), "Scriptfile.lua" );

    -- Get the scripts folder in a particular Library e.g. "Asset Library/Scripts" or "Dev Library/Scripts"
    -- Replace "Asset Library" with a string that represents a path set up from the Editor Settings menu.
    entity.addScript( entity.getIDFromTag("cube_1"), "$(Asset Library)/Scripts/Scriptfile.lua"
end
void entity::attach ( int  parentID,
int  childID 
)

This function will allow you to attach a "sceneEntity" or "dynamic sceneEntity"(spawned) to another entity in the scene.

Parameters
parentID: The Entity ID you wish to attach to.
childID: The Entity ID you wish to attach to the parent ID.

This is useful for attaching items such as blades to helicopters/planes or weapons/armour to characters and vehicles and many more things.

"Before attach"
    Entity1 -- parent id (not attached)
    Entity2 -- parent id (not attached)
"After attach"
    Entity1 -- parent id (not attached)
        Entity2 -- entity 2 was attached to entity 1

If you do not detach the entity yourself in code, then skyline will automatically detach when you end the game.

Here is a Small Example of how to use this function:

int obj = 0;
int weapon = 3;
function onInit()
    obj = objID;
    attachObjects();
end

function attachObjects()
    -- example: entity.attach(parentID, childID);
    character = obj;
    entity.attach(character, weapon); -- you must call the object parent first. in this case, it is the entity the script is attached to.
end
void entity::callFn ( int  entityID,
int  targetID,
String  functionName,
String  arg 
)

Use entity.callFn(...) to call any function in any objects script, a direct script ot script communication.

Parameters
entityID: The Entity ID calling the command. In special cases you can pass -1 if you dont want the function to recieve the calling objects id.
this has the advantage that the calling function does not have to pass the id in the first arg which will leave the function as a normal function.
targetID: The Entity ID whose attached script is to receive the event.
functionName: A string containing the name of the function to be called.
arg: Any value you want ot pass through to the fucntion.

By calling this command you have access to any function anywhere in your game. Ensure that the function you are calling
has for the first argument the variable callingID, see example below... ] If your function requires zero args or you dont want to pass the calling id through, you can set the entityID = -1 then you dont have to alter any existing functions args.

Here is a Small Example of how to use this function:

--[[ Scene Entity A: Add the following to an objects micro script]]--
obj = 0;
function onInit(objID)
    sky.lprint("LUA: Calling Object Active!"); 
    obj = objID;
end

function onKeyDown( key )
    entity.callFn(obj,targetID,"anyFunction","Hello");
end


--[[ Scene Entity B: Add this to the second objects micro script]]--
obj = 0;
function onInit(objID)
    sky.lprint("LUA: Target Object Active!"); 
    obj = objID;
end

function anyFunction(callingID, str)
    sky.lprint("ID: "..callingID.." passed:"..str);
end

----------------------------------------------------------------------------
-- alternativly.........
----------------------------------------------------------------------------

--[[ Scene Entity A: Add the following to an objects micro script]]--
obj = 0;
function onInit(objID)
    sky.lprint("LUA: Calling Object Active!"); 
    obj = objID;
end

function onKeyDown( key )
    -- Note: pass the id as -1 to simplify called function.
    entity.callFn(-1,targetID,"anyFunction","Hello");
end


--[[ Scene Entity B: Add this to the second objects micro script]]--
obj = 0;
function onInit(objID)
    sky.lprint("LUA: Target Object Active!"); 
    obj = objID;
end

-- the function does not require the callingID any more
function anyFunction(str)
    sky.lprint("ID: "..callingID.." passed:"..str);
end
void entity::callPublicFn ( entityID  ,
targetID  ,
value   
)

Call this command to trigger an event in the target entities script.

Parameters
entityID: The Entity ID calling the command.
targetID: The Entity ID whose attached script is to receive the event.
value: Any value you want ot pass through the event.

Use this command when you would like to trigger an event in another script or pass a value.
When called the script attached to the Entity with targetID will have its event function
publicFn( int callingID, string value) triggered. A value can be passed between scripts by
using the value argument.

Here is a Small Example of how to use this function:

if( entity.isColliding(obj,0,1,0,2,2)>0) then 
    entity.callPublicFn(obj,entity.getLastHitID(),bulletDamage);
end

-- In the receiving scripts events functions.
function publicFn( callingID, value )
    shieldStrength = shieldStrength - value;
end
void entity::delete ( int  entityID)

Use this Function to Delete a specific entity from the scene which is specified by passing the Entity ID to be deleted.

Parameters
entityID: This is the entity that will be destroyed.

Here is a Small Example of how to use this function:

function onInit(objID)
    entity.delete( entity.getIDFromTag("cube_1") );
end
void entity::detach ( int  parentID,
int  childID 
)

This function will allow you to detach a "sceneEntity" or "dynamic sceneEntity"(spawned) from another entity in the scene.
Useful for detaching when the game is running. Skyline auto clears attachments when end the game button has been pressed.

Parameters
parentID: The Entity ID you wish to detach from.
childID: The Entity ID you wish to detach from the parent ID.

Here is a Small Example of how to use this function:

int obj = 0;
int weapon = 3;
function onInit()
    obj = objID;
    attachObjects();
end

function attachObjects()
    -- example: entity.attach(parentID, childID);
    character = obj;
    entity.attach(character, weapon); -- you must call the object parent first. in this case, it is the entity the script is attached to.
end

function onKeyDown(key)
    if(key == "1")then entity.detach(obj, weapon); end -- you must call the object parent first. in this case, it is the entity the script is attached to.
end
int entity::exist ( int  entityID)

Returns the value 1 if the entity ID pass in the arg exists in the scene.

Parameters
entityID: The Entity ID you would like to check.
Returns
1 or 0: the value of 1 is returned if the object exists

Many commands require that an entity exists so they can perform there process, if no entity
exists the application may perform in an unexpected manor. If you are unsure you can use this
command to check if the entity exists before calling an entity command.

Here is a Small Example of how to use this function:

if( entity.exist(shipID[i]) == 1 ) then
    x,y,z = entity.getPosition( shipID[i] );
    if(x < boundsL and dir == -1) then dropRow(i); end;
    if(x > boundsR and dir == 1) then dropRow(i); end;
    if(y < ground ) then gameOver(); break; end         
    entity.move(shipID[i],dir*invaderSpeed*td,-drop,0);
end
entity entity::followPath ( entityID  ,
Pathname  ,
Speed  ,
(opt)  useRoll 
)

Follow a path.

Parameters
entityID:
pathname:
speed:
useroll: (optional) defaults to 1

Here is a Small Example of how to use this function:

function onInit(objID)

end
float entity::getBoundingMaximum ( objID  )

Get bounding box maximum.

Parameters
entityID:

Here is a Small Example of how to use this function:

function onInit(objID);
    Bmax = entity.getBoundingMaximum(objID) 
end

Get scale of entity

Parameters
entityID:

Here is a Small Example of how to use this function:

function onInit(objID)
scale =  entity.getScale(objID);        
end
float entity::getBoundingMinimum ( objID  )

Get bounding box minimum.

Parameters
entityID:

Here is a Small Example of how to use this function:

function onInit(objID)
    Bmin = entity.getBoundingMinimum(objID);    
end
float entity::getBoundingRadius ( objID  )

Get bounding box size.

Parameters
entityID:

Here is a Small Example of how to use this function:

function onInit(objID)

radious = float entity.getBoundingRadius(objID);

end
float entity::getBoundingSize ( objID  )

Get bounding box size.

Parameters
entityID:

Here is a Small Example of how to use this function:

function onInit(objID)

bx,by,bz = entity.getBoundingSize(objID);   

end
int entity::getDescription ( int  entityID)

Get a description from an entity ID.

Parameters
entityID: The entity ID for the object we want the tag from.
Returns
entity desription Here is a Small Example of how to use this function:
Each scene entity has a non-unique base property called "description" which can be used to define an objects category. \n
Eg zombie, dog, friend,foe,ground etc Useful with AI NPC and other uses.

function onInit(objID)
description = entity.getDescription(objID);
end
float3 entity::getDirection ( int  entityID_1,
int  entityID_2 
)

Simple and Fast Function for getting the Direction between two entities.
It Simply subtracts the main entities position from the target entities position.

Parameters
entityID_1: This is the Entity that will have its position removed from the Target Entity.
entityID_2: This is the Target Entity to subtract the Main Objects position from.
Returns
dirX : Returns the Direction for the X Axis as a float.
dirY : Returns the Direction for the Y Axis as a float.
dirZ : Returns the Direction for the Z Axis as a float.

Here is a Small Example of how to use this function:

function onInit(objID)
    x,y,z = entity.getDirection( entity.getIDFromTag("main_cube_2"), entity.getIDFromTag("target_cube_1") );
end
float3 entity::getDirectionOfEntity ( int  entityID)

Simple and Fast Function for getting the direction of an entity without needing 2 ids or positions It simply uses the entity and retrieves the the direction from the orientation it is pointing.

Parameters
entityID_1: This is the Entity that will get the direction
Returns
dirX : Returns the Direction for the X Axis as a float.
dirY : Returns the Direction for the Y Axis as a float.
dirZ : Returns the Direction for the Z Axis as a float.

Here is a Small Example of how to use this function:

function onInit(objID)
    x,y,z = entity.getDirectionOfEntity( obj );
end
float entity::getDistance ( int  objectID,
int  TargetID 
)

returns the distance between the 2 objects

int entity::getDistanceToVector ( obj  ,
,
,
 
)

Position to vector.

Parameters
entityID:
positionX:
positionY:
positionZ:

Here is a Small Example of how to use this function:

function onInit(objID)

distance = entity.getDistanceToVector(obj,x,y,z);

end
float entity::getDynamicProperty ( eID  ,
paramName   
)

getDynamicProperty

Parameters
entityID:
paramName:

Gets a dynamic value passed by the name Here is a Small Example of how to use this function:

function onInit(objID)
value = entity.getDynamicProperty( eID, paramName )     
end

setDynamicProperty

Parameters
entityID:
paramName: Sets a dynamic value passed by the name Here is a Small Example of how to use this function:
function onInit(objID)
entity.setDynamicProperty( eID, paramName, paramValue );
end
float entity::getElevation ( int  objectID,
int  TargetID 
)
float3 entity::getForward ( int  entityID)

Get the Forward direction of the specified object based on orientation.

Parameters
entityID: The entity to get the forward direction of.
Returns
forwardX : Returns the Forwards for the X Axis as a float.
forwardY : Returns the Forwards for the Y Axis as a float.
forwardZ : Returns the Forwards for the Z Axis as a float.

Here is a Small Example of how to use this function:

function onInit(objID)
    x,y,z = entity.getForward( objID );
end
float entity::getHeading ( int  objectID,
int  TargetID 
)

returns the yaw angle between the 2 objects

float entity::getHeadingV3 ( int  objectID,
float  x,
float  y,
float  z 
)

returns the yaw angle between the object and the provided position x,y,z

int entity::getIDFromTag ( string  entityTagName)

Get the ID of the Entity from its Entity Tag.

Parameters
entityTagName: The name of the entity we want the the ID from.
Returns
The ID number of the entitiy Here is a Small Example of how to use this function:
function onInit(objID)
    id = entity.getIDFromTag("cube_1");
end
int entity::getLastHitID ( )

Returns the ID of the last object hit with the ray cast system.

Returns
The ID number of the object

This command is used along with the isColliding(...) command to get the ID of the entity last hit
with the ray. See isColliding(...) on how to perform a ray cast collision check.

Here is a Small Example of how to use this function:

collisionFlag = 2;
range = 2;
if( entity.isColliding(obj,0,1,0,range,collisionFlag)>0) then 
    entity.callPublicFn(obj,entity.getLastHitID(),value);
    delete(); 
end
float4 entity::getLocalOrientation ( int  entityID)

Gets the Orientation in LOCAL Space of the entity Provided. The values returned are a Quaternion.

Parameters
entityID: The Entity to get LOCAL Orientation from.
Returns
quatX : Returns the Quaternion X value into a float.
quatY : Returns the Quaternion Y value into a float.
quatZ : Returns the Quaternion Z value into a float.
quatW : Returns the Quaternion W value into a float.

Here is a Small Example of how to use this function:

function onInit(objID)
    x,y,z,w = entity.getLocalOrientation( entity.getIDFromTag("main_cube_2") );
end
float3 entity::getLocalOrientationByAxis ( int  entityID,
int  axisX,
int  axisY,
int  axisZ 
)

Gets the Orientation in LOCAL Space of the entity Provided Multiplied by an axis.
This allows you to change the Orientation axis and work on a particular axis.
The values return as a float3 instead of a Quaternion.

Parameters
entityID: The Entity to get LOCAL Orientation from.
AxisX: Set the Orientation of the object to work on the X Axis.
AxisY: Set the Orientation of the object to work on the Y Axis.
AxisZ: Set the Orientation of the object to work on the Z Axis.
Returns
quatX : Returns the Quaternion X value into a float.
quatY : Returns the Quaternion Y value into a float.
quatZ : Returns the Quaternion Z value into a float.

Here is a Small Example of how to use this function:

function onInit(objID)
    x,y,z = entity.getLocalOrientationByAxis( entity.getIDFromTag("main_cube_2"), 0,1,0 );
end
float3 entity::getLocalPosition ( int  entityID)

This will return the local position of the specified entity based on its parents node position.

Parameters
entityID: The ID of the Entity to affect.
Returns
posX : The value returns as a float, this value is the X Axis position of the Entity.
posY : The value returns as a float, this value is the Y Axis position of the Entity.
posZ : The value returns as a float, this value is the Z Axis position of the Entity.

Here is a Small Example of how to use this function:

function onInit( objID )
    obj = objID
end

function onKeyDown( key )
    x,y,z = entity.getLocalPosition( obj );
    sky.lprint("x="..x.."  y="..y.."  z="..z);
end
void entity::getMaterialName ( int  objId,
int  subentityIndex 
)

Call this command to get the material name of the sub entity passed through.

Parameters
entityID: The Entity ID you would like to get from.
subEntityIndex: The index of the sub entity you want to get the material name from.

Here is a Small Example of how to use this function:

function onInit(objID)
    obj = objID;

    material = entity.getMaterialName(obj, 0);
    sky.lprint("This material name is :"..origMaterial);
end
string entity::getMeshName ( objID  )

get mesh name distance from object to camera.

Parameters
objID: The ID of the object you want to retrieve the name of. Objects mesh name Here is a Small Example of how to use this function:
function onInit(objID)
    name = entity.getMeshName(objID);
end
String entity::getName ( int  objID)

Get the scene list name of the entity with the passed objID arg.

Parameters
objID: The entity id to get the name of.
Returns
String: The scene name of the object

Here is a Small Example of how to use this function:

function onInit(objID)
    name = entity.getName(objID);
end
int entity::getNumSubEntities ( )

Call this command to get the number of sub entity the sceneEntity has.

Parameters
entityID: The Entity ID you would like to get from.

Note: You could use this number in a for loop to set each of the sub materials.

Here is a Small Example of how to use this function:

function onInit(objID)
    obj = objID;

    numSubEnts = entity.getNumSubEntities(obj);
    sky.lprint("This entity has : "..numSubEnts.." : number of sub Entities");
end
float3 entity::getPosition ( int  entityID)

This Function will return the position of the specified Entity.

Parameters
entityID: The ID of the Entity to affect.
Returns
posX : The value returns as a float, this value is the X Axis position of the Entity.
posY : The value returns as a float, this value is the Y Axis position of the Entity.
posZ : The value returns as a float, this value is the Z Axis position of the Entity.

Here is a Small Example of how to use this function:

function onInit( objID )
    obj = objID
end

function onKeyDown( key )
    x,y,z = entity.getPosition( obj );
    sky.lprint("x="..x.."  y="..y.."  z="..z);
end
float3 entity::getRadialOffset ( int  objID,
float  radiusOffset,
float  posx,
float  posy,
float  posz 
)

Returns a poitional vector for an offset down the forward direction.

Parameters
objID: The parent object
radiusOffset: the distance down the object directional forward vector
Returns
posx : Returns the x position
posy : Returns the y position
posz : Returns the z position

Use this command when you need to add obects at a fixed radius around the parent object, eg magic fx or muzzel flash
Pass in the parent objects position and this function will return the new position based on the parent objects
orientation and the offset distance.

Here is a Small Example of how to use this function:

function onTimer()
    time.stopTimer(enum.GS_GameMain(), obj);
    radiusOffset    = 1.2
    x,y,z = entity.getPosition(obj);
    x,y,z = entity.getRadialOffset(obj,radiusOffset,x,y,z);
    particle.PU_Run(PU_ID, x, y+0.4, z); -- position the particle effect 1.2 units down the forward direction
    shoot();
end
float3 entity::getRight ( int  entityID)

Get the Right direction of the specified object based on orientation.

Parameters
entityID: The entity to get the forward direction of.
Returns
rightX : Returns the right of the entity for the X Axis as a float.
rightY : Returns the right of the entity for the Y Axis as a float.
rightZ : Returns the right of the entity for the Z Axis as a float.

Here is a Small Example of how to use this function:

function onInit(objID)
    x,y,z = entity.getRight( objID );
end
float4 entity::getRotationTo ( float  srcRotX,
float  srcRotY,
float  srcRotZ,
float  destRotX,
float  destRotY,
float  destRotZ 
)

Gets the shortest arc quaternion to rotate this vector to the destination vector.
This can be used to smoothly transit between rotations from the source rotation to the Destination
rotation.

Parameters
srcRotX: Set the Rotation for the Source Rotation on the X Axis.
srcRotY: Set the Rotation for the Source Rotation on the Y Axis.
srcRotZ: Set the Rotation for the Source Rotation on the Z Axis.
destRotX: Set the Rotation for the Destination Rotation on the X Axis.
destRotY: Set the Rotation for the Destination Rotation on the Y Axis.
destRotZ: Set the Rotation for the Destination Rotation on the Z Axis.
Returns
quatX : Returns the Quaternion X value into a float.
quatY : Returns the Quaternion Y value into a float.
quatZ : Returns the Quaternion Z value into a float.
quatW : Returns the Quaternion W value into a float.

Here is a Small Example of how to use this function:

function onInit(objID)
    x,y,z,w = entity.getRotationTo( -1, 0, 0, 0, 1, 0 );
end
float entity::getSquaredDistance ( int  objectID,
int  TargetID 
)

returns the distance between the 2 objects but less accurate and faster then getDistance()

int entity::getTagFromID ( int  entityID)

Get a Tag name from an entity ID.

Parameters
entityID: The entity ID for the object we want the tag from.
Returns
entity tag name Here is a Small Example of how to use this function:
function onInit(objID)
    tag = entity.getTagFromID(objID);
end
float3 entity::getUp ( int  entityID)

Get the UP direction of the specified object based on orientation.

Parameters
entityID: The entity to get the forward direction of.
Returns
UpX : Returns the UP of the entity for the X Axis as a float.
UpY : Returns the UP of the entity for the Y Axis as a float.
UpZ : Returns the UP of the entity for the Z Axis as a float.

Here is a Small Example of how to use this function:

function onInit(objID)
    x,y,z = entity.getUp( objID );
end
float4 entity::getWorldOrientation ( int  entityID)

Gets the Orientation in WORLD Space of the entity Provided. The values returned are a Quaternion.

Parameters
entityID: The Entity to get World Orientation from.
Returns
quatX : Returns the Quaternion X value into a float.
quatY : Returns the Quaternion Y value into a float.
quatZ : Returns the Quaternion Z value into a float.
quatW : Returns the Quaternion W value into a float.

Here is a Small Example of how to use this function:

function onInit(objID)
    w,x,y,z = entity.getWorldOrientation( entity.getIDFromTag("main_cube_2") );
end
float3 entity::getWorldOrientationByAxis ( int  entityID,
int  axisX,
int  axisY,
int  axisZ 
)

Gets the Orientation in WORLD Space of the entity Provided Multiplied by an axis.
This allows you to change the Orientation axis and work on a particular axis.
The values are returned as a float3 instead of a Quaternion.

Parameters
entityID: The Entity to get World Orientation from.
AxisX: Set the Orientation of the object to work on the X Axis as an int.
AxisY: Set the Orientation of the object to work on the Y Axis.
AxisZ: Set the Orientation of the object to work on the Z Axis.
Returns
quatX : Returns the Quaternion X value into a float.
quatY : Returns the Quaternion Y value into a float.
quatZ : Returns the Quaternion Z value into a float.

Here is a Small Example of how to use this function:

function onInit(objID)
    x,y,z = entity.getWorldOrientationByAxis( entity.getIDFromTag("main_cube_2"), 0,1,0 );
end
float3 entity::getWorldPosition ( int  entityID)

This Function will return the world position of the specified Entity whether it is attached or not.

Parameters
entityID: The ID of the Entity to affect.
Returns
posX : The value returns as a float, this value is the X Axis position of the Entity.
posY : The value returns as a float, this value is the Y Axis position of the Entity.
posZ : The value returns as a float, this value is the Z Axis position of the Entity.

Here is a Small Example of how to use this function:

function onInit( objID )
    obj = objID
end

function onKeyDown( key )
    x,y,z = entity.getWorldPosition( obj );
    sky.lprint("x="..x.."  y="..y.."  z="..z);
end
float3 entity::inverseTransform ( int  entityID,
float  x,
float  y,
float  z 
)

transforms a world space position to local position based on node orientation. This essentially makes the Z axis face the position you passed through. The returned X axis would give you how far left or right the object is. The Returned Y would give you how many units above or below the position is. This is a useful function when dealing with steering.

Parameters
entityID: The angle in degrees you wish to convert
positionX: The X Position you wish to get local space to
positionY: The Y Position you wish to get local space to
positionZ: The Z Position you wish to get local space to

Here is a Small Example of how to use this function:

function onInit(objID)
    degree = 45;
    radian = transform.degreeToRadian( degree );
    sky.print("radian: "..radian);
end
int entity::isColliding ( int  objID,
float  direction_x,
float  direction_y,
float  direction_z,
float  range,
int  queryflag 
)

Returns the value 1 if this ray collides with an object.

Parameters
objID: The name of the entity we want the the ID from.
direction_x: Set the X Axis direction using a float.
direction_y: Set the Y Axis direction using a float.
direction_z: Set the Z Axis direction using a float.
range: This range controls the raycasts isColliding range. This is the distance the ray has to detect from the colliding object, which will then return 1 for collision.
queryflag: Send through the querymask that the raycast will detect.
Returns
The ID number of the entitiy

The command isColliding(...) uses the system ray cast to detect if any objects are in its path, this
is done on the AABB. If an object is inside the argument range it will be considered for a finer polygon
level ray cast and if a poly is detected a value of 1 will be returned, otherwise the command will return 0.
See getIDFromTag(...) on how to return the value of the object the ray collided with.

Here is a Small Example of how to use this function:

collisionFlag = 2;
range = 2;
if( entity.isColliding(obj,0,1,0,range,collisionFlag)>0) then 
    entity.callPublicFn(obj,entity.getLastHitID(),value);
    delete(); 
end
void entity::lookatObject ( int  entityID,
int  targetID,
float  rotProgress,
int  axisX,
int  axisY,
int  axisZ 
)

Simple Function to make one entity lookat another entity.

Parameters
entityID: The ID of the entity the entity that will rotate to look at target.
targetID: The target ID that the entity will be pointed towards
rotProgress: This is a blend value that should increase from 0 to 1 at a speed you find to suit your needs. When it hits 1, it will reset back to 0. This essentially performs a lerp on orientation known as sLerp, with is a smooth interpolation between 2 Quaternion rotations.
AxisX: Choose which axis to do the rotation around, default is Z axis as that is the forward axis.
AxisY: Choose which axis to do the rotation around, default is Z axis as that is the forward axis.
AxisZ: Choose which axis to do the rotation around, default is Z axis as that is the forward axis.

Here is a Small Example of how to use this function:

targetID = 5;
rotFactor = 0.01;
rotProgress = 0;
function onUpdate() 
    rotProgress = rotProgress + rotFactor;
    if(rotProgress >= 1)then 
        rotProgress = 0;
    else
        entity.lookatObject(obj, targetID, rotProgress, 0, 0, 1);
    end 
end
void entity::lookatPosition ( int  entityID,
float  lookAtPosX,
float  lookAtPosY,
float  lookAtPosZ,
float  rotProgress,
int  axisX,
int  axisY,
int  axisZ 
)

Similar to the lookatObject Function, except this looks at a position which could be moving
or stationary.

Parameters
entityID: The Entity that will be rotated to look at the position
lookAtPosX: Set the Position that the object will be pointed towards on the X Axis.
lookAtPosY: Set the Position that the object will be pointed towards on the Y Axis.
lookAtPosZ: Set the Position that the object will be pointed towards on the Z Axis.
rotProgress: This is a blend value that should increase from 0 to 1 at a speed you find to suit your needs. When it hits 1, it will reset back to 0. This essentially performs a lerp on orientation known as sLerp, with is a smooth interpolation between 2 Quaternion rotations.
AxisX: Choose which axis to do the rotation around, default is Z axis as that is the forward axis.
AxisY: Choose which axis to do the rotation around, default is Z axis as that is the forward axis.
AxisZ: Choose which axis to do the rotation around, default is Z axis as that is the forward axis.

Here is a Small Example of how to use this function:

function onUpdate() 
    rotProgress = rotProgress + rotFactor;
    if(rotProgress >= 1)then 
        rotProgress = 0;
    else
        x = 0;
        y = 0;
        z = 0;
        entity.lookatPosition(obj, x, y, z, rotProgress, 0, 0, 1);
    end 
end
void entity::move ( int  objID,
float  pitch,
float  yaw,
float  roll 
)

Move the specified object in the XYZ direction by the unit amounts passed in the argument.

Parameters
entityID: The entity ID that will be turned.
X: Set how far to move along the X axis
Y: Set how far to move along the Y axis
Z: Set how far to move along the Z axis

This function moves the object in the directions specified by the arguments x,y,z. The values are in world units and are
are relative meaning that each time the function is called it will move xyz units from its current position not from world 0,0

Here is a Small Example of how to use this function:

function onUpdate(objID)
    entity.move( objID, 1, 0, 0 );
end
void entity::pitch ( int  entityID,
float  angle 
)

set how much to pitch a specific scene entity. This number will add to the current rotation of the entity.

Parameters
entityID: This is the Entity that will have its Pitch added to.
angle: Set the angle of Pitch to apply to the object
DegreeOrRadian: Use the enum.rotateDegree to set 0 or Use the enum.rotateRadian to set 1.

The pitch you apply to the object is not absolute. if you run this function in an update with a value of 1 set to pitch,
the entity will spin all the way round as this number adds to the previous number.

Here is a Small Example of how to use this function:

function onInit(objID)
    entity.pitch( objID, 1, enum.rotateDegree );
end
void entity entity::refreshDynamicProperties ( )

Refresh dynamic properties.

Parameters
entityID:

Here is a Small Example of how to use this function:

function onInit(objID)
    entity.refreshDynamicProperties();
end
int entity::registerTodEvent ( int  objID)

Add this Object to the Time Of Day system so that its script can receive atod event. Great to turn on/off the lights at night.

Parameters
objID: Set the Object ID you wish to set the Specular Color to.
int entity::removeRegisteredTodEvent ( int  objID)

Removes this object from the tod system and will no longer receive any tod event messages.

Parameters
objID: Set the Object ID you wish to remove from the tod event queue.
void entity::roll ( int  entityID,
float  angle,
int  DegreeOrRadian 
)

set how much to roll a specific scene entity. This number will add to the current rotation of the entity.

Parameters
entityID: This is the Entity that will have its Roll added to.
angle: Set the angle of roll to apply to the object
DegreeOrRadian: Use the enum.rotateDegree() to set 0 or Use the enum.rotateRadian() to set 1.

The roll you apply to the object is not absolute. if you run this function in an update with a value of 1 set to roll,
the entity will spin all the way round as this number adds to the previous number.

Here is a Small Example of how to use this function:

function onInit(objID)
    entity.roll( objID, 1, enum.rotateDegree );
end
void entity::rotateToSurface ( eID  ,
normalx  ,
normaly  ,
normalz  ,
qw  ,
qx  ,
qy  ,
qz   
)

Rortate to surface Rotate an entity to align with the surface of a physics object.

Here is a Small Example of how to use this function:

function onInit(objID)
    entity.rotateToSurface( eID, normalx, normaly, normalz, qw, qx, qy, qz );
end
int entity::setAdvancedMaterial ( id  ,
materialname   
)

Set material to advanced.

Parameters
entityID:
materialname: the name on the material to set to advanced Here is a Small Example of how to use this function:
function onInit(objID)

entity.setAdvancedMaterial(objID, glass);

end
int entity::setDescription ( int  entityID,
string  description 
)

Set a description to an entity.

Parameters
description: The description of the object
Returns
entity desription

Each scene entity has a non-unique base property called "description" which can be used to define an objects category.
Eg zombie, dog, friend,foe,ground etc Useful with AI NPC and other uses.

Here is a Small Example of how to use this function:

function onInit(objID)
    entity.setDescription(objID,"Zombie");
end
void entity::setDirection ( int  entityID,
float  dirX,
float  dirY,
float  dirZ 
)

Set the Direction of an Entity by passing entitiy ID and the direction as a float3.

Parameters
entityID: The Entity to set direction to.
dirX: Set the Direction for the X Axis.
dirY: Set the Direction for the Y Axis.
dirZ: Set the Direction for the Z Axis.

Here is a Small Example of how to use this function:

function onInit(objID)
    entity.setDirection( entity.getIDFromTag("main_cube_2"), 1,0,1 );
end
void entity::setFixedYaw ( int  entityID,
int  check[0 or 1] 
)

Fixes an entity to only rotate around the Y Axis, this will stop quaternion rotations from rolling.

Parameters
entityID: This is the Entity that will have its Yaw added to.
check: a boolean value specified as 0 or 1. 0 = false, 1 = true.

Here is a Small Example of how to use this function:

function onInit(objID)
    entity.setFixedYaw( objID, 1 );
end
void entity::setLocalOrientation ( int  entityID,
int  rotW,
int  rotX,
int  rotY,
int  rotZ 
)

Set the LOCAL Orientation of the entity you provide to the function.

IMPORTANT :: The W Value must be sent through before the others.

Parameters
entityID: The Entity to set the Orientation to.
AxisW: Set the Quaternion Orientation of the object using the W Value.
AxisX: Set the Quaternion Orientation of the object using the X Value.
AxisY: Set the Quaternion Orientation of the object using the Y Value.
AxisZ: Set the Quaternion Orientation of the object using the Z Value.

Here is a Small Example of how to use this function:

function onInit(objID)
    entity.setLocalOrientation( entity.getIDFromTag("main_cube_2"), 0, 0, 0, 0 );
end
void entity::setMaterialName ( int  objId,
string  materialName 
)

Call this command to set the material name of all sub materials.

Parameters
entityID: The Entity ID you would like to set to.
materialName: The material name as a string you would like applied to all sub Entities

Calling this command will set all sub entities materials to the materialname passed through.

Note: Only put the material name that would exist inside the .material file and NOT the .material file name.

Here is a Small Example of how to use this function:

function onKeyDown( key )
    if(key=="1")then 
        entity.setMaterialName(obj, "Proto_Red_adv"); 
    end
end
entity::setName ( int  objID,
string  name 
)

Set the scene list name of the entity with the passed objID arg.

Parameters
objID: The entity id we want to rename
nameThe string name of the object

Here is a Small Example of how to use this function:

function onInit(objID)
name = entity.getName(objID);
end
void entity::setPos ( int  entityID,
Table  pos 
)

This Function will let you set the position of an Entity with the id of entityID by pass in a table for the vector position.

Parameters
entityID: a string containing the name of the spawned Entity.
pos: The Position to set on the given Entity to in the form of a lua table pos = {x=0, y=10, z=0}.

Here is a Small Example of how to use this function:

function onKeyDown( key )
    pos = {x=0, y=10, z=0}
    entity.setPos(obj,pos);
end
void entity::setPosition ( int  entityID,
float  posX,
float  posY,
float  posZ 
)

This Function will let you set the given position of the given Entity with the id of entityID.See also setPos()

Parameters
entityID: a string containing the name of the spawned Entity.
posX: The Position to set on the X Axis of the given Entity.
posY: The Position to set on the Y Axis of the given Entity.
posZ: The Position to set on the Z Axis of the given Entity.

Here is a Small Example of how to use this function:

function onKeyDown( key )
    posx = x + math.random(-60,60)
    posy = y + math.random(-60,60)
    entity.setPosition( entity.getIDFromTag("moveme"), posx, posy, -100 );
end
void entity::setQueryFlag ( int  entityID,
int  QueryFlag 
)

Set the Query flag for this object to the value pass in the second argument "QueryFlag".

Parameters
entityID: The Entity to apply the QUERY MASK to.
QueryFlag: sets the QueryFlag by passing an integer representing one of the flag types 1-9

When checking ray cast collisions you can choose to target certain objects based on their flags.
Only matching flags will return a collision. Set an objects QueryFlag to match the one set with the
command entity.isColliding(obj,0,1,0,range,queryflag)

Here is a Small Example of how to use this function:

function onInit(objID)
    entity.setQueryFlag_Model( entity.getIDFromTag("cube_1") );
end
void entity::setQueryFlag_DoNotSelect ( int  entityID)

Set the Query flag for DO_NOT_SELECT_MASK. Once an entity has had this mask applied,
it will be EXCLUDED in ray casts to objects.

Parameters
entityID: The Entity to apply the QUERY MASK to.

Here is a Small Example of how to use this function:

function onInit(objID)
    entity.setQueryFlag_DoNotSelect( entity.getIDFromTag("cube_1") );
end
void entity::setQueryFlag_Model ( int  entityID)

Set the Query flag for MODEL_MASK. Once an entity has had this mask applied,
it will be INCLUDED in all raycasts.

Parameters
entityID: The Entity to apply the QUERY MASK to.

Here is a Small Example of how to use this function:

function onInit(objID)
    entity.setQueryFlag_Model( entity.getIDFromTag("cube_1") );
end
void entity::setRotation ( int  entityID,
float  rotX,
float  rotY,
float  rotZ 
)

Set the Rotation of a specific scene entity.

Parameters
entityID: This is the Entity that be rotated by the euler angle.
rotX: Set the Rotation for the Entity on the X Axis.
rotY: Set the Rotation for the Entity on the Y Axis.
rotZ: Set the Rotation for the Entity on the Z Axis.

Here is a Small Example of how to use this function:

function onInit(objID)
    entity.setRotation( entity.getIDFromTag("cube_1"), 0,0,0 );
end
void entity::setScale ( int  entityID,
float  scaleX,
float  scaleY,
float  scaleZ 
)

Set the Scale of the Entity with the id of entityID.

Parameters
entityID: The ID of the Entity to affect.
scaleX: The Scale to set on the X Axis of the given Entity.
scaleY: The Scale to set on the Y Axis of the given Entity.
scaleZ: The Scale to set on the Z Axis of the given Entity.

Here is a Small Example of how to use this function:

function onInit(objID)
    entity.setScale( entity.getIDFromTag("cube_1"), 1, 2, 1 );
end
void entity::setShadow ( int  entityID,
int  enabledState 
)

This Function lets you cast shadows on the object you provide.

Parameters
entityID: This is the Entity that shadows will be enabled or disabled on.
enabledState: Set 1 for true
0 for false
This will allow you to change the state of the entity shadows for whether they are casting or not.
Here is a Small Example of how to use this function:
function onInit(objID)
    entity.setShadow( obj, 1 );
end
void entity::setStatic ( int  entityID,
int  state 
)

Set the visibility distance of the entity of entityID.

Parameters
entityID: This is the ID of the Entity to have its visibility Distance set.
state: integer value representing boolean state. 1 = True and 0 = false

The object that has this method used will gain a subsequent performance improvment as the mesh is set to behave as a static object and Skyline's object does not call upon its update. Note: ensure you only call this command on an object that will not ever MOVE or have any ACTION/SCRIPT/MODULES attached

function onInit(objID)
entity.setStatic(objID,1)
end
bool entity::setStatic ( bool  state)

set static distance from object to camera.

Parameters
boolstate : 1=true 0=false stops updating if set to static, boost performance when not needing object to be dynamic Here is a Small Example of how to use this function:
function onInit(objID)
    entity.setStatic(bool state);
end
void entity::setSubMaterialName ( int  objId,
int  subentityIndex,
string  materialName 
)

Call this command to set the material name of the specified sub entity.

Parameters
entityID: The Entity ID you would like to set to.
subEntityIndex: The index of the sub entity you want to apply the material too. Starts from 0.
materialName: The material name you would like applied to the sub Entity.

Calling this command will set the specified material name to the chosen sub entity. This is different to the setMaterialName command as it only affects 1 sub entity.

Note: Only put the material name that would exist inside the .material file and NOT the .material file name.

Here is a Small Example of how to use this function:

function onKeyDown( key )
    if(key=="1")then 
        subEntityIndex = 0;
        entity.setSubMaterialName(obj, subEntityIndex, "Proto_Sand_adv");
    end
end
int entity::setTag ( int  entityID,
string  tag 
)

Set a tag name for the object.

Parameters
Tag: The tag name of the object
Returns
entity desription Here is a Small Example of how to use this function:
function onInit(objID)
entity.setTag(objID,"Zombie3");
end
void entity::setVisible ( int  entityID,
int  enabledState 
)

Set the visibility of the entity you provide.

Parameters
entityID: This is the ID of the Entity to have its visibility enabled or disabled.
enabledState: Set 1 for true, 0 for false. This will allow you to change the state of the entities visibility.

NOTE: If you use this command on a entity containing this script it will stop the scripts operation as only visible objects currently have their scripts parsed. Here is a Small Example of how to use this function:

function onInit(objID)
    entity.setVisible( entity.getIDFromTag("cube_1"), 1 );
end
void entity::setVisibleDistance ( int  entityID,
float  distance 
)

Set the visibility distance of the entity of entityID.

Parameters
entityID: This is the ID of the Entity to have its visibility Distance set.
distance: Distance this object can be seen. A value of 0 will be visible constantly.

A good performance setting to enable better frame rates in highly populated scenes. By setting the visible distance to a low value on small objects and longer distances on larger objects you can gain extra frames. This property can work well in conjuction with the systems auto lods.

function onInit(objID)
entity.setVisibleDistance( entity.getIDFromTag("cube_1"), 10 );
end
float entity::setVisibleDistance ( float  distaance)

set staticset visable distance distance from object to camera.

Parameters
floatdistance : The didstance to show the object afte this distance it is hidden. hides object after distace Here is a Small Example of how to use this function:
function onInit(objID)
    entity.setVisibleDistance(float distaance);
end
void entity::setWorldOrientation ( int  entityID,
int  rotW,
int  rotX,
int  rotY,
int  rotZ 
)

Set the WORLD Orientation of the entity you provide to the function.

IMPORTANT :: The W Value must be sent through before the others.

Parameters
entityID: The Entity to set the Orientation to.
rotW: Set the Quaternion Orientation of the object using the W Value.
rotX: Set the Quaternion Orientation of the object using the X Value.
rotY: Set the Quaternion Orientation of the object using the Y Value.
rotZ: Set the Quaternion Orientation of the object using the Z Value.

Here is a Small Example of how to use this function:

function onInit(objID)
    entity.setWorldOrientation( entity.getIDFromTag("main_cube_2"), 0, 0, 0, 0 );
end
int entity::spawn ( string  meshFilename,
float  posX,
float  posY,
float  posZ,
float  scaleX,
float  scaleY,
float  scaleZ 
)

This Function will spawn a new scene entity model with the provided meshFilename, position and scale.

Parameters
meshFilename: a string containing the file name of the mesh to be spawned.
posX: The Position to set on the X Axis of the given Entity.
posY: The Position to set on the Y Axis of the given Entity.
posZ: The Position to set on the Z Axis of the given Entity.
scaleX: The Scale to set on the X Axis.
scaleY: The Scale to set on the Y Axis.
scaleZ: The Scale to set on the Z Axis.
Returns
The ID of the spawned Entity.

Here is a Small Example of how to use this function:

function onKeyDown( key )
    posx = x + math.random(-60,60)
    posy = y + math.random(-60,60)
    id = entity.spawn("Cube_Normal",posx,posy,-100,1,1,1);
    sky.lprint ( id );
end
float3 entity::subtractPositions ( int  entityID_1,
int  entityID_2 
)

This Function will provide the means to subtract one entity position from another entity. This can be used to work out directions or get the distance between 2 entities.

Parameters
entityID_1: This is the Target Entity ID to subtract the Main Objects position from.
entityID_2: This is the Entity ID that will have its position removed from the Target Entity.
Returns
posX : The value returns as a float, this value is the X Axis position of the Entity.
posY : The value returns as a float, this value is the Y Axis position of the Entity.
posZ : The value returns as a float, this value is the Z Axis position of the Entity.

Here is a Small Example of how to use this function:

function onInit(objID)
    entity.subtractPositions( entity.getIDFromTag("target_cube_1"), entity.getIDFromTag("main_cube_2") );
end
float3 entity::subtractPositions_float3 ( float  x1,
float  y1,
float  z1,
float  x2,
float  y2,
float  z2 
)

This function provides the means to subtract 1 float3 from another float3, useful for getting directions.

Parameters
x1: This is the X axis value of the first float3
y1: This is the Target Entity to subtract the Main Objects position from.
z1: This is the Target Entity to subtract the Main Objects position from.
x2: This is the Target Entity to subtract the Main Objects position from.
y2: This is the Target Entity to subtract the Main Objects position from.
z2: This is the Target Entity to subtract the Main Objects position from.
Returns
posX : The value returns as a float, this value is the X Axis position of the Entity.
posY : The value returns as a float, this value is the Y Axis position of the Entity.
posZ : The value returns as a float, this value is the Z Axis position of the Entity.

Here is a Small Example of how to use this function:

function onInit(objID)
    x1,y1,z1 = entity.getPosition(obj);
    x2,y2,z2 = entity.getPosition(obj2);
    newX,newY,newZ = entity.subtractPositions_float3( x1,y1,z1,x2,y2,z2 );
end
void entity::turn ( int  objID,
float  pitch,
float  yaw,
float  roll 
)

Set the relative rotations of a specific scene entity.

Parameters
entityID: The entity ID that will be turned.
pitch: Set the angle of pitch in degrees to apply to the object.
yaw: Set the angle of yaw in degrees to apply to the object.
roll: Set the angle of roll in degrees to apply to the object.

Pass values for pitch ,yaw and roll to set the amount of rotation in degrees. This function works on relative values, this means
that if you pass a value of 1 to the yaw, every time this function is called the object will turn its yaw by 1 degree.

Here is a Small Example of how to use this function:

function onUpdate(objID)
    entity.turn( objID, 1, 0, 0 );
end
void entity::yaw ( int  entityID,
float  angle 
)

Set the Yaw of a specific scene entity.

Parameters
entityID: This is the Entity that will have its Yaw added to.
angle: Set the angle of Yaw to apply to the object
DegreeOrRadian: Use the enum.rotateDegree to set 0 or Use the enum.rotateRadian to set 1.

The yaw you apply to the object is not absolute. if you run this function in an update with a value of 1 set to yaw,
the entity will spin all the way round as this number adds to the previous number.

Here is a Small Example of how to use this function:

function onInit(objID)
    entity.yaw( objID, 1, enum.rotateDegree );
end

Member Data Documentation

float entity::distance = entity.getDistanceToCamera(objID)

get distance to camera distance from object to camera.

Here is a Small Example of how to use this function:

function onInit(objID)
    distance = entity.getDistanceToCamera(objID);
end
float entity::paramName
float entity::paramValue

The documentation for this class was generated from the following file: