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.
The action’s name, 1 to 48 characters. It is what the
action event hands your handler. Binding a name again replaces its combo.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.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
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.
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.
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.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.
A controller’s number from
joysticks(), 0 to 15. Leave it out for the first controller as above.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.
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().
True to keep the controller for the next 250 ms, false (or nothing) to give it back now.
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().
What to keep from the game. Each call replaces your plugin’s last one;
nil or {} gives everything back.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 withgamepad(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.
The whole controller, in the units
gamepad() gives. A control left out is neutral: centred, released, not pressed. nil lets go of your replacement.An integer from 0 to 3 for that Xbox controller, or
"playstation" for the PlayStation controller.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.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.
True to read the pad while ReSkate’s menu, console or a dialog is open too.
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.)
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"
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).
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.
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.
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.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.
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.
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.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.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.
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.
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."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.
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.
Needs the
input permission.