Skyline Lua API  Version 1.0
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 setWeaponFullAmmo (int entityID, string weapon, int state)
 sets the weapon shoot action to either behave as full ammo (state = 1) or no ammo (state = 0 ) More...
 
void setTargetID (int entityID, int TargetID int enabled, float offsetY)
 When called this command will set the weapons action to target at the specified objects axis. 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 weaponKey)
 sets the weapon system current weapon. More...
 
int resetGame (int mode)
 Resets the full game without unloading resources. More...
 
int SetMouseRayEnable (int state) int isKo(int objID
 Mouse ray on button down. 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 - https://home.aurasoft-skyline.co.uk

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
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(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

int game::SetMouseRayEnable ( int  state)

Mouse ray on button down.

Parameters
intstate : - state is either 1 or 0 for on or off.

Enables mouse ray on mouse button down. function

game.SetMouseRayEnable(state);

end Sets the Damage actions KO status.

Parameters
intstate : state is either 1 for KO or 0 for Revive. When the Damage action's health drops to zero then it triggers the ds_ko() event and at the same time it sets its internal KO flag to true, thus preventing any more response from the damage action. When you want to manually cause a fatality the isKo command can be called. Conversly you may want to revive your NPC, so you must call isKo with a state value of 0 Enables mouse ray on mouse button down. function
game.isKo(obj,1); -- KO
game.isKo(obj,0); -- Revive

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

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

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
offsetY: Optional argument for offsetting the Y axis component for targeting as without this and if the character has its axis at its feet then the Ai will shoot at the feet which could be outside the controller body.

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  entityID,
String  weaponKey 
)

sets the weapon system current weapon.

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

sets the weapon system current weapon function game.setWeapon entityID, "weapon"); end

void game::setWeaponFullAmmo ( int  entityID,
string  weapon,
int  state 
)

sets the weapon shoot action to either behave as full ammo (state = 1) or no ammo (state = 0 )

Parameters
entityID: objID the object with the weapon shoot action
weaponstring : The name of the weapon in the weapons Editor.
stateEither has full ammo or not 1=full 0=empty
    game.setWeaponFullAmmo(entityID, "scar", 1);)
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: