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

#include <LUA_API_Input.h>

Public Member Functions

int keyDown (String Key)
 This function can be used to detect keys that are held down. More...
 
int keyHit (String Key)
 This function can be used to detect keys that are pressd once or want to trigger code only once. More...
 
int releaseKey (String Key)
 Use this function to free an key that is held down and is being monitored by the keyDown(key) method. More...
 
int mouseDown (int button)
 Detect if the specified mouse button is pressed. More...
 
int mouseHit (int button)
 Detect if the specified mouse button is clicked. More...
 
 getFromMap (int id, string keyMapName)
 getFromMap(int id, string keyMapName). More...
 

Detailed Description

This area covers User input functions. Skyline Lua can intercept input events a check their current state. You can check to see if
a specified key is held down or detect the left mouse buttom. This does not effect the system events and can be used together with them. Use as input.function()

Member Function Documentation

input::getFromMap ( int  id,
string  keyMapName 
)

getFromMap(int id, string keyMapName).

Parameters
intid : Define the button you want to check against.
stringkeymap :
  • Will be used for easy control of keys for forwards, backwards, etc...
  • IGNORE this for now as it is not usable yet.
    function 
        getFromMap(int id, string keyMapName)
    end
int input::keyDown ( String  Key)

This function can be used to detect keys that are held down.

Parameters
StringKey : Define the key you want to check.
Returns
1 for as long as the specified key is held down else return 0.

This function can be called from another function such as the onUpdate(..) to detect if the specified key is held down. the value 1
is return as long as the specified key is held down. This is unlike the keyHit(key) which returns 1 then reverts to 0 again.

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

function onUpdate( timeDelta )
    if( input.keyDown( "z" ) == 1) then entity.move(obj,-0.001,0,0);end
    if( input.keyDown( "x" ) == 1) then entity.move(obj,0.001,0,0); end
end
int input::keyHit ( String  Key)

This function can be used to detect keys that are pressd once or want to trigger code only once.

Parameters
StringKey : Define the key you want to check.
Returns
The defined keys state either 1= for held down or 0 for released.

This function can be called from another function to detect if the specified key has been pressed. This will only trigger once
per key press not matter how long the key is help. This is unlike the keyDown(key) method which returns 1 as long as the key is held.

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

function onUpdate( timeDelta )
    if( input.keyHit( "space" ) == 1) then sky.lprint("Shoot  !");  end
end
int input::mouseDown ( int  button)

Detect if the specified mouse button is pressed.

Parameters
intButton : Define the button you want to check against.
Returns
1 for as long as the specified button is held down else return 0.

Detect if the specified mouse button is being held down.Pass the value 1 to check for the left button presses and 2 the for right button

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

function onUpdate( timeDelta )
    if( input.mouseDown( 1 ) == 1) then sky.lprint("you pressed the Left mouse button"); end
    if( input.mouseDown( 2 ) == 1) then sky.lprint("you pressed the Right mouse button"); end
end
int input::mouseHit ( int  button)

Detect if the specified mouse button is clicked.

Parameters
intButton : Define the button you want to check against.
Returns
1 when the specified button is first pressed then return 0.

Use this function if you only need to detect if the specified button has been clicked. This differs to mouseDown(button) which detects button being held down The following is a Small Example on how to use this function:

function onUpdate( timeDelta )
    if( input.mouseHit( 1 ) == 1) then sky.lprint("LMB");   end
    if( input.mouseHit( 2 ) == 1) then sky.lprint("RMB");   end
end
int input::releaseKey ( String  Key)

Use this function to free an key that is held down and is being monitored by the keyDown(key) method.

Parameters
StringKey : Define the key you want to release.

Call this function to release the specified key, ie the key will return 0 to any code monitoring it, such as the keyDown(key) method
per key press not matter how long the key is help.

The releaseKey(key) function works well in conjunction with keyDown(key) if you are creating a simple player controller as it can
prevent key lock, ie when you try to press both keys together.

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

function onUpdate( timeDelta )
    if( input.keyDown( "z" ) == 1) then entity.move(obj,-0.001,0,0); input.releaseKey("x"); end
    if( input.keyDown( "x" ) == 1) then entity.move(obj,0.001,0,0); input.releaseKey("z");  end
end

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