Input
Keyboard, mapped axes and actions, and the mouse. Dryad mirrors them with caffeine_input_* natives.
Namespace: caffeine.input · Dryad prefix: caffeine_input_
isKeyDown#
Lua: caffeine.input.isKeyDown · Dryad: caffeine_input_key_down
isKeyDown(name) -> boolean
Checks whether a keyboard key is held.
| Parameters | Type | Description |
|---|---|---|
name | string | Key name such as "Space", "W", "Up", "LShift", "Escape", "0"-"9". |
Returns: boolean. True while the key is held; false for an unknown name or without input.
Example
if caffeine.input.isKeyDown('Space') then end
getAxis#
Lua: caffeine.input.getAxis · Dryad: caffeine_input_axis
getAxis(name) -> number
Reads a mapped input axis.
| Parameters | Type | Description |
|---|---|---|
name | string | Axis: Horizontal, Vertical, LookX, LookY. |
Returns: number. Axis value; 0 for an unknown name or without input.
Example
local h = caffeine.input.getAxis('Horizontal')
isActionDown#
Lua: caffeine.input.isActionDown · Dryad: caffeine_input_action_down
isActionDown(name) -> boolean
Checks whether a mapped action is held.
| Parameters | Type | Description |
|---|---|---|
name | string | Action: MoveUp, MoveDown, MoveLeft, MoveRight, Jump, Attack, Interact, Pause. |
Returns: boolean. True while the action is held.
Example
if caffeine.input.isActionDown('Jump') then end
isActionPressed#
Lua: caffeine.input.isActionPressed · Dryad: caffeine_input_action_pressed
isActionPressed(name) -> boolean
Checks whether a mapped action was just pressed this frame.
| Parameters | Type | Description |
|---|---|---|
name | string | Action: MoveUp, MoveDown, MoveLeft, MoveRight, Jump, Attack, Interact, Pause. |
Returns: boolean. True only on the frame the action started.
Example
if caffeine.input.isActionPressed('Attack') then end
mouseDelta#
Lua: caffeine.input.mouseDelta
mouseDelta() -> number, number
Mouse movement since the previous frame. Returns two values, not a table.
Returns: number, number. dx, dy (two return values).
Example
local dx, dy = caffeine.input.mouseDelta()
mousePosition#
Lua: caffeine.input.mousePosition
mousePosition() -> number, number
Mouse position as reported by the input manager. Returns two values, not a table.
Returns: number, number. x, y (two return values).
Example
local mx, my = caffeine.input.mousePosition()
isMouseButtonDown#
Lua: caffeine.input.isMouseButtonDown · Dryad: caffeine_input_mouse_down
isMouseButtonDown(button) -> boolean
Checks whether a mouse button is held.
| Parameters | Type | Description |
|---|---|---|
button | integer | 1 left, 2 middle, 3 right. |
Returns: boolean. True while held; false for any other number.
Example
if caffeine.input.isMouseButtonDown(1) then end
caffeine_input_mouse_x#
Lua: not available · Dryad: caffeine_input_mouse_x
caffeine_input_mouse_x() -> number
Dryad only: mouse x position.
Returns: number. Mouse x position; 0 without input.
Example
let v = caffeine_input_mouse_x();
caffeine_input_mouse_y#
Lua: not available · Dryad: caffeine_input_mouse_y
caffeine_input_mouse_y() -> number
Dryad only: mouse y position.
Returns: number. Mouse y position; 0 without input.
Example
let v = caffeine_input_mouse_y();
caffeine_input_mouse_dx#
Lua: not available · Dryad: caffeine_input_mouse_dx
caffeine_input_mouse_dx() -> number
Dryad only: mouse x movement since the previous frame.
Returns: number. Mouse x movement since the previous frame; 0 without input.
Example
let v = caffeine_input_mouse_dx();
caffeine_input_mouse_dy#
Lua: not available · Dryad: caffeine_input_mouse_dy
caffeine_input_mouse_dy() -> number
Dryad only: mouse y movement since the previous frame.
Returns: number. Mouse y movement since the previous frame; 0 without input.
Example
let v = caffeine_input_mouse_dy();