Module m.input
Module to simplify input handling.
The module will keep track of pressed and released states for all input that it receives.
Usage:
local input = require "ludobits.m.input" function init(self) input.acquire() end function final(self) input.release() end function update(self, dt) if input.is_pressed(hash("left")) then go.set_position(go.get_position() - vmath.vector3(50, 0, 0) * dt) elseif input.is_pressed(hash("right")) then go.set_position(go.get_position() + vmath.vector3(50, 0, 0) * dt) end end function on_input(self, action_id, action) input.on_input(action_id, action) end
Functions
acquire (url) | Acquire input focus for the current script |
release (url) | Release input focus for the current script |
is_pressed (action_id) | Check if an action is pressed/active |
update (action_id, action) | Forward any calls to on_input from scripts using this module |
Functions
- acquire (url)
-
Acquire input focus for the current script
Parameters:
- url
- release (url)
-
Release input focus for the current script
Parameters:
- url
- is_pressed (action_id)
-
Check if an action is pressed/active
Parameters:
- action_id
Returns:
-
true if pressed/active
- update (action_id, action)
-
Forward any calls to on_input from scripts using this module
Parameters:
- action_id
- action