commit 941868ba9a3ee1139d29f895e306c81a4a5d22f8 Author: Imbus Date: Sat Oct 28 14:52:57 2023 +0200 Initial diff --git a/binds.lua b/binds.lua new file mode 100644 index 0000000..c97e2b4 --- /dev/null +++ b/binds.lua @@ -0,0 +1,63 @@ +local function unsetBinding(action) + local key1, key2 = GetBindingKey(action); + if key1 then + SetBinding(key1, nil); + end + if key2 then + SetBinding(key2, nil); + end +end + +local function setBindingRM(key, action) + unsetBinding(action); + if SetBinding(key, action) then + print("Set binding " .. key .. " to " .. action); + else + print("Failed to set binding " .. key .. " to " .. action); + end + SaveBindings(1); +end + +-- https://wowpedia.fandom.com/wiki/BindingID +local myBinds = { + ["1"] = "ACTIONBUTTON1", + ["2"] = "ACTIONBUTTON2", + ["3"] = "ACTIONBUTTON3", +} + +local function setAllBinds() + setBindingRM("CTRL-2", "ACTIONBUTTON1"); + setBindingRM("1", "ACTIONBUTTON2"); + print("Bindings set") +end + +-- Define a function to handle the /hello command +local function HelloCommandHandler(msg, editbox) + setAllBinds() +end + +-- message('loaded') +print("test") + +-- Register the /hello command +SLASH_BINDS1 = "/binds" +SlashCmdList["BINDS"] = HelloCommandHandler + +local function MyAddonOnLoad(self, event, arg1) + if arg1 == "MyAddon" then -- Replace "MyAddon" with your add-on's folder name + setAllBinds() + print("MyAddon has been loaded!") + end +end + +local frame = CreateFrame("Frame") +frame:RegisterEvent("ADDON_LOADED") +frame:SetScript("OnEvent", MyAddonOnLoad) + +-- local actionName = "ACTIONBUTTON1"; +-- local primaryKey = GetBindingKey(actionName); +-- setBinding(primaryKey, nil); +-- SetBinding("CTRL+A", actionName); +-- SaveBindings(1); + +-- setBinding("CTRL+A", "ACTIONBUTTON1"); setBinding("CTRL+B", "ACTIONBUTTON2"); \ No newline at end of file diff --git a/binds.toc b/binds.toc new file mode 100644 index 0000000..190b042 --- /dev/null +++ b/binds.toc @@ -0,0 +1,6 @@ +## Interface: 30403 +## Title: Binds Addon +## Author: Imbus +## Version: 0.1 + +binds.lua \ No newline at end of file