动作条快捷键缩写代码问题求助
发表于 : 2021-10-15 10:52:56
第一段:缩写Alt+Ctrl+F为ACF,但是进战斗和离开战斗一瞬间会卡一下,什么问题?
local function updatehotkey(self, actionButtonType)
local hotkey = _G[self:GetName() .. "HotKey"];
local replace = string.gsub;
if ( not actionButtonType ) then
actionButtonType = "ACTIONBUTTON";
end
local action = actionButtonType..self:GetID();
local text = GetBindingText(GetBindingKey(action), "KEY_");
if text then
text = replace(text, "CTRL", "C");
text = replace(text, "ALT", "A");
text = replace(text, "SHIFT", "S");
text = replace(text, "Spacebar", "Sp");
text = replace(text, "Insert", "In");
text = replace(text, "Delete", "De");
text = replace(text, "Num Pad", "NP");
text = replace(text, "Num Lock", "NL");
text = replace(text, "Backspace", "Ba");
text = replace(text, " Arrow", "");
text = replace(text, "-", "");
text = replace(text, "Wheel ", "W-");
text = replace(text, "Page ", "P-");
end
if hotkey:GetText() == _G["RANGE_INDICATOR"] then
hotkey:SetText("")
else
hotkey:SetText(text)
end
end
hooksecurefunc("ActionButton_OnEvent", function(self, event, ...)
if event == "PLAYER_ENTERING_WORLD" then
ActionButton_UpdateHotkeys(self, self.buttonType)
hooksecurefunc("ActionButton_UpdateHotkeys", updatehotkey)
end
end)
-- 快捷键优化
local function OnPlayerLogin(self, event, ...)
_G.NumberFont_OutlineThick_Mono_Small:SetFont(STANDARD_TEXT_FONT, 10,
"OUTLINE") ----快捷键
end
local Event = CreateFrame("Frame", nil, UIParent)
Event:RegisterEvent("PLAYER_LOGIN")
Event:SetScript("OnEvent", function(self, event, ...)
if event == "PLAYER_LOGIN" then OnPlayerLogin(self, event, ...) end
end)
---------------------------------------------------------------------------------------------
第二段:只能缩写Alt+W为AW,缩写Alt+Ctrl+F为ACF无效,但是不卡顿。。。
local function updatehotkey(self, actionButtonType)
local hotkey = _G[self:GetName() .. "HotKey"]
local replace = string.gsub
local text = hotkey:GetText()
if text then
text = replace(text, "(s%-)", "S")
text = replace(text, "(a%-)", "A")
text = replace(text, "(c%-)", "C")
text = replace(text, "(Mouse Button )", "M")
text = replace(text, "(鼠标中键)", "M3")
text = replace(text, "(鼠标滚轮向上滚动)", "MU")
text = replace(text, "(鼠标滚轮向下滚动)", "MD")
text = replace(text, "(鼠标按键4)", "M4")
text = replace(text, "(鼠标按键5)", "M5")
text = replace(text, "(数字键盘)", "N")
text = replace(text, "Capslock", "CK")
text = replace(text, "(Page Up)", "PU")
text = replace(text, "(Page Down)", "PD")
text = replace(text, "(空格键)", "SpB")
text = replace(text, "(Insert)", "Ins")
text = replace(text, "(Home)", "Hm")
text = replace(text, "(Delete)", "Del")
end
if hotkey:GetText() == _G["RANGE_INDICATOR"] then
hotkey:SetText("")
else
hotkey:SetText(text)
end
end
hooksecurefunc("ActionButton_OnEvent", function(self, event, ...)
if event == "PLAYER_ENTERING_WORLD" then
ActionButton_UpdateHotkeys(self, self.buttonType)
hooksecurefunc("ActionButton_UpdateHotkeys", updatehotkey)
end
end)
-- 快捷键优化
local function OnPlayerLogin(self, event, ...)
_G.NumberFont_OutlineThick_Mono_Small:SetFont(STANDARD_TEXT_FONT, 10,
"OUTLINE") ----快捷键
end
local Event = CreateFrame("Frame", nil, UIParent)
Event:RegisterEvent("PLAYER_LOGIN")
Event:SetScript("OnEvent", function(self, event, ...)
if event == "PLAYER_LOGIN" then OnPlayerLogin(self, event, ...) end
end)
local function updatehotkey(self, actionButtonType)
local hotkey = _G[self:GetName() .. "HotKey"];
local replace = string.gsub;
if ( not actionButtonType ) then
actionButtonType = "ACTIONBUTTON";
end
local action = actionButtonType..self:GetID();
local text = GetBindingText(GetBindingKey(action), "KEY_");
if text then
text = replace(text, "CTRL", "C");
text = replace(text, "ALT", "A");
text = replace(text, "SHIFT", "S");
text = replace(text, "Spacebar", "Sp");
text = replace(text, "Insert", "In");
text = replace(text, "Delete", "De");
text = replace(text, "Num Pad", "NP");
text = replace(text, "Num Lock", "NL");
text = replace(text, "Backspace", "Ba");
text = replace(text, " Arrow", "");
text = replace(text, "-", "");
text = replace(text, "Wheel ", "W-");
text = replace(text, "Page ", "P-");
end
if hotkey:GetText() == _G["RANGE_INDICATOR"] then
hotkey:SetText("")
else
hotkey:SetText(text)
end
end
hooksecurefunc("ActionButton_OnEvent", function(self, event, ...)
if event == "PLAYER_ENTERING_WORLD" then
ActionButton_UpdateHotkeys(self, self.buttonType)
hooksecurefunc("ActionButton_UpdateHotkeys", updatehotkey)
end
end)
-- 快捷键优化
local function OnPlayerLogin(self, event, ...)
_G.NumberFont_OutlineThick_Mono_Small:SetFont(STANDARD_TEXT_FONT, 10,
"OUTLINE") ----快捷键
end
local Event = CreateFrame("Frame", nil, UIParent)
Event:RegisterEvent("PLAYER_LOGIN")
Event:SetScript("OnEvent", function(self, event, ...)
if event == "PLAYER_LOGIN" then OnPlayerLogin(self, event, ...) end
end)
---------------------------------------------------------------------------------------------
第二段:只能缩写Alt+W为AW,缩写Alt+Ctrl+F为ACF无效,但是不卡顿。。。
local function updatehotkey(self, actionButtonType)
local hotkey = _G[self:GetName() .. "HotKey"]
local replace = string.gsub
local text = hotkey:GetText()
if text then
text = replace(text, "(s%-)", "S")
text = replace(text, "(a%-)", "A")
text = replace(text, "(c%-)", "C")
text = replace(text, "(Mouse Button )", "M")
text = replace(text, "(鼠标中键)", "M3")
text = replace(text, "(鼠标滚轮向上滚动)", "MU")
text = replace(text, "(鼠标滚轮向下滚动)", "MD")
text = replace(text, "(鼠标按键4)", "M4")
text = replace(text, "(鼠标按键5)", "M5")
text = replace(text, "(数字键盘)", "N")
text = replace(text, "Capslock", "CK")
text = replace(text, "(Page Up)", "PU")
text = replace(text, "(Page Down)", "PD")
text = replace(text, "(空格键)", "SpB")
text = replace(text, "(Insert)", "Ins")
text = replace(text, "(Home)", "Hm")
text = replace(text, "(Delete)", "Del")
end
if hotkey:GetText() == _G["RANGE_INDICATOR"] then
hotkey:SetText("")
else
hotkey:SetText(text)
end
end
hooksecurefunc("ActionButton_OnEvent", function(self, event, ...)
if event == "PLAYER_ENTERING_WORLD" then
ActionButton_UpdateHotkeys(self, self.buttonType)
hooksecurefunc("ActionButton_UpdateHotkeys", updatehotkey)
end
end)
-- 快捷键优化
local function OnPlayerLogin(self, event, ...)
_G.NumberFont_OutlineThick_Mono_Small:SetFont(STANDARD_TEXT_FONT, 10,
"OUTLINE") ----快捷键
end
local Event = CreateFrame("Frame", nil, UIParent)
Event:RegisterEvent("PLAYER_LOGIN")
Event:SetScript("OnEvent", function(self, event, ...)
if event == "PLAYER_LOGIN" then OnPlayerLogin(self, event, ...) end
end)
楼主这个贴子是不是通过代码可以在mod后面加鼠标3,鼠标4,鼠标5了?