API:GetButtonName
From RoR Wiki
UI Lua API · Game functions
Version: WAR 1.4.8
Returns the display name of a key or button on an input device.
name = GetButtonName(deviceId, buttonId)
Arguments
- deviceId
number– Input device, for exampleSystemData.InputDevice.KEYBOARD.- buttonId
number– Button id on that device, as returned in thebuttonsarray of GetBindingsForAction.easystem_utils/source/keyutils.lualists some keyboard ids, for example 42 for left Shift.
Returns
- name
wstring– Name of the button.
Details
- Both numbers are converted to integers.
- The client first looks in its own table of button names. If the button is not there, it asks the input system for a name.
- The name is localised.
easystem_utils/source/keyutils.luanotes that its short-name lookup table must be keyed withGetButtonNameresults for this reason.
Errors
None.
Example
From easystem_utils/source/keyutils.lua:
local buttonName = GetButtonName( deviceId, buttonId )
Building a lookup table of localised modifier names, from the same file:
[GetButtonName(SystemData.InputDevice.KEYBOARD, LSHIFT)] = StringTables.ShortKeyNames.SHORTKEY_LEFT_SHIFT, [GetButtonName(SystemData.InputDevice.KEYBOARD, LCTRL)] = StringTables.ShortKeyNames.SHORTKEY_LEFT_CONTROL,
