Lua setting renderer 'inputBinding' assumes the trigger's/action's 'key' as l10n name instead of their 'l10n' parameter
Issue
I made this Lua player script, which uses the input.registerTrigger
functionality alongside the inputBinding built-in settings renderer to let player execute an action (display a textbox) on any keyboard input they configure in the script settings window. I'm also using core.l10n
to define setting descriptions in a en.yaml file.
I noticed that not all of these descriptions are taken from my yaml file. Pictures should show what I expect best. My thoughts on what's wrong IMO are after, then the script itself:
Expected:
Actual:
Possible correction
Script seems to be looking for the l10n context named exactly as I named the trigger key. To me it's odd, because AFAIK both ActionInfo and TriggerInfo (parameters used in input.registerTrigger
/ input.registerAction
functions) have the l10n
parameter and it seems to me that this should be used, not the key.
I'm pretty sure (at least I tested it locally) that just changing this line in https://gitlab.com/OpenMW/openmw/-/blob/master/files/data/scripts/omw/input/settings.lua#L105
from
local l10n = core.l10n(info.key)
to
local l10n = core.l10n(info.l10n)
shall fix the issue (the "Expected" picture above was taken after I made that exact change)
Or am I completely wrong? Please let me know if I am.
Script used to reproduce the issue
l10n/troubleshooting_input_issue_with_l10n/en.yaml
1.: travTroubleshootingSettingsPageName: "Main settings title for this issue"
travTroubleshootingSettingsPageNameDescription: "Description for the page for this issue"
travSettingsSectionName: "Settings section with the input changing option"
travSettingName: "Name of the setting where you change the input"
travSettingNameDescription: "Description of this setting"
travTriggerName: "Click here ->"
travTriggerDescription: "then press the new button"
scripts/player3.lua
2.: local input = require('openmw.input')
local storage = require('openmw.storage')
local async = require('openmw.async')
local I = require('openmw.interfaces')
local ui = require('openmw.ui')
local l10nKey = 'troubleshooting_input_issue_with_l10n'
local defaultButtonForTrigger = "u"
local triggerKey = "travTriggerKey"
local triggerName = "travTriggerName"
local triggerDesc = "travTriggerDescription"
local settingKey = "travSettingsKey"
local settingName = "travSettingName"
local settingsPageKey = "travTroubleshootingSettingsPageKey"
local settingsPageName = "travTroubleshootingSettingsPageName"
local modSettingsKey = "SettingsCustom_0travSettings"
local settingSectionName = "travSettingsSectionName"
input.registerTrigger({
name = triggerName,
description = triggerDesc,
l10n = l10nKey,
key = triggerKey,
})
input.registerTriggerHandler(triggerKey, async:callback(function ()
print("I see you, hello")
ui.showMessage("I see you, hello")
end))
I.Settings.registerPage({
key = settingsPageKey,
l10n = l10nKey,
name = settingsPageName,
description = settingsPageName.."Description",
})
I.Settings.registerGroup({
key = modSettingsKey,
page = settingsPageKey,
l10n = l10nKey,
name = settingSectionName,
permanentStorage = true,
settings = {
{
key = settingKey,
renderer = "inputBinding",
name = settingName,
description = settingName..'Description',
default = defaultButtonForTrigger,
argument = {
type = "trigger",
key = triggerKey
}
}
},
})
3.: omwscripts file
It just points to the player script:
PLAYER: scripts/player3.lua