Skip to main content
reskate.input gives your plugin actions the player can press, and reads the keyboard, mouse, gamepad and joystick for a plugin that flies something or runs a game of its own. Every function, and the action event, needs the input permission, except reskate.input.write, which needs input.write; calling one without its permission raises an error. See permissions.

Actions

reskate.input.bind(action, key)

Puts a named action on a key or a pad combo. Each press fires the action event with the action’s name, once, while the game itself has the input: not while a menu, the console or a text box is open. The player sees your actions on the Binds page of ReSkate’s settings and can record another combo for any of them, or clear it. The player’s choice wins over yours and is kept between sessions.
string
required
The action’s name, 1 to 48 characters. It is what the action event hands your handler. Binding a name again replaces its combo.
string
A key, a key combo, or a pad combo, at most 60 characters (see below). nil (or nothing): no key of its own; the action is on the Binds page for the player to put on one.
boolean
True when the action is bound.
string
"that is not a key or pad combo" when ok is false.
A key name that is not one raises an error, as does a 17th action.
Needs the input permission. A plugin has at most 16 actions. When the plugin stops, its actions go away (the player’s choices for them are kept).

Key and pad combo names

A combo is names joined with +, with no spaces. Case does not matter. A combo is either keys or pad buttons, never both. Keys (up to 5 held together): Examples: "F7", "Ctrl+K", "Shift+Alt+1", "Space". Pad buttons, each written Pad. and the button: Examples: "Pad.A", "Pad.LB+Pad.RB", "Pad.Up+Pad.Y".

The action event

A combo fires once when all of it is held, and again only after it is let go. Registering a handler needs the input permission. See events.

Flight input

reskate.input.flight()

The flight keys and the mouse, as Freecam reads them, for a plugin that flies its own camera. It answers only while the plugin’s camera view is the one shown, the game window has the focus, and no ReSkate menu is open.
table or nil
nil when the plugin’s view is not shown, or the game cannot be read now.
The mouse’s movement is used up as it is read, and it is read once a tick: two calls in one tick see the same values.
Needs the input permission and a camera view of the plugin’s own (camera.look or camera.set).

Controllers

reskate.input.gamepad(controller)

A gamepad’s sticks, triggers and buttons. It reads the pad even while the game is kept from it (see capture), and it reads the real controller: a replacement from write is not what it returns.
number or string
Left out: the pads together, as the game sees them. An integer from 0 to 3: that one Xbox (XInput) controller. "playstation": the PlayStation controller ReSkate reads. Anything else raises an error.
table or nil
nil when no such pad is connected or the game window does not have the focus.
Needs the input permission.

reskate.input.joystick(device)

A joystick, RC radio or other game controller connected to Windows. With no device, one whose name holds “radio”, “EdgeTX” or “OpenTX” is chosen first, otherwise the lowest-numbered one.
integer
A controller’s number from joysticks(), 0 to 15. Leave it out for the first controller as above.
table or nil
nil when there is no such controller, or the game window does not have the focus.
ReSkate reads the controllers on a thread of its own, about 250 times a second, and this call returns the latest reading, so it never holds up your tick. Just after the first call, or after a controller is plugged in, it can take a moment to show up.
Needs the input permission. Before ReSkate 2.1.3 there were 6 axes, in Windows’ older order (X, Y, Z, R, U, V). A plugin that saved which axis is which should let players set them again.

reskate.input.joysticks()

Every game controller plugged in, so a player with a gamepad and a radio can pick which one your plugin reads.
table
A list, lowest number first, empty when none is plugged in. Each entry:
Needs the input permission.

reskate.input.capture(on)

Keeps the game from reading the controller, so the player can fly your camera with the pad without the skater moving too. Each call keeps it for 250 ms: call it every tick for as long as you want it. Your plugin still reads the pad with gamepad().
boolean
required
True to keep the controller for the next 250 ms, false (or nothing) to give it back now.
boolean
True when the controller is kept (or given back).
string
"only while the plugin's camera is shown" when ok is false.
Needs the input permission. It works only while the plugin’s own camera view is shown: when Spectate takes the camera, or the plugin releases it, the game has the controller again at once. One plugin captures at a time: the latest call wins.

reskate.input.hide(controls)

Keeps some of the pad’s controls from the game, for a plugin that gives them a job of its own, such as picking a grind’s exit with the triggers, or aiming a camera of its own with the right stick. A hidden trigger reads to the game as let go, a hidden stick as centred, and a hidden stick click as not pressed. The left stick’s left and right, hidden while grinding, read as centred only while the skater grinds, so a push held through the pop reaches the game at the pop. Your plugin still reads them all with gamepad().
table or nil
required
What to keep from the game. Each call replaces your plugin’s last one; nil or {} gives everything back.
boolean
True when the controls are hidden (or given back).
string
"hiding pad controls is unavailable for this game build" when ok is false.
Needs the input permission. Unlike capture, it needs no camera of your own and lasts until you change it. A control stays hidden while any plugin hides it. Your plugin reads the pad once a tick, so the game may see a trigger for a frame before you hide it. When the plugin stops, everything it hid is given back.

Controller layers

A controller layer reads a real controller with gamepad(controller), changes what it likes (sticks swapped, a button moved, a stick turned into another control), and hands the game the result with write. The control scheme lives in your Luau: ReSkate knows none. The rider observations and gameplay options go with it.

reskate.input.write(pad, controller)

Replaces everything the game reads from one real controller with pad, for the next 100 ms.
table or nil
required
The whole controller, in the units gamepad() gives. A control left out is neutral: centred, released, not pressed. nil lets go of your replacement.
number or string
default:"0"
An integer from 0 to 3 for that Xbox controller, or "playstation" for the PlayStation controller.
boolean
True when the replacement is in force (or let go).
string
When ok is false: "the game does not have gameplay input" (see allowed), or "<plugin> replaces this controller" when another plugin’s replacement is live.
A number outside its range or not finite, a value of the wrong type, a button that is not a boolean, or a controller that is not 0 to 3 or "playstation" raises an error. Your table is copied when you call: changing it afterwards changes nothing.
Needs the input.write permission; the player is asked for it apart from input, and input alone does not give it. A replacement lasts 100 ms: call it every tick. One plugin replaces each controller at a time, and another plugin cannot take or let go of a live one. Every replacement is dropped the moment the game window loses the focus, a menu takes the input or the cursor, or the game holds gameplay input, so an old one is never played back afterwards. Controls a plugin hides with hide stay hidden from the game on top of a replacement. Only a controller that is really there is replaced: write does not make up a controller that is not connected. Your plugin reads and writes once a tick, so changes between ticks can be missed. When the plugin stops, reloads or is stopped for its limits, its replacements end.

Raw input

These read the pad and the keyboard as they are, for a plugin with a game layer of its own: menus it draws, buttons it gives a job, things it places.

reskate.input.pad_bits(menu)

The gamepad’s buttons as one number of bits, XInput’s own, with the triggers added.
boolean
default:"false"
True to read the pad while ReSkate’s menu, console or a dialog is open too.
number or nil
The buttons held now. nil when no pad is connected, the game window does not have the focus, or (without menu) ReSkate’s menu is open.
Needs the input permission.

reskate.input.key(key)

Whether a key or a mouse button is held down now. It reads past a pause or a capture that keeps the input from the game. While the game window is not in front it answers false for every key, as the pad does: a key held in another program is not the game’s. (Up to ReSkate 2.1.4 it answered for keys held anywhere.)
string or number
required
A key’s name, or a Windows virtual key code from 1 to 254. The names (case matters):
  • "A" to "Z" and "0" to "9"
  • "Enter", "Backspace", "Escape", "Tab", "Space", "Delete"
  • "Shift", "Ctrl", "Alt"
  • "Home", "End", "PageUp", "PageDown"
  • "Left", "Up", "Right", "Down"
  • "[", "]"
  • "LeftMouse", "RightMouse", "MiddleMouse"
boolean
True while it is held.
Another name, a lower-case letter, or a number out of range raises an error.
Needs the input permission. It does not check that ReSkate’s menu, console or chat is shut: read focus (below) for that, so a key typed into the chat does nothing.

reskate.input.wheel()

The mouse wheel’s notches since the last call. They are gathered only while game input is paused by game_buttons (see below).
number
Whole notches: above 0 rolled away from the player, below 0 towards. 0 when none, or when game input is not paused.
Needs the input permission. The notches are used up as they are read, for every plugin together.

reskate.input.mouse()

How far the mouse moved since your plugin last read it, for a camera of your own that the mouse aims. Unlike wheel, it needs no pause: the game still gets the mouse too.
table or nil
nil while the game window is not in front, or ReSkate’s menu, console or a dialog is open. Movement in that time is thrown away, so nothing piles up for when it closes.
Needs the input permission. Each plugin gets all the movement: reading it does not take it from another plugin. Your first read gives only the latest movement, and a plugin that has not read for 2 seconds starts again that way.

reskate.input.text(capture)

What the player typed since the last call, while one of your plugin’s screens is open: for a text field your plugin draws itself on a screen with no panel.
boolean
default:"true"
True (or nothing) to keep taking the typing for 300 ms more: call it every frame while your field types. While it does, Esc is your plugin’s (read it with reskate.input.key) and does not close the screen. False lets go at once.
string
The characters typed, in UTF-8, printable ones only: no Enter, Backspace, Tab or arrows (read those with reskate.input.key). "" when none were, and always while none of your screens is open. At most 1024 bytes wait between calls.
Needs the input permission. There is no clipboard: a field cannot paste.

reskate.input.cursor()

The mouse over the game window while one of your plugin’s screens is open: for a tool on a docked screen that picks or drags things the player sees.
table or nil
nil while none of your screens is open.
Needs the input permission.

reskate.input.game_buttons(hidden, held, pause)

Keeps pad buttons from the game, for a plugin that gives them a job, and pauses all game input for a moment. Your plugin still reads every button with pad_bits and gamepad.
number
default:"0"
A mask of the button bits above, 0 to 0xFFFF: these read to the game as let go. The triggers are not in it: hide them with hide.
number
default:"0"
A mask, 0 to 0xFFFF, of the buttons the player still holds. While a button is in both hidden and held, the game reads no input at all, as during a pause: the game does not see a button you took until it is let go.
boolean
default:"false"
True to pause all of the game’s input for 500 ms from now. Call it every tick for as long as you want it. False does not end a pause early.
Returns nothing. Each call replaces both masks.
A mask that is not a number from 0 to 0xFFFF raises an error.
Needs the input permission. One set of masks is kept for every plugin: the latest call wins. The masks last until you change them; when the plugin that called last stops, they are cleared. Unlike capture, it needs no camera of your own.

reskate.input.game_keys(keys)

Keeps keys from the game, for a plugin that gives them a job where the game would use them too: Q and E, which step the game’s tabs in its menus, say. The game does not see these keys go down, by any of the ways it reads the keyboard. Their releases still reach it, so a key it saw go down before still comes up. Your plugin still reads them with key.
table
A list of at most 32 keys, each a name or a virtual key code as key takes them. nil or {} gives every key back.
Returns nothing. Each call replaces the list.
A list of more than 32 keys, a name that is not one, "Escape" or a mouse button raises an error: Escape and the mouse always reach the game.
Needs the input permission. One list is kept for every plugin: the latest call wins. It lasts until you change it; when the plugin that called last stops, the keys are given back.

Who has the input

reskate.input.allowed()

Whether the game has the input now: its window has the focus, ReSkate’s menu, console and dialogs are shut, and the game lets gameplay input through.
boolean
True when all three hold. It is focus().focused and not focus().interface_open and focus().gameplay.
Needs the input permission.

reskate.input.focus()

The three checks behind allowed, one by one.
table
Needs the input permission.
The flying camera guide puts camera.set, input.flight, input.gamepad and input.capture together.