Initial
This commit is contained in:
commit
941868ba9a
2 changed files with 69 additions and 0 deletions
63
binds.lua
Normal file
63
binds.lua
Normal file
|
@ -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");
|
6
binds.toc
Normal file
6
binds.toc
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
## Interface: 30403
|
||||||
|
## Title: Binds Addon
|
||||||
|
## Author: Imbus
|
||||||
|
## Version: 0.1
|
||||||
|
|
||||||
|
binds.lua
|
Loading…
Reference in a new issue