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

#include <LUA_API_Game.h>

Public Member Functions

void getPlayerID ()
 Returns the player ID from the default tag name of "Player". More...
 
void setPlayerID (string tagName)
 Override the default playerID with one derived from a custom user player tag name. More...
 
void clickObject (int Zero)
 Fires a ray into the scene and if it hits an entity, the entities script onClick event is fired. More...
 
void resetLevel (int zero)
 Resets the game to the pre-play state whilst still in play the game mode. More...
 
void enableMouseRay (int state)
 Activates the system mouse click ray which when hits an object will trigger the objects onClick event. More...
 
void setMouseTrap (int state)
 Activates the system mouse trap. This provides screen mouse trap with wrapping. More...
 
void doDamage (int entityID, float x, float y, float z, float damageAmt, float powerAmt)
 Causes damage to any object with an attached "Damage System" action. More...
 
void shoot (int entityID, int state)
 Triggers the shoot event in the object "Weapon - Shoot" action. More...
 
void setTargetID (int entityID, int TargetID int enabled)
 When called this command will set the weapons action to target at the specified objects axis. More...
 
void setWeapon (int objID, String weaponKey)
 Sets the current player weapon from the weapon database. More...
 
void getHealth (int objID)
 Gets the health of the selected object. More...
 
void setSceneSpeed (float speed)
 Sets the speed of the scene. More...
 
void setHealth (int objID, int health)
 Set the health of a Entity with the damage action attached. More...
 
int getHealth (int objID)
 Inspect a enitiy's health that has the damage action applied. More...
 
void setWeapon (int entityID, String"weapon")
 sets the weapon system current weapon. More...
 
int resetGame (int mode)
 Resets the full game without unloading resources. More...
 
int setSceneSpeed (int speed)
 Change teh global scene speed and particles. More...
 

Detailed Description

Game mechanic related functions can be found in this class.
Use as game.function()
For more information on how these functions can be used please visit the User Manual - http://www.chi-ad.com/Skyline/SDN/

Member Function Documentation

void game::clickObject ( int  Zero)

Fires a ray into the scene and if it hits an entity, the entities script onClick event is fired.

To be able to receive onClick events an object must have a script containing an onClick() function. Generally you would call the game.clickObject(0) command from inside a scripts onMouseDown() event function. See the Events section of this API for more information

NOTE as of version 0.5.0 there may be a console error. If this does occure pass a zero argument with the command eg: game.clickObject(0);

The following is a Small Example on how to use this function:

function onMouseDown(button,x,y) 
    sky.lprint("click");
    game.clickObject(0); 
end
void game::doDamage ( int  entityID,
float  x,
float  y,
float  z,
float  damageAmt,
float  powerAmt 
)

Causes damage to any object with an attached "Damage System" action.

Parameters
entityID: The object ID of the target object.
posX: The X position the object was hit at. Use with raycast positions for velocity vectors
posY: The Y position the object was hit at. Use with raycast positions for velocity vectors
posZ: The Z position the object was hit at. Use with raycast positions for velocity vectors
damageAmt: the amount of damage to inflict.
powerAmt: the amount of power to put force on the hit object. Higher amounts will move the object more. Has to use Dynamic RigidBody to work.

Note: For this command to have an effect please ensure the target object has the Damage Action attached.

void game::enableMouseRay ( int  state)

Activates the system mouse click ray which when hits an object will trigger the objects onClick event.

Parameters
state: a value 1/0 representing true or false

Note: Enabling this fucntion has no effect if it is enabled in other scripts as it is a global command, ie not local to this script. Here is a Small Example of how to use this function:

function onInit(objID)
    game.enableMouseRay(1);
end

function onClick( object_ID  )
    sky.lprint("you clicked me!");
    game.enableMouseRay(0); -- Stop the mouse from sending onClick events
end
void game::getHealth ( int  objID)

Gets the health of the selected object.

Parameters
entityID: The ID of the object you want to retrieve the health value for.

You can use this command to change the weapon of the player by setting the players ID and weapon ID from the weapon editor. function

game.getHealth(npc1ID);

end

int game::getHealth ( int  objID)

Inspect a enitiy's health that has the damage action applied.

Parameters
IntobjID : objID the object whos health you want to inspect.

For this command to work the object must have a damage action attached. function

int health = game.getHealth(int objID);

end

void game::getPlayerID ( )

Returns the player ID from the default tag name of "Player".

Quick method to getting the current players ID from the default tag name. If you want to use a custom player tag name you must call setPlayerID("NewTag") see setPlayerID("TagName")

The following is a Small Example on how to use this function:

playerID = game.getPlayerID();
int game::resetGame ( int  mode)

Resets the full game without unloading resources.

Parameters
intmode : - Currnetly unused. Set to a zero value.

Use as game.resetGame(0) to instigate a full game reset. This is the same as stopping and restating with out unloading any assets from resourses. function

game.resetGame(int mode);

end

void game::resetLevel ( int  zero)

Resets the game to the pre-play state whilst still in play the game mode.

Parameters
zero: requires a 0 pass in the arg

Due to system requirements this command will fail if there is no argument. The following is a Small Example on how to use this function:

function onKeyDown(key) 
    game.resetLevel(0); 
end
void game::setHealth ( int  objID,
int  health 
)

Set the health of a Entity with the damage action attached.

Parameters
IntobjID : objID the object to add health to.
Inthealth : health value to set entities main health

For this command to work the object must have a damage action attached. function

game.setHealth(obj, 100);

end

void game::setMouseTrap ( int  state)

Activates the system mouse trap. This provides screen mouse trap with wrapping.

Parameters
state: a value (1 is true) and a value of (0 is false)

Note: Enabling this function has no effect if it is enabled in other scripts as it is a global command, ie not local to this script. Here is a Small Example of how to use this function:

function onInit(objID)
    game.setMouseTrap(1); -- Locks the mouse xy to the screen and wraps when passed screen edge
end
void game::setPlayerID ( string  tagName)

Override the default playerID with one derived from a custom user player tag name.

Parameters
tagName: the string tagname you have chosen for your player.

If you want to use a custom player tag name you must call setPlayerID("NewTag") preferably in the scene scripts onInit() to ensure all scripts get the new ID not the default ID. Do not use this if you have not manually changed the players tagname as the system provides the id from the default tagname of "Player"

The following is a Small Example on how to use this function:

setPlayerID("myPlayer")
void game::setSceneSpeed ( float  speed)

Sets the speed of the scene.

Parameters
floatSpeed : The value in integer that you want to set the scene speed to.

Value of 1 is normal. Higher is faster. Use this value to change the speed the engine works, great for bullet time effects as particles, animations and movements slow down function

game.setSceneSpeed( "1.2" );

end

int game::setSceneSpeed ( int  speed)

Change teh global scene speed and particles.

Parameters
intspeed : - 1 = normal. > 1 fast, < 1 slow.

Changes the global scene speed slowing down particles but not physics. function

game.setSceneSpeed(int speed);

end

void game::setTargetID ( int  entityID,
int TargetID int  enabled 
)

When called this command will set the weapons action to target at the specified objects axis.

Parameters
entityID: The object ID of the obejct with the weapon.
TargetID: The ID of the object you want to axis target
enabled: a value of 1 enables system 0=disable

When enabled this command will target the obejcts axis in a full 360 degree orientations. Generally used on a bot to enable shooting to all elevations.

void game::setWeapon ( int  objID,
String  weaponKey 
)

Sets the current player weapon from the weapon database.

Parameters
entityID: The object ID of the player.
WeaponKey: The ID of the weapon in the weapon database

You can use this command to change the weapon of the player by setting the players ID and weapon ID from the weapon editor.

function 

    Game.setWeapon(objID,”2”);
    
end
void game::setWeapon ( int  entityID,
String"weapon"   
)

sets the weapon system current weapon.

Parameters
intobjID : - objID the object to change weapon.
stringWeapon : - The name of the weapon in the weapons Editor.

sets the weapon system current weapon function

game.setWeapon(int entityID, string "weapon");

end

void game::shoot ( int  entityID,
int  state 
)

Triggers the shoot event in the object "Weapon - Shoot" action.

Parameters
entityID: The object ID of the obejct with the weapon.
state: a value of 1=shoot weapon and a value of 0=stops shooting

Note: For this command to have an effect please ensure the object has the "Weapon - Shoot" action. attached.

Here is a Small Example of how to use this function:
function sensorEvent()
    if((distance<=distanceToAttack))then game.shoot(obj,1); end
end

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