input — Luau Binding
require("input"): the per-tick snapshot of keyboard, gamepad, and pointer — buttons, axes, pointer, and bound actions — plus record / replay. The programmatic surface of the input system. Every function is[antos].
Status: design. Not built yet.
local input = require("input")
Buttons, axes, pointer
Everything reads the tick's latched snapshot, so results are stable for the whole frame.
| Call | Returns | Does |
|---|---|---|
input.down(button) |
bool |
held this tick |
input.pressed(button) |
bool |
went down this tick (edge) |
input.released(button) |
bool |
went up this tick (edge) |
input.axis(name) |
number |
an axis in −1…1 — a stick / trigger, or a named digital axis ("moveX") |
input.pointer() |
{ x, y, buttons } |
pointer position and buttons |
Actions
| Call | Returns | Does |
|---|---|---|
input.bind(action, inputs) |
ok |
map a logical action to a list of buttons / axes — bind("jump", { "space", "gamepad:A" }) |
input.action(name) |
{ down, pressed, released, value } |
the bound action's state this tick |
local input = require("input")
input.bind("jump", { "space", "gamepad:A" })
input.bind("moveX", { "left", "right", "gamepad:lx" }) -- a named axis
-- in a per-tick update:
if input.action("jump").pressed then physics.impulse(hero, 0, -1200) end
hero.vx = input.axis("moveX") * SPEED
Record and replay
| Call | Returns | Does |
|---|---|---|
input.record() |
ok |
begin capturing the per-tick snapshot stream |
input.stop_record() |
rec |
end capture, return the stream |
input.replay(rec) |
ok |
feed a recorded stream instead of the devices — with the same seed, an exact rerun (demos, deterministic tests, bug repro) |