GearBlocks
The GearBlocks Lua scripting API
Static Public Member Functions | Properties | List of all members
SmashHammer.Scripting.InputProxy Class Reference

The input system. More...

Static Public Member Functions

static float GetAxis (string axisName)
 Get the value of an input axis.
 
static bool GetKey (string keyName)
 Is a key held?
 
static bool GetKeyDown (string keyName)
 Was a key pressed?
 
static bool GetKeyUp (string keyName)
 Was a key released?
 
static bool GetMouseButton (int button)
 Is a mouse button held?
 
static bool GetMouseButtonDown (int button)
 Was a mouse button pressed?
 
static bool GetMouseButtonUp (int button)
 Was a mouse button released?
 

Properties

static bool AnyKey [get]
 Is any key held?
 
static bool AnyKeyDown [get]
 Was any key pressed?
 
static Vector3Proxy MousePosition [get]
 The mouse position.
 

Detailed Description

The input system.

Available in Lua via the "Input" global, for example:

if Input.GetKeyDown( 'j' ) then
print( 'Key pressed' )
end

Member Function Documentation

◆ GetAxis()

static float SmashHammer.Scripting.InputProxy.GetAxis ( string  axisName)
static

Get the value of an input axis.

Parameters
axisNameThe name of the axis to check.

Valid axis names are:

  • Mouse directions: 'MouseX', 'MouseY', and 'MouseZ'
  • Joystick axes: 'Joystick0Axis0' to 'Joystick3Axis15'

A full list of available axis names can be found by typing LogAxisNames in the debug console.

Returns
The current value of the axis.

◆ GetKey()

static bool SmashHammer.Scripting.InputProxy.GetKey ( string  keyName)
static

Is a key held?

Parameters
keyNameThe name of the key to check.

Valid key names are:

  • Letter keys: 'a' to 'z'
  • Number keys: '0' to '9'
  • Arrow keys: 'up', 'down', 'left', 'right'
  • Numpad keys: 'numlock', '[0]' to '[9]', '[/]', '[*]', '[-]', '[+]', '[.]', 'enter'
  • Modifier keys: 'right shift', 'left shift', 'right ctrl', 'left ctrl', 'right alt', 'left alt', 'right cmd', 'left cmd'
  • Special keys: 'backspace', 'tab', 'return', 'escape', 'space', 'delete', 'insert', 'home', 'end', 'page up', 'page down'
  • Function keys: 'f1' to 'f15'
  • Symbol keys: '-', '=', '[', ']', ';', '\'', '\', ',', '.', '/', etc.
  • Mouse buttons: 'mouse 0' to 'mouse 6'
  • Buttons for any joystick: 'joystick button 0' to 'joystick button 19'
  • Buttons for specific joysticks: 'joystick 1 button 0' to 'joystick 16 button 19'

A full list of available key names can be found by typing LogKeyNames in the debug console.

Returns
true if the key is currently held; otherwise, false.

◆ GetKeyDown()

static bool SmashHammer.Scripting.InputProxy.GetKeyDown ( string  keyName)
static

Was a key pressed?

Parameters
keyNameThe name of the key to check.

See GetKey for key names.

Returns
true if the key was pressed this frame; otherwise, false.

◆ GetKeyUp()

static bool SmashHammer.Scripting.InputProxy.GetKeyUp ( string  keyName)
static

Was a key released?

Parameters
keyNameThe name of the key to check.

See GetKey for key names.

Returns
true if the key was released this frame; otherwise, false.

◆ GetMouseButton()

static bool SmashHammer.Scripting.InputProxy.GetMouseButton ( int  button)
static

Is a mouse button held?

Parameters
buttonThe index of the button to check.

Valid indices are between 0 and 6.

Returns
true if the button is currently held; otherwise, false.

◆ GetMouseButtonDown()

static bool SmashHammer.Scripting.InputProxy.GetMouseButtonDown ( int  button)
static

Was a mouse button pressed?

Parameters
buttonThe index of the button to check.

Valid indices are between 0 and 6.

Returns
true if the button was pressed this frame; otherwise, false.

◆ GetMouseButtonUp()

static bool SmashHammer.Scripting.InputProxy.GetMouseButtonUp ( int  button)
static

Was a mouse button released?

Parameters
buttonThe index of the button to check.

Valid indices are between 0 and 6.

Returns
true if the button was released this frame; otherwise, false.

Property Documentation

◆ AnyKey

bool SmashHammer.Scripting.InputProxy.AnyKey
staticget

Is any key held?

true if any key is currently held; otherwise, false.

◆ AnyKeyDown

bool SmashHammer.Scripting.InputProxy.AnyKeyDown
staticget

Was any key pressed?

true if any key was pressed this frame; otherwise, false.

◆ MousePosition

Vector3Proxy SmashHammer.Scripting.InputProxy.MousePosition
staticget

The mouse position.

The current mouse position in pixel coordinates.