63 lines
No EOL
1.6 KiB
Lua
63 lines
No EOL
1.6 KiB
Lua
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"); |