From 311cc5b611ae9baed47549ee3ad2cef04f4892e0 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 23 Nov 2019 14:40:00 +0100 Subject: lua: make add_key_binding() rotate optional arguments correctly add_key_binding() makes the name argument optional (in weird Lua fashion), which did not work if there were additional arguments. So there is no way to avoid specifying a name while passing a rp argument. Fix this, declare this way of skipping the argument as deprecated, and allow passing name=nil as the preferred way to skip the name argument. --- player/lua/defaults.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'player/lua') diff --git a/player/lua/defaults.lua b/player/lua/defaults.lua index 38b6a9d04b..72b73b566b 100644 --- a/player/lua/defaults.lua +++ b/player/lua/defaults.lua @@ -157,8 +157,12 @@ end local function add_binding(attrs, key, name, fn, rp) rp = rp or "" - if (type(name) ~= "string") and (not fn) then + if (type(name) ~= "string") and (name ~= nil) then + rp = fn fn = name + name = nil + end + if name == nil then name = reserve_binding() end local repeatable = rp == "repeatable" or rp["repeatable"] -- cgit v1.2.3