Skip to content

Return of Reckoning

Wiki

RoR Wiki

API:GetBindingsForAction

From RoR Wiki

UI Lua API · Game functions
Version: WAR 1.4.8

Returns every key or button combination bound to an action.

bindings = GetBindingsForAction(actionName)

Arguments

actionName
string – Name of the action. Compared without regard to case.

Returns

bindings
table – Array of binding tables, indexed from 1. Empty if the action has no bindings or the name is unknown.

Each binding table has these fields:

Key Type Meaning
deviceId number Input device of the binding. Compare with SystemData.InputDevice values, for example SystemData.InputDevice.KEYBOARD.
buttons table Array of button ids (number) that make up the combination, indexed from 1.

Details

  • An unknown action name returns an empty table. It is not an error.
  • Pass deviceId and each button id to GetButtonName to get a readable name.
  • In the stock UI, all buttons before the last one in a combination are treated as keyboard modifiers (see the example).

Errors

None.

Example

From KeyUtils.GetBindingsForAction in easystem_utils/source/keyutils.lua:

local boundKeys = GetBindingsForAction( action )
...
for bindingCount, bindingData in ipairs( boundKeys )
do
    ...
    for buttonCount, buttonId in ipairs( bindingData.buttons )
    do
        local deviceId = bindingData.deviceId

        -- Modifiers are always on the keyboard, so force the device id
        -- on anything before the final button, so we can show things like shift-mouse3
        if( numButtons ~= buttonCount )
        then
            deviceId = SystemData.InputDevice.KEYBOARD
        end

        local buttonName = GetButtonName( deviceId, buttonId )
        ...

See also