CraftStudio Wiki
CraftStudio Wiki

Your game's controls (axes and buttons) are defined in the project's administration tab.

CraftStudio.Input.GetAxisValue[]

[number] CraftStudio.Input.GetAxisValue( [string] axis name )

Returns the specified axis' numerical value.

The value will be in the (-1, 1) range unless it's a mouse move value, in which case its the mouse's delta in pixels since the last frame.

CraftStudio.Input.IsButtonDown[]

[boolean] CraftStudio.Input.IsButtonDown( [string] button name )

Returns true if the specified button is currently pressed, false otherwise.

CraftStudio.Input.WasButtonJustPressed[]

[boolean] CraftStudio.Input.WasButtonJustPressed( [string] button name )


Returns true if the specified button was pressed during the last tick (1/60th of a second), false otherwise.

CraftStudio.Input.WasButtonJustReleased[]

[boolean] CraftStudio.Input.WasButtonJustReleased( [string] button name )

Returns true if the specified button was released during the last tick (1/60th of a second), false otherwise.

CraftStudio.Input.SetMouseVisible[]

CraftStudio.Input.SetMouseVisible( [boolean] visible )

Defines whether the mouse cursor should be visible or not while in the game's window. (This does not lock the mouse.)

Calls to this function while the mouse is locked will be ignored.

CraftStudio.Input.LockMouse[]

CraftStudio.Input.LockMouse()

Hides the mouse cursor and locks it inside the game's window. Useful for games using the mouse to allow looking around.

CraftStudio.Input.UnlockMouse[]

CraftStudio.Input.UnlockMouse()

Unlocks the mouse after it has been locked with CraftStudio.Input.LockMouse.

CraftStudio.Input.GetMousePosition[]

​[table] CraftStudio.Input.GetMousePosition()

Returns a table with x and y containing the mouse position in pixels. x=0 is left, y=0 is top.

You probably don't want to call this function after the mouse has been locked with CraftStudio.Input.LockMouse as the hidden mouse will be kept in the center of the window.

CraftStudio.Input.GetMouseDelta[]

​[table] CraftStudio.Input.GetMouseDelta()

Returns a table with x and y containing the mouse delta since last frame in pixels. Positive x is right, positive y is bottom.

This function is particularly useful for mouse look after calling CraftStudio.Input.LockMouse.

Xbox 360 gamepad button mapping[]

Button indices for the Xbox 360 gamepad:

  • DPadUp = 0
  • DPadDown = 1
  • DPadLeft = 2
  • DPadRight = 3
  • Start = 4
  • Back = 5
  • LeftStick = 6
  • RightStick = 7
  • LeftShoulder = 8
  • RightShoulder = 9
  • BigButton = 11
  • A = 12
  • B = 13
  • X = 14
  • Y = 15
  • LeftThumbstickLeft = 21
  • RightTrigger = 22
  • LeftTrigger = 23
  • RightThumbstickUp = 24
  • RightThumbstickDown = 25
  • RightThumbstickRight = 26
  • RightThumbstickLeft = 27
  • LeftThumbstickUp = 28
  • LeftThumbstickDown = 29
  • LeftThumbstickRight = 30

Axis indices:

  • 0 = Left stick, horizontal
  • 1 = Left stick, vertical
  • 2 = Right stick, horizontal
  • 3 = Right stick, vertical
  • 4 = Left trigger
  • 5 = Right trigger