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

#include <LUA_API_Events.h>

Public Member Functions

void onResize (int width, int height)
 Event gets called from either the editor or player when they are resized. More...
 
void publicFn (int callingID, string value)
 This scripts function event is called from another script to trigger local functions and pass
data between scripts. More...
 
void globalFn (int callingID, string value)
 This event is called is called from the sky.callGlobalFn(objID,value)
and will make a call to every script that contains this function. More...
 
void onInit (object_ID)
 Event called when you press the play button or the game initialises from the stand alone version. More...
 
void onTriggerBoxExit ()
 Called after an entity collides with a trigger box and leaves again. More...
 
void onTriggerBoxEnter ()
 Called an entity collides with a trigger box. More...
 
void onCollision_Start (int hitID)
 PhysX Event callback when 2 objects make the initial collision. More...
 
void onCollision_Stay (int hitID)
 PhysX Event continiously called callback when 2 objects are overlapping. More...
 
void onCollision_End (int hitID)
 PhysX Event callback when the obejcts move appart and stop colliding. More...
 
void onSceneCollision_Start (int hitID1, int hitID2)
 PhysX Scene script event callback when 2 objects make the initial collision. More...
 
void onSceneCollision_Stay (int hitID1, int hitID2)
 PhysX Scene script event continiously called callback when 2 objects are overlapping. More...
 
void onSceneCollision_End (int hitID1, int hitID2)
 PhysX Scene script event callback when the obejcts move appart and stop colliding. More...
 
void onTrigger_Enter (int hitID)
 PhysX Event callback called when the object enters a physx trigger. More...
 
void onTrigger_Stay (int hitID)
 PhysX Event callback called whilst the object is inside a physx trigger. More...
 
void onTrigger_Leave (int hitID)
 PhysX Event callback called on leaving contact with a physx trigger. More...
 
void onTimer ()
 
void onEnter ()
 
void onExit ()
 
void onUpdate (float timeDelta)
 
void onStop ()
 Event called when you press the Stop button and before the system goes back to editing mode. More...
 
void onKeyDown (string key)
 
void onKeyUp (string key)
 
void onClick (int hitID)
 This Event is triggered if the game.clickObject() has been called. The object that has been clicked on must contain a script containing this onClick() event function. More...
 
void onMouseDown (int button, int x, int y)
 
void onMouseUp (int button, int x, int y)
 
void onMouseMove (int x, int y)
 
void _________________________________ ()
 
void onEnter_GamePaused ()
 
void onExit_GamePaused ()
 
void onUpdate_GamePaused (float timeDelta)
 
void onStop_GamePaused ()
 
void onKeyDown_GamePaused (string key)
 
void onKeyUp_GamePaused (string key)
 
void onClick_GamePaused ()
 
void onMouseDown_GamePaused (int button, int x, int y)
 
void onMouseUp_GamePaused (int button, int x, int y)
 
void onMouseMove_GamePaused (int x, int y)
 
void _________________________________ ()
 
void onEnter_GameStart ()
 
void onExit_GameStart ()
 
void onUpdate_GameStart (float timeDelta)
 
void onStop_GameStart ()
 
void onKeyDown_GameStart (string key)
 
void onKeyUp_GameStart (string key)
 
void onClick_GameStart ()
 
void onMouseDown_GameStart (int button, int x, int y)
 
void onMouseUp_GameStart (int button, int x, int y)
 
void onMouseMove_GameStart (int x, int y)
 
void _________________________________ ()
 
void onEnter_GameOver ()
 
void onExit_GameOver ()
 
void onUpdate_GameOver (float timeDelta)
 
void onStop_GameOver ()
 
void onKeyDown_GameOver (string key)
 
void onKeyUp_GameOver (string key)
 
void onClick_GameOver ()
 
void onMouseDown_GameOver (int button, int x, int y)
 
void onMouseUp_GameOver (int button, int x, int y)
 
void onMouseMove_GameOver (int x, int y)
 
void _________________________________ ()
 
void onTriggerStart_GameWin ()
 
void onTriggerEnd_GameWin ()
 
void onEnter_GameWin ()
 
void update_GameWin ()
 
void onExit_GameWin ()
 
void onStop_GameWin ()
 
void onKeyDown_GameWin (string key)
 
void onKeyUp_GameWin (string key)
 
void onClick_GameWin (int objID)
 
void onMouseDown_GameWin (int button, int x, int y)
 
void onMouseUp_GameWin (int button, int x, int y)
 
void onMouseMove_GameWin (int x, int y)
 
void _________________________________ ()
 
void onJSButtonReleased (int button)
 
void onJSButtonReleased_GamePaused (int button)
 
void onJSButtonReleased_GameStart (int button)
 
void onJSButtonReleased_GameOver (int button)
 
void onJSButtonReleased_GameWin (int button)
 
void onJSButtonReleased_User1 (int button)
 
void onJSButtonReleased_User2 (int button)
 
void onJSButtonReleased_User3 (int button)
 
void onJSButtonReleased_User4 (int button)
 
void onJSButtonReleased_User5 (int button)
 
void onJSButtonReleased_User6 (int button)
 
void onJSButtonReleased_User7 (int button)
 
void onJSButtonReleased_User8 (int button)
 
void onJSButtonReleased_User9 (int button)
 
void onJSButtonReleased_User10 (int button)
 
void onJSButtonPressed (int button)
 
void onJSButtonPressed_GamePaused (int button)
 
void onJSButtonPressed_GameStart (int button)
 
void onJSButtonPressed_GameOver (int button)
 
void onJSButtonPressed_GameWin (int button)
 
void onJSButtonPressed_User1 (int button)
 
void onJSButtonPressed_User2 (int button)
 
void onJSButtonPressed_User3 (int button)
 
void onJSButtonPressed_User4 (int button)
 
void onJSButtonPressed_User5 (int button)
 
void onJSButtonPressed_User6 (int button)
 
void onJSButtonPressed_User7 (int button)
 
void onJSButtonPressed_User8 (int button)
 
void onJSButtonPressed_User9 (int button)
 
void onJSButtonPressed_User10 (int button)
 
void onJSPovMoved (String direction)
 
void onJSPovMoved_GamePaused (String direction)
 
void onJSPovMoved_GameStart (String direction)
 
void onJSPovMoved_GameOver (String direction)
 
void onJSPovMoved_GameWin (String direction)
 
void onJSPovMoved_User1 (String direction)
 
void onJSPovMoved_User2 (String direction)
 
void onJSPovMoved_User3 (String direction)
 
void onJSPovMoved_User4 (String direction)
 
void onJSPovMoved_User5 (String direction)
 
void onJSPovMoved_User6 (String direction)
 
void onJSPovMoved_User7 (String direction)
 
void onJSPovMoved_User8 (String direction)
 
void onJSPovMoved_User9 (String direction)
 
void onJSPovMoved_User10 (String direction)
 
void onJSliderMoved (int sliderID)
 
void onJSliderMoved_GamePaused (int sliderID)
 
void onJSliderMoved_GameStart (int sliderID)
 
void onJSliderMoved_GameOver (int sliderID)
 
void onJSliderMoved_GameWin (int sliderID)
 
void onJSliderMoved_User1 (int sliderID)
 
void onJSliderMoved_User2 (int sliderID)
 
void onJSliderMoved_User3 (int sliderID)
 
void onJSliderMoved_User4 (int sliderID)
 
void onJSliderMoved_User5 (int sliderID)
 
void onJSliderMoved_User6 (int sliderID)
 
void onJSliderMoved_User7 (int sliderID)
 
void onJSliderMoved_User8 (int sliderID)
 
void onJSliderMoved_User9 (int sliderID)
 
void onJSliderMoved_User10 (int sliderID)
 
void onJSAxisMoved (int axis, int value)
 
void onJSAxisMoved_GamePaused (int axis, int value)
 
void onJSAxisMoved_GameStart (int axis, int value)
 
void onJSAxisMoved_GameOver (int axis, int value)
 
void onJSAxisMoved_GameWin (int axis, int value)
 
void onJSAxisMoved_User1 (int axis, int value)
 
void onJSAxisMoved_User2 (int axis, int value)
 
void onJSAxisMoved_User3 (int axis, int value)
 
void onJSAxisMoved_User4 (int axis, int value)
 
void onJSAxisMoved_User5 (int axis, int value)
 
void onJSAxisMoved_User6 (int axis, int value)
 
void onJSAxisMoved_User7 (int axis, int value)
 
void onJSAxisMoved_User8 (int axis, int value)
 
void onJSAxisMoved_User9 (int axis, int value)
 
void onJSAxisMoved_User10 (int axis, int value)
 
void onEnter_User1 () -> User10()
 A set of User events ranging from User1() to User10() More...
 
void onUpdate_User1 () -> User10()
 
void onExit_User1 () -> User10()
 
void onStop_User1 () -> User10()
 
void onClick_User1 (int ID) -> User10(int ID)
 
void onMouseDown_User1 (int button, int x, int y) -> User10(int button, int x, int y)
 
void onMouseUp_User1 (int button, int x, int y) -> User10(int button, int x, int y)
 
void onMouseMove_User1 (int x, int y) -> User10(int x, int y)
 
void onKeyDown_User1 (string key) -> User10(string key)
 
void onKeyUp_User1 (string key) -> User10(string key)
 
void fps_Pickup (itemType, itemName, itemValue)
 This event is called from the FPS System to a micro script attached to the player with the FPS System attached. More...
 
void fps_PlayerDamage (damageAmount, objectID)
 This event is called from the FPS System to a micro script attached to the player with the FPS System attached. More...
 
void fps_Shoot (contact_X, contact_Y, contact_Z)
 This event is called from the FPS System to a micro script attached to the player with the FPS System attached. More...
 
void fps_DamageEvent (targetID, targetName, targetHealth, scoreValue)
 This event is called from the FPS System to a micro script attached to the player with the FPS System attached. More...
 
void ds_nKo ()
 This event is called from the Damage System to a micro script attached to the object with the Damage System attached. More...
 
void ds_onDamage (int health, int damage, int attackingID)
 This event is called from the Damage System to a script attached to the object with the Damage Action attached. More...
 
void onSensorContact_Enter (objID)
 This event is called from the Damage System to a micro script attached to the object with the Damage System attached. More...
 
void onSensorContact_Exit (objID)
 
void onSensorContact_Stay (objID, distance)
 
void onEditorClose ()
 
void onEditorOpen ()
 
void game_Pickup (fps_itemType, fps_itemName, val)
 
void game_PlayerDamage (str)
 
void game_Shoot ()
 
void game_DamageEvent (Value, string, Value, Value)
 
void SetDynamicProperty (eID,"Param","Value")
 
void updateDefaultGUI_Screen (scene.sceneScript.scriptID)
 

Detailed Description

When you run your project many different events get fired in response to certain contitions. Some of these events
are passed through to lua where they can be put to good use in your scripts. The syntax for these events is based on
standard function body.

    eg:

    function onStop()
        -- Body code here...
    end

Some events pass in their arguments the IDs of the calling event. In the following example, when a key
is pressed it triggers the systems key down event and passes the key to the event.

    eg:

    function onKeyDown( key )
        if( key == "p" )then 
        -- do something...
        end
    end

Every Script has access to these events including the main game update loop. This section outlines all of the available events and their respective arguments.

Game States:
At the core of Skyline beats the heart of a modern state based machine, to seamlessly handle the transition of code from one state to another. What this means for your project is a set of organised scripts which only run when the required game state is set. For example, you can setup a main game update loop to take care of the main game and another update loop set up for when the game is in pause mode. When you pause; you set the game state to the pause state - this then stops the Main Game update from running, meanwhile activating the pause update loop.

Each Game State has a set of related events which are farmed out by the system depending upon the value set in setGameState. Alongside the normal events all states provide extra events such as onEnter() and onExit(); these states get called when a state change is initiated. The current state calls its own onExit() then the new state calls its onEnter() event.

Visualise each state as a self contained set of commands with events that are only accessible when it is in the respective state.

State Flow:

     1.Set state to Main Game
     2.Main Game onUpdate() running
     3.a call is made to the state machine to change state to the Pause state.  
     4.Main Game onUpdate() stops
     5.Main Game onExit() runs
     6.Pause onEnter() runs
     7.Pause onUpdate() running

To test how the game state system works, copy the following code into a script attached to a scene entity such as a cube The script can also be located in the Asset Library/Scripts/Examples/Game States folder

    --[[
        SKYLINE DEVELOPMENT SCRIPT
        This script is to be used for testing the game state system. Add this script to
        a scene entity such as a cube.
        
        Use the Keys [1-4] to change the game state. This will cause a change to the state
        and the respective events will be called.
        
        The changes will be printed to the console, these will show the sequence of events
        as each state goes through its onExit, onEnter event. When the number key is pressed,
        the onKeyDown() for the current state is triggered, followed by the current state's onExit() 
        being called. Then the new state's onEnter() event is called, any new event will 
        then be passed to the new state's event system.
    --]]

    -- the onInit is not state dependant and will always be called when the script is activated
    -- by playing the project.
    function onInit( objID )
        sky.lprint("\n***TEST SCRIPT - COMMON :: INIT ***\n");
        obj = objID;
    end

    ------------------------------------------------------------------------------------------
    -- onMouseDown() for each state. We can call the game.clickObject() for the selected state
    -- The system calls the respective events based upon the current state. In this case we
    -- need to have a mouse down from each state but only the function matching the current 
    -- state will be fired when the mouse button is clicked.
    ------------------------------------------------------------------------------------------
    function onMouseDown(button,x,y) game.clickObject(0); end 
    function onMouseDown_GamePaused(button,x,y) game.clickObject(0); end 
    function onMouseDown_GameStart(button,x,y)game.clickObject(0);end 
    function onMouseDown_GameOver(button,x,y)game.clickObject(0);end 

    ------------------------------------------------------------------------------------------
    -- onKeyDown() for each state. With this we can change states from the number keys for
    -- the selected state. Again we have a function for each state and only the key down
    -- function matching the current state will be called.
    ------------------------------------------------------------------------------------------
    function onKeyDown( key )
        sky.lprint(" ");sky.lprint("------------------------------------------------------------");
        sky.lprint("\n***TEST SCRIPT - MAIN :: KEYDOWN***");
        if(key=="1") then sky.setGameState( 1 ); sky.lprint("***CHANGING STATE - MAIN*** "); end
        if(key=="2") then sky.setGameState( 2 ); sky.lprint("***CHANGING STATE - PAUSE***"); end
        if(key=="3") then sky.setGameState( 3 ); sky.lprint("***CHANGING STATE - START***"); end
        if(key=="4") then sky.setGameState( 4 ); sky.lprint("***CHANGING STATE - OVER*** "); end
    end                                                      
                                                             
    function onKeyDown_GamePaused( key )                     
        sky.lprint(" ");sky.lprint("------------------------------------------------------------");
        sky.lprint("\n***TEST SCRIPT - PAUSED :: KEYDOWN***"); 
        if(key=="1") then sky.setGameState( 1 ); sky.lprint("***CHANGING STATE - MAIN***"); end
        if(key=="2") then sky.setGameState( 2 ); sky.lprint("***CHANGING STATE - PAUSE***"); end
        if(key=="3") then sky.setGameState( 3 ); sky.lprint("***CHANGING STATE - START***"); end
        if(key=="4") then sky.setGameState( 4 ); sky.lprint("***CHANGING STATE - OVER***"); end
    end                                                      
                                                             
    function onKeyDown_GameStart( key )                      
        sky.lprint(" ");sky.lprint("------------------------------------------------------------");
        sky.lprint("\n***TEST SCRIPT - START :: KEYDOWN***");  
        if(key=="1") then sky.setGameState( 1 ); sky.lprint("***CHANGING STATE - MAIN***"); end
        if(key=="2") then sky.setGameState( 2 ); sky.lprint("***CHANGING STATE - PAUSE***"); end
        if(key=="3") then sky.setGameState( 3 ); sky.lprint("***CHANGING STATE - START***"); end
        if(key=="4") then sky.setGameState( 4 ); sky.lprint("***CHANGING STATE - OVER***"); end
    end                                                      
                                                             
    function onKeyDown_GameOver( key )                       
        sky.lprint(" ");sky.lprint("------------------------------------------------------------");
        sky.lprint("\n***TEST SCRIPT - OVER :: KEYDOWN***");   
        if(key=="1") then sky.setGameState( 1 ); sky.lprint("***CHANGING STATE - MAIN***"); end
        if(key=="2") then sky.setGameState( 2 ); sky.lprint("***CHANGING STATE - PAUSE***"); end
        if(key=="3") then sky.setGameState( 3 ); sky.lprint("***CHANGING STATE - START***"); end
        if(key=="4") then sky.setGameState( 4 ); sky.lprint("***CHANGING STATE - OVER***"); end
    end

    ------------------------------------------------------------------------------------------

    function onStop(  )
        sky.lprint("***TEST SCRIPT - STOPPING MAIN ***");
    end

    function onEnter(  )
        sky.lprint("***TEST SCRIPT - ENTERING MAIN ***");
    end

    function onExit(  )
        sky.lprint("***TEST SCRIPT - EXITING MAIN ***");
    end

    function onUpdate( timeDelta )
        --sky.lprint("***TEST SCRIPT - MAIN :: UPDATE ***");
    end

    --function onKeyDown( key ) at top of this script

    function onKeyUp( key )
        sky.lprint("***TEST SCRIPT - MAIN :: KEYUP***");
    end

    function onClick( hitID )
        sky.lprint("***TEST SCRIPT - MAIN :: CLICK***");
    end

    --function onMouseDown( button, x, y ) at top of this script

    function onMouseUp( button,x ,y )
        sky.lprint("***TEST SCRIPT - MAIN :: MOUSEUP***");
    end

    function onMouseMove( x, y )
        sky.lprint("***TEST SCRIPT - MAIN :: MOVE***");
    end

    ------------------------------------------------------------------------------------------

    function onStop_GamePaused(  )
        sky.lprint("***TEST SCRIPT - STOPPING GamePaused ***");
    end

    function onEnter_GamePaused(  )
        sky.lprint("***TEST SCRIPT - ENTERING GamePaused ***");
    end

    function onExit_GamePaused(  )
        sky.lprint("***TEST SCRIPT - EXITING GamePaused ***");
    end


    function onUpdate_GamePaused( timeDelta )
        --sky.lprint("***TEST SCRIPT - GamePaused :: UPDATE***");
    end

    --function onKeyDown_GamePaused( key ) at top of this script

    function onKeyUp_GamePaused( key )
        sky.lprint("***TEST SCRIPT - GamePaused :: KEYUP***");
    end

    function onClick_GamePaused( hitID )
        sky.lprint("***TEST SCRIPT - GamePaused :: CLICK***");
    end


    --function onMouseDown_GamePaused( button, x, y ) at top of this script

    function onMouseUp_GamePaused( button,x ,y )
        sky.lprint("***TEST SCRIPT - GamePaused :: MOUSEUP***");
    end

    function onMouseMove_GamePaused( x, y )
        sky.lprint("***TEST SCRIPT - GamePaused :: MOVE***");
    end

    ------------------------------------------------------------------------------------------

    function onStop_GameStart(  )
        sky.lprint("***TEST SCRIPT - STOPPING GameStart ***");
    end

    function onEnter_GameStart(  )
        sky.lprint("***TEST SCRIPT - ENTERING GameStart ***");
    end

    function onExit_GameStart(  )
        sky.lprint("***TEST SCRIPT - EXITING GameStart ***");
    end

    function onUpdate_GameStart( timeDelta )
        --sky.lprint("***TEST SCRIPT - GameStart :: UPDATE***");
    end

    --function onKeyDown_GameStart( key ) at top of this script

    function onKeyUp_GameStart( key )
        sky.lprint("***TEST SCRIPT - GameStart :: KEYUP***");
    end

    function onClick_GameStart( hitID )
        sky.lprint("***TEST SCRIPT - GameStart :: CLICK***");
    end

    --function onMouseDown_GameStart( button, x, y ) at top of this script

    function onMouseUp_GameStart( button,x ,y )
        sky.lprint("***TEST SCRIPT - GameStart :: MOUSEUP***");
    end

    function onMouseMove_GameStart( x, y )
        sky.lprint("***TEST SCRIPT - GameStart :: MOVE***");
    end

    ------------------------------------------------------------------------------------------

    function onStop_GameOver(  )
        sky.lprint("***TEST SCRIPT - STOPPING GameOver ***");
    end

    function onEnter_GameOver(  )
        sky.lprint("***TEST SCRIPT - ENTERING GameOver ***");
    end

    function onExit_GameOver(  )
        sky.lprint("***TEST SCRIPT - EXITING GameOver ***");
    end

    function onUpdate_GameOver( timeDelta )
        --sky.lprint("***TEST SCRIPT - GameOver :: UPDATE ***");
    end

    --function onKeyDown_GameOver( key ) at top of this script

    function onKeyUp_GameOver( key )
        sky.lprint("***TEST SCRIPT - GameOver :: KEYUP***");
    end

    function onClick_GameOver( hitID )
        sky.lprint("***TEST SCRIPT - GameOver :: CLICK***");
    end

    --function onMouseDown_GameOver( button, x, y ) at top of this script

    function onMouseUp_GameOver( button,x ,y )
        sky.lprint("***TEST SCRIPT - GameOver :: MOUSEUP***");
    end

    function onMouseMove_GameOver( x, y )
        sky.lprint("***TEST SCRIPT - GameOver :: MOVE***");
    end

    ------------------------------------------------------------------------------------------
For reference: this is the order in which skyline loads a game.
Order:
> Press play
> Scene Script onInit called
> External Scripts onInit called
> All Actions onInit called (PhysX Rigidbody, microscript onInit)

> Scene Script postInit
> External Script Postinit (this one is missing).
> Microscript Postinit

> Game is now setup
> call all other events like onUpdate, onkeydown when required.

Member Function Documentation

void Basic_Events::_________________________________ ( )
void Basic_Events::_________________________________ ( )
void Basic_Events::_________________________________ ( )
void Basic_Events::_________________________________ ( )
void Basic_Events::_________________________________ ( )
void Basic_Events::ds_nKo ( )

This event is called from the Damage System to a micro script attached to the object with the Damage System attached.

When this objects health is zero this ds_nKo() event is triggered
NOTE: This Object must have a micro script attached to receive this event. Also this event is local to this object only.

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

function ds_onKo()
    sky.print("KO - BOOOOM"); 
end
void Basic_Events::ds_onDamage ( int  health,
int  damage,
int  attackingID 
)

This event is called from the Damage System to a script attached to the object with the Damage Action attached.

Parameters
health: The objects remaining health
damage: The current amaount of damage that has reduced the health.
attackingID: The ID of the object causing damage. The name can be got from entity.getName(attackingID);

When this objects gets damaged this event passes the objects health and amount of damaged caused to this event.
NOTE: This Object must have a script and Damage Action attached to receive this event. Also this event is local to this object only.

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

function ds_onDamage( health, damage, attackingID )
    sprint("Damage: "..damage.."  Health : "..health.." Attacker : "..entity.getName(attackingID),1);
end
void Basic_Events::fps_DamageEvent ( targetID  ,
targetName  ,
targetHealth  ,
scoreValue   
)

This event is called from the FPS System to a micro script attached to the player with the FPS System attached.

Parameters
targetID: The ID of the object the player shot.
targetName: The name of the object the player shot.
targetHealth: The health of the object the player shot.
scoreValue: The value assigned to this object of the object the player shot.

When the player shoots an object containing the damage system this event is called providing the plyer with the damaged objects data.
NOTE: This player must have a micro script attached to receive this event. Also this event is local to the player only.

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

function fps_DamageEvent(targetID, targetName, targetHealth, scoreValue)
    sky.ui_clear();
    sky.print("targetID: "..targetID);
    sky.print("targetName: "..targetName);
    sky.print("targetHealth: "..targetHealth);
    sky.print("scoreValue: "..scoreValue);
end
void Basic_Events::fps_Pickup ( itemType  ,
itemName  ,
itemValue   
)

This event is called from the FPS System to a micro script attached to the player with the FPS System attached.

Parameters
itemType: The item type the pickup has been assigned.
itemName: The item name the pickup has been assigned.
itemValue: The item value the pickup has been assigned.

When a player with the FPS System action collides with an object carrying the pickup action this event will be called.
NOTE: This player must have a micro script attached to receive this event. Also this event is local to the player only.

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

function fps_Pickup(itemType,itemName,itemValue)
    sky.ui_clear();
    sky.print("itemType: "..itemType);
    sky.print("itemName: "..itemName);
    sky.print("itemValue: "..itemValue);
end
void Basic_Events::fps_PlayerDamage ( damageAmount  ,
objectID   
)

This event is called from the FPS System to a micro script attached to the player with the FPS System attached.

Parameters
damageAmount: The damageAmount.
objectID: The ID of the object causing the damage.

If the fpsSystem.damagePlayer(playerID , damageAmount) command has been called then this event will be triggered
NOTE: This player must have a micro script attached to receive this event. Also this event is local to the player only.

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

function fps_PlayerDamage(damageAmt)
    sky.print("Player Damaged: "..damageAmt)
end
void Basic_Events::fps_Shoot ( contact_X  ,
contact_Y  ,
contact_Z   
)

This event is called from the FPS System to a micro script attached to the player with the FPS System attached.

Parameters
contact_X: The x position where the shot hits.
contact_y: The y position where the shot hits
contact_z: The z position where the shot hits

When the FPS System player shoots this event is triggered.
NOTE: This player must have a micro script attached to receive this event. Also this event is local to the player only.

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

function fps_Shoot(cx,cy,cz)
    sky.print("Posx: "..cx.."  Posy: "..cy.."  Posz: "..cz,1);
end
void Basic_Events::game_DamageEvent ( Value  ,
string  ,
Value  ,
Value   
)
void Basic_Events::game_Pickup ( fps_itemType  ,
fps_itemName  ,
val   
)
void Basic_Events::game_PlayerDamage ( str  )
void Basic_Events::game_Shoot ( )
void Basic_Events::globalFn ( int  callingID,
string  value 
)

This event is called is called from the sky.callGlobalFn(objID,value)
and will make a call to every script that contains this function.

Parameters
callingID: the numeric ID of the entity owning the script that made the call to the global function.
value: This can be any value of any type which is passed from the calling script.

This event is called from another script by using the command callGlobalFn(entityID, value)

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

function globalFn( callingID, value )
    if(callingID == playerID) then
        shieldStrength = shieldStrength - value;
        if(shieldStrength<=0) then
            shieldStrength = 0;
            sound.play2DSound( boomSound_ID );
            spawnExplosion();
        end
    end
end
void Basic_Events::onClick ( int  hitID)

This Event is triggered if the game.clickObject() has been called. The object that has been clicked on must contain a script containing this onClick() event function.

Parameters
hitID: the numeric ID of the the clicked object.

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

-- Put this function some when in your main project script
function onMouseDown(button,x,y) 
    sky.lprint("click");
    game.clickObject(); 
end

-- Add this event to any object you wish to receive the mouse click.
function onClick( hitID )
    count=count+1;
    sky.lprint(count);
end
void Basic_Events::onClick_GameOver ( )
void Basic_Events::onClick_GamePaused ( )
void Basic_Events::onClick_GameStart ( )
void Basic_Events::onClick_GameWin ( int  objID)
void Basic_Events::onClick_User1 ( int  ID) -> User10(int ID)
void Basic_Events::onCollision_End ( int  hitID)

PhysX Event callback when the obejcts move appart and stop colliding.

Parameters
hitID: the numeric ID of the object collided with

Called once as the objects part contact.

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

function onCollision_End(int hitID)
    sound.play2DSound( sound_ID );
end
void Basic_Events::onCollision_Start ( int  hitID)

PhysX Event callback when 2 objects make the initial collision.

Parameters
hitID: the numeric ID of the object collided with

Called once on contact.

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

function onCollision_Start(int hitID)
    sound.play2DSound( sound_ID );
end
void Basic_Events::onCollision_Stay ( int  hitID)

PhysX Event continiously called callback when 2 objects are overlapping.

Parameters
hitID: the numeric ID of the object collided with

Called continiously as the objects stay in contact The following is a Small Example on how to use this function:

function onCollision_Stay(int hitID)
    sound.play2DSound( sound_ID );
end
void Basic_Events::onEditorClose ( )
void Basic_Events::onEditorOpen ( )
void Basic_Events::onEnter ( )
void Basic_Events::onEnter_GameOver ( )
void Basic_Events::onEnter_GamePaused ( )
void Basic_Events::onEnter_GameStart ( )
void Basic_Events::onEnter_GameWin ( )
void Basic_Events::onEnter_User1 ( ) -> User10()

A set of User events ranging from User1() to User10()

Parameters
GameState : To access the User states use the following game state IDs.

game state ID 6 = User1
game state ID 7 = User2
game state ID 8 = User3
game state ID 9 = User4
game state ID 10 = User5
game state ID 11 = User6
game state ID 12 = User7
game state ID 13 = User8
game state ID 14 = User9
game state ID 15 = User10
The state system has a set of User states which behave in the same way as the Main Game state but use the suffix onEventType_User1-10() The following is a Small Example on how to use this function:

function onEnter_User1(td)
    -- do somthing
end
void Basic_Events::onExit ( )
void Basic_Events::onExit_GameOver ( )
void Basic_Events::onExit_GamePaused ( )
void Basic_Events::onExit_GameStart ( )
void Basic_Events::onExit_GameWin ( )
void Basic_Events::onExit_User1 ( ) -> User10()
void Basic_Events::onInit ( object_ID  )

Event called when you press the play button or the game initialises from the stand alone version.

Parameters
object_ID: the numeric ID of the parent entity. Use this ID when refering to this entity.

This event passes the ID number of the parent entity of this script.

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

-- make this entitys ID available globally to this script.
obj = 0; 

function onInit(objID)
    obj =  objID;
end
void Basic_Events::onJSAxisMoved ( int  axis,
int  value 
)
void Basic_Events::onJSAxisMoved_GameOver ( int  axis,
int  value 
)
void Basic_Events::onJSAxisMoved_GamePaused ( int  axis,
int  value 
)
void Basic_Events::onJSAxisMoved_GameStart ( int  axis,
int  value 
)
void Basic_Events::onJSAxisMoved_GameWin ( int  axis,
int  value 
)
void Basic_Events::onJSAxisMoved_User1 ( int  axis,
int  value 
)
void Basic_Events::onJSAxisMoved_User10 ( int  axis,
int  value 
)
void Basic_Events::onJSAxisMoved_User2 ( int  axis,
int  value 
)
void Basic_Events::onJSAxisMoved_User3 ( int  axis,
int  value 
)
void Basic_Events::onJSAxisMoved_User4 ( int  axis,
int  value 
)
void Basic_Events::onJSAxisMoved_User5 ( int  axis,
int  value 
)
void Basic_Events::onJSAxisMoved_User6 ( int  axis,
int  value 
)
void Basic_Events::onJSAxisMoved_User7 ( int  axis,
int  value 
)
void Basic_Events::onJSAxisMoved_User8 ( int  axis,
int  value 
)
void Basic_Events::onJSAxisMoved_User9 ( int  axis,
int  value 
)
void Basic_Events::onJSButtonPressed ( int  button)
void Basic_Events::onJSButtonPressed_GameOver ( int  button)
void Basic_Events::onJSButtonPressed_GamePaused ( int  button)
void Basic_Events::onJSButtonPressed_GameStart ( int  button)
void Basic_Events::onJSButtonPressed_GameWin ( int  button)
void Basic_Events::onJSButtonPressed_User1 ( int  button)
void Basic_Events::onJSButtonPressed_User10 ( int  button)
void Basic_Events::onJSButtonPressed_User2 ( int  button)
void Basic_Events::onJSButtonPressed_User3 ( int  button)
void Basic_Events::onJSButtonPressed_User4 ( int  button)
void Basic_Events::onJSButtonPressed_User5 ( int  button)
void Basic_Events::onJSButtonPressed_User6 ( int  button)
void Basic_Events::onJSButtonPressed_User7 ( int  button)
void Basic_Events::onJSButtonPressed_User8 ( int  button)
void Basic_Events::onJSButtonPressed_User9 ( int  button)
void Basic_Events::onJSButtonReleased ( int  button)
void Basic_Events::onJSButtonReleased_GameOver ( int  button)
void Basic_Events::onJSButtonReleased_GamePaused ( int  button)
void Basic_Events::onJSButtonReleased_GameStart ( int  button)
void Basic_Events::onJSButtonReleased_GameWin ( int  button)
void Basic_Events::onJSButtonReleased_User1 ( int  button)
void Basic_Events::onJSButtonReleased_User10 ( int  button)
void Basic_Events::onJSButtonReleased_User2 ( int  button)
void Basic_Events::onJSButtonReleased_User3 ( int  button)
void Basic_Events::onJSButtonReleased_User4 ( int  button)
void Basic_Events::onJSButtonReleased_User5 ( int  button)
void Basic_Events::onJSButtonReleased_User6 ( int  button)
void Basic_Events::onJSButtonReleased_User7 ( int  button)
void Basic_Events::onJSButtonReleased_User8 ( int  button)
void Basic_Events::onJSButtonReleased_User9 ( int  button)
void Basic_Events::onJSliderMoved ( int  sliderID)
void Basic_Events::onJSliderMoved_GameOver ( int  sliderID)
void Basic_Events::onJSliderMoved_GamePaused ( int  sliderID)
void Basic_Events::onJSliderMoved_GameStart ( int  sliderID)
void Basic_Events::onJSliderMoved_GameWin ( int  sliderID)
void Basic_Events::onJSliderMoved_User1 ( int  sliderID)
void Basic_Events::onJSliderMoved_User10 ( int  sliderID)
void Basic_Events::onJSliderMoved_User2 ( int  sliderID)
void Basic_Events::onJSliderMoved_User3 ( int  sliderID)
void Basic_Events::onJSliderMoved_User4 ( int  sliderID)
void Basic_Events::onJSliderMoved_User5 ( int  sliderID)
void Basic_Events::onJSliderMoved_User6 ( int  sliderID)
void Basic_Events::onJSliderMoved_User7 ( int  sliderID)
void Basic_Events::onJSliderMoved_User8 ( int  sliderID)
void Basic_Events::onJSliderMoved_User9 ( int  sliderID)
void Basic_Events::onJSPovMoved ( String  direction)
void Basic_Events::onJSPovMoved_GameOver ( String  direction)
void Basic_Events::onJSPovMoved_GamePaused ( String  direction)
void Basic_Events::onJSPovMoved_GameStart ( String  direction)
void Basic_Events::onJSPovMoved_GameWin ( String  direction)
void Basic_Events::onJSPovMoved_User1 ( String  direction)
void Basic_Events::onJSPovMoved_User10 ( String  direction)
void Basic_Events::onJSPovMoved_User2 ( String  direction)
void Basic_Events::onJSPovMoved_User3 ( String  direction)
void Basic_Events::onJSPovMoved_User4 ( String  direction)
void Basic_Events::onJSPovMoved_User5 ( String  direction)
void Basic_Events::onJSPovMoved_User6 ( String  direction)
void Basic_Events::onJSPovMoved_User7 ( String  direction)
void Basic_Events::onJSPovMoved_User8 ( String  direction)
void Basic_Events::onJSPovMoved_User9 ( String  direction)
void Basic_Events::onKeyDown ( string  key)
void Basic_Events::onKeyDown_GameOver ( string  key)
void Basic_Events::onKeyDown_GamePaused ( string  key)
void Basic_Events::onKeyDown_GameStart ( string  key)
void Basic_Events::onKeyDown_GameWin ( string  key)
void Basic_Events::onKeyDown_User1 ( string  key) -> User10(string key)
void Basic_Events::onKeyUp ( string  key)
void Basic_Events::onKeyUp_GameOver ( string  key)
void Basic_Events::onKeyUp_GamePaused ( string  key)
void Basic_Events::onKeyUp_GameStart ( string  key)
void Basic_Events::onKeyUp_GameWin ( string  key)
void Basic_Events::onKeyUp_User1 ( string  key) -> User10(string key)
void Basic_Events::onMouseDown ( int  button,
int  x,
int  y 
)
void Basic_Events::onMouseDown_GameOver ( int  button,
int  x,
int  y 
)
void Basic_Events::onMouseDown_GamePaused ( int  button,
int  x,
int  y 
)
void Basic_Events::onMouseDown_GameStart ( int  button,
int  x,
int  y 
)
void Basic_Events::onMouseDown_GameWin ( int  button,
int  x,
int  y 
)
void Basic_Events::onMouseDown_User1 ( int  button,
int  x,
int  y 
) -> User10(int button, int x, int y)
void Basic_Events::onMouseMove ( int  x,
int  y 
)
void Basic_Events::onMouseMove_GameOver ( int  x,
int  y 
)
void Basic_Events::onMouseMove_GamePaused ( int  x,
int  y 
)
void Basic_Events::onMouseMove_GameStart ( int  x,
int  y 
)
void Basic_Events::onMouseMove_GameWin ( int  x,
int  y 
)
void Basic_Events::onMouseMove_User1 ( int  x,
int  y 
) -> User10(int x, int y)
void Basic_Events::onMouseUp ( int  button,
int  x,
int  y 
)
void Basic_Events::onMouseUp_GameOver ( int  button,
int  x,
int  y 
)
void Basic_Events::onMouseUp_GamePaused ( int  button,
int  x,
int  y 
)
void Basic_Events::onMouseUp_GameStart ( int  button,
int  x,
int  y 
)
void Basic_Events::onMouseUp_GameWin ( int  button,
int  x,
int  y 
)
void Basic_Events::onMouseUp_User1 ( int  button,
int  x,
int  y 
) -> User10(int button, int x, int y)
void Basic_Events::onResize ( int  width,
int  height 
)

Event gets called from either the editor or player when they are resized.

Parameters
width: The new screen width after resizing.
height: The new screen height after resizing.

When the system resize event is called it is then passed through to Lua via this event function.

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

function onResize(width,height)
    sky.print("width: "..width.."  height: "..height); 
end
void Basic_Events::onSceneCollision_End ( int  hitID1,
int  hitID2 
)

PhysX Scene script event callback when the obejcts move appart and stop colliding.

Parameters
hitID1: the int numeric ID of the first object of the pair that collided.
hitID2: the int numeric ID of the first object of the pair that collided.

Called once as the objects part contact.

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

function onSceneCollision_End(int hitID1, int hitID2)
    sound.play2DSound( sound_ID );
end
void Basic_Events::onSceneCollision_Start ( int  hitID1,
int  hitID2 
)

PhysX Scene script event callback when 2 objects make the initial collision.

Parameters
hitID1: the int numeric ID of the first object of the pair that collided.
hitID2: the int numeric ID of the first object of the pair that collided.

Called once on contact.

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

function onSceneCollision_Start(int hitID1, int hitID2)
    sound.play2DSound( sound_ID );
end
void Basic_Events::onSceneCollision_Stay ( int  hitID1,
int  hitID2 
)

PhysX Scene script event continiously called callback when 2 objects are overlapping.

Parameters
hitID1: the int numeric ID of the first object of the pair that collided.
hitID2: the int numeric ID of the first object of the pair that collided.

Called continiously as the objects stay in contact The following is a Small Example on how to use this function:

function onSceneCollision_Stay(int hitID1, int hitID2)
    sound.play2DSound( sound_ID );
end
void Basic_Events::onSensorContact_Enter ( objID  )

This event is called from the Damage System to a micro script attached to the object with the Damage System attached.

Parameters
health: The objects remaining health
damage: The current amaount of damage that has reduce the health.
void Basic_Events::onSensorContact_Exit ( objID  )
void Basic_Events::onSensorContact_Stay ( objID  ,
distance   
)
void Basic_Events::onStop ( )

Event called when you press the Stop button and before the system goes back to editing mode.

Parameters
object_ID: the numeric ID of the parent entity. Use this ID when refering to this entity.

It is wise to add any clean up code you need, to this function.

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

function onStop(objID)
    particle.deleteParticle( particleFX_ID );
end
void Basic_Events::onStop_GameOver ( )
void Basic_Events::onStop_GamePaused ( )
void Basic_Events::onStop_GameStart ( )
void Basic_Events::onStop_GameWin ( )
void Basic_Events::onStop_User1 ( ) -> User10()
void Basic_Events::onTimer ( )
void Basic_Events::onTrigger_Enter ( int  hitID)

PhysX Event callback called when the object enters a physx trigger.

Parameters
hitID: the numeric ID of the object collided with

Called once as the object make initial contact with the trigger.

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

function onTrigger_Enter(int hitID)
    sound.play2DSound( sound_ID );
end
void Basic_Events::onTrigger_Leave ( int  hitID)

PhysX Event callback called on leaving contact with a physx trigger.

Parameters
hitID: the numeric ID of the object collided with

Called once as the object leaves the trigger volume.

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

function onTrigger_Leave(int hitID)
    sound.play2DSound( sound_ID );
end
void Basic_Events::onTrigger_Stay ( int  hitID)

PhysX Event callback called whilst the object is inside a physx trigger.

Parameters
hitID: the numeric ID of the object collided with

Called continiously as the object is inside the trigger volume.

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

function onTrigger_Stay(int hitID)
    sound.play2DSound( sound_ID );
end
void Basic_Events::onTriggerBoxEnter ( )

Called an entity collides with a trigger box.

The script containing this event must be attached to an entity with a trigger action in order to work.

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

function onInit(objID)
    sky.lprint("\n Lua:: Default onInit() called OK"); 
    ui.enableDefaultUI( 0 );    
    ui.newLayer("ui");
    ui.setLayer("ui");
    ui.setFontSize(24)
    ui.newText("text",10,60);
    ui.setColor("text",0.8,0.8,1.0);
    ui.text("text","Message: Waiting.....");
end

-- | Trigger Start: Trigger box has been entered
function onTriggerBoxEnter()
    ui.text("text","Message: ** TRIGGERED **");
    id = entity.getEntityIDFromTag("spinme")
    entity.setActionParam(id,1,"Rotate Enabled","1");
end

-- | Trigger End: Trigger box has been exited
function onTriggerBoxExit()
    ui.text("text","Message: Waiting.....");
    id = entity.getEntityIDFromTag("spinme")
    entity.setActionParam(id,1,"Rotate Enabled","0");
end
void Basic_Events::onTriggerBoxExit ( )

Called after an entity collides with a trigger box and leaves again.

The script containing this event must be attached to an entity with a trigger action in order to work

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

function onInit(objID)
    sky.lprint("\n Lua:: Default onInit() called OK"); 
    ui.enableDefaultUI( 0 );    
    ui.newLayer("ui");
    ui.setLayer("ui");
    ui.setFontSize(24)
    ui.newText("text",10,60);
    ui.setColor("text",0.8,0.8,1.0);
    ui.text("text","Message: Waiting.....");
end

-- | Trigger Start: Trigger box has been entered
function onTriggerBoxEnter()
    ui.text("text","Message: ** TRIGGERED **");
    id = entity.getEntityIDFromTag("spinme")
    entity.setActionParam(id,1,"Rotate Enabled","1");
end

-- | Trigger End: Trigger box has been exited
function onTriggerBoxExit()
    ui.text("text","Message: Waiting.....");
    id = entity.getEntityIDFromTag("spinme")
    entity.setActionParam(id,1,"Rotate Enabled","0");
end
void Basic_Events::onTriggerEnd_GameWin ( )
void Basic_Events::onTriggerStart_GameWin ( )
void Basic_Events::onUpdate ( float  timeDelta)
void Basic_Events::onUpdate_GameOver ( float  timeDelta)
void Basic_Events::onUpdate_GamePaused ( float  timeDelta)
void Basic_Events::onUpdate_GameStart ( float  timeDelta)
void Basic_Events::onUpdate_User1 ( ) -> User10()
void Basic_Events::publicFn ( int  callingID,
string  value 
)

This scripts function event is called from another script to trigger local functions and pass
data between scripts.

Parameters
callingID: the numeric ID of the entity owning the script that called the publicFn().
value: This can be any value of any type which is passed from another other script.

This event is called from another script by using the command callPublicFn(entityID, targetID, value)

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

function publicFn( callingID, value )
    if(callingID == playerID) then
        shieldStrength = shieldStrength - value;
        if(shieldStrength<=0) then
            shieldStrength = 0;
            sound.play2DSound( boomSound_ID );
            spawnExplosion();
        end
    end
end
void Basic_Events::SetDynamicProperty ( eID  ,
"Param"  ,
"Value"   
)
void Basic_Events::update_GameWin ( )
void Basic_Events::updateDefaultGUI_Screen ( scene.sceneScript.  scriptID)

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