diff --git a/builtin/common/settings/components.lua b/builtin/common/settings/components.lua index 4e657a5648..00bd1bfee4 100644 --- a/builtin/common/settings/components.lua +++ b/builtin/common/settings/components.lua @@ -439,27 +439,14 @@ function make.key(setting) return height end - local critical_keys = { - keymap_drop = true, - keymap_dig = true, - keymap_place = true, - } - for _, o in ipairs(core.full_settingtypes) do if o.type == "key" and o.name ~= setting.name and + is_keybinding_critical(setting.name, o.name) and has_keybinding_conflict(core.settings:get(o.name):split("|"), value) then - local is_current_close_world = setting.name == "keymap_close_world" - local is_other_close_world = o.name == "keymap_close_world" - local is_current_critical = critical_keys[setting.name] - local is_other_critical = critical_keys[o.name] - - if (is_other_critical or is_current_critical) or - (not is_current_close_world and not is_other_close_world) then - table.insert(fs, ("label[0,%f;%s]"):format(height + 0.3, - core.colorize(mt_color_orange, fgettext([[Conflicts with "$1"]], fgettext(o.readable_name))))) - height = height + 0.6 - end + table.insert(fs, ("label[0,%f;%s]"):format(height + 0.3, + core.colorize(mt_color_orange, fgettext([[Conflicts with "$1"]], fgettext(o.readable_name))))) + height = height + 0.6 end end return height diff --git a/builtin/common/settings/dlg_change_keybinding.lua b/builtin/common/settings/dlg_change_keybinding.lua index d59b0760ef..4a97b9f8b9 100644 --- a/builtin/common/settings/dlg_change_keybinding.lua +++ b/builtin/common/settings/dlg_change_keybinding.lua @@ -28,8 +28,9 @@ local function get_formspec(dialogdata) for idx, key in ipairs(value) do local prefix = "" for _, o in ipairs(core.full_settingtypes) do - if o.type == "key" and o.name ~= name - and has_keybinding_conflict(core.settings:get(o.name):split("|"), key) then + if o.type == "key" and o.name ~= name and + is_keybinding_critical(name, o.name) and + has_keybinding_conflict(core.settings:get(o.name):split("|"), key) then prefix = mt_color_orange if idx == selection then warning = core.colorize(mt_color_orange, fgettext([[Conflicts with "$1"]], fgettext_ne(o.readable_name))) @@ -156,3 +157,17 @@ function has_keybinding_conflict(t1, t2) -- not local as it is also used by the end return false end + +local critical_keys = { + keymap_drop = true, + keymap_dig = true, + keymap_place = true, +} +function is_keybinding_critical(n1, n2) + local is_current_close_world = n1 == "keymap_close_world" + local is_other_close_world = n2 == "keymap_close_world" + local is_current_critical = critical_keys[n1] + local is_other_critical = critical_keys[n2] + return (is_other_critical or is_current_critical) or + (not is_current_close_world and not is_other_close_world) +end