From ded727b9d77bbd5653c50a4699a3106d80f61fb9 Mon Sep 17 00:00:00 2001 From: Imbus Date: Sun, 29 Oct 2023 11:37:41 +0100 Subject: [PATCH] Slight refactoring and moved camera hotkeys to a separate subrouting --- ImbusBinds.lua | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/ImbusBinds.lua b/ImbusBinds.lua index 415e175..c5ddbcf 100755 --- a/ImbusBinds.lua +++ b/ImbusBinds.lua @@ -8,10 +8,6 @@ local myBinds = { ["F1"] = "TOGGLEBACKPACK", ["F2"] = "TOGGLECHARACTER0", - -- Remove zoom from mousewheel - ["-"] = "CAMERAZOOMOUT", - ["+"] = "CAMERAZOOMIN", - -- Action Bar 1 ["1"] = "ACTIONBUTTON1", ["2"] = "ACTIONBUTTON2", @@ -83,6 +79,13 @@ local myBinds = { ["CTRL-6"] = "MULTIACTIONBAR4BUTTON12", } +local cameraBinds = { + -- Remove zoom from mousewheel + ["-"] = "CAMERAZOOMOUT", + ["+"] = "CAMERAZOOMIN", +} + +-- Unsets a binding, if it exists local function unsetBinding(action) local key1, key2 = GetBindingKey(action); if key1 then @@ -93,6 +96,7 @@ local function unsetBinding(action) end end +-- Same as SetBinding, but removes the old binding first local function setBindingRM(key, action) unsetBinding(action); if SetBinding(key, action) then @@ -102,12 +106,11 @@ local function setBindingRM(key, action) end end - -local function setAllBinds() - for key, action in pairs(myBinds) do +local function applyBindingSet(set) + for key, action in pairs(set) do setBindingRM(key, action) end - print("Bindings set. Run /binds permanent to save them permanently.") + print("Bindings set. Dont forget to reload your UI.") end local function enableBars() @@ -122,22 +125,18 @@ local function enableBars() SetCVar("countdownForCooldowns", 1); SetCVar("autoLootDefault", 1); SetCVar("cameraDistanceMaxZoomFactor", 2); + SetCVar("instantQuestText", 1); end local function BindsHandler(msg, editbox) - if msg == "reset" then - for key, action in pairs(myBinds) do - unsetBinding(action) - end - print("Bindings reset. Run /binds to set them again.") - return - end if msg == "" then - setAllBinds() + applyBindingSet(myBinds) enableBars() - SaveBindings(1) - return end + if msg == "camera" then + applyBindingSet(cameraBinds) + end + SaveBindings(1) end -- Register the /hello command