crystal.input.set_bindings
Defines which actions are bound to which inputs for the specified player.
Usage
crystal.input.set_bindings(player_index, bindings)
Arguments
| Name | Type | Description |
|---|---|---|
player_index | number | Number identifying a player. |
bindings | table | Lists of actions bound to each input. |
Keys in the bindings table can be:
- Any love.Scancode.
- Any love.GamepadAxis.
- Any love.GamepadButton, except
a,b,xandy, which should be replaced bybtna,btnb,btnx,btny. - A string describing a mouse button:
mouseleftfor left mouse buttonmouserightfor right mouse buttonmousemiddlefor middle mouse buttonmouseextra1throughmouseextra12for additional mouse buttons
Values associated with these keys are lists of actions as strings. Actions should be specific to your game title (eg. jump, attack, dodge, etc.). If players in your game can accomplish different things by pressing a single key (eg. talking to an NPC or jumping, depending on context), you should define an action for each of these outcomes and map them all to the same key.
Examples
crystal.input.set_bindings(1, {
-- Keyboard
space = { "jump", "talk" },
x = { "attack" },
-- Gamepad
btna = { "jump", "talk" },
btnx = { "attack" },
-- Mouse
mouseleft = { "jump", "talk" },
mouseright = { "attack" },
});