I'm using this Lua to replace the hotkey text.
But there is a error in DF.
Can anyone help me to fix it?
Lua Code:
local gsub = string.gsub
local function HotkeyReplace(button)
local text = button.HotKey and button.HotKey:GetText()
if not text then return end
text = gsub(text, '(s%-)', 's')
text = gsub(text, '(a%-)', 'a')
text = gsub(text, '(c%-)', 'c')
text = gsub(text, '(st%-)', 'c') -- german control 'Steuerung'
for i = 1, 30 do
text = gsub(text, _G['KEY_BUTTON'..i], 'M'..i)
end
for i = 1, 9 do
text = gsub(text, _G['KEY_NUMPAD'..i], 'N'..i)
end
text = gsub(text, CAPSLOCK_KEY_TEXT, 'CK')
text = gsub(text, KEY_NUMPADMULTIPLY, '*')
text = gsub(text, KEY_NUMPADDIVIDE, '/')
text = gsub(text, KEY_NUMPADPLUS, '+')
text = gsub(text, KEY_NUMPADMINUS, '-')
text = gsub(text, KEY_MOUSEWHEELUP, 'MU')
text = gsub(text, KEY_MOUSEWHEELDOWN, 'MD')
text = gsub(text, KEY_NUMLOCK, 'NuL')
text = gsub(text, KEY_PAGEUP, 'PU')
text = gsub(text, KEY_PAGEDOWN, 'PD')
text = gsub(text, KEY_SPACE, '_')
text = gsub(text, KEY_INSERT, 'Ins')
text = gsub(text, KEY_HOME, 'Hm')
text = gsub(text, KEY_DELETE, 'Del')
button.HotKey:SetText(text)
end
local lgr, lgg, lgb = LIGHTGRAY_FONT_COLOR:GetRGB()
local function SetButtonFont(button)
if button.HotKey then
button.HotKey:SetFont(button.HotKey:GetFont(), 12, 'OUTLINE')
-- update hotkey color
hooksecurefunc(button.HotKey, 'SetVertexColor', function(self, r, g, b)
if r == lgr and g == lgg and b == lgb then
self:SetVertexColor(1, 1, 1)
end
end)
end
if button.Name then
button.Name:SetFont(button.Name:GetFont(), 12, 'OUTLINE')
end
end
local frame = CreateFrame('Frame')
frame:RegisterEvent('PLAYER_LOGIN')
frame:SetScript('OnEvent', function()
frame:UnregisterEvent('PLAYER_LOGIN')
-- process old buttons
-- action bar
for _, button in ipairs(ActionBarButtonEventsFrame.frames) do
SetButtonFont(button)
HotkeyReplace(button)
hooksecurefunc(button, 'UpdateHotkeys', HotkeyReplace)
end
-- pet action bar
for i = 1, 10 do
local button = _G['PetActionButton' .. i]
SetButtonFont(button)
button.HotKey:SetPoint('TOPRIGHT', -1, -4)
HotkeyReplace(button)
end
-- action bar
hooksecurefunc(ActionBarButtonEventsFrame, 'RegisterFrame', function(_, button)
SetButtonFont(button)
hooksecurefunc(button, 'UpdateHotkeys', HotkeyReplace)
end)
-- pet action bar
hooksecurefunc('PetActionButton_SetHotkeys', HotkeyReplace)
end)
The error:
Code:
1x Interface/AddOns/HotkeyFont/HotkeyFont.lua:80: hooksecurefunc(): PetActionButton_SetHotkeys is not a function
[string "=[C]"]: in function `hooksecurefunc'
[string "@Interface/AddOns/HotkeyFont/HotkeyFont.lua"]:80: in function <Interface/AddOns/HotkeyFont/HotkeyFont.lua:56>