Oh, boy.
Lua Code:
local frame = CreateFrame('Frame')
local actionButtons = {}
local stanceButtons = {}
local protectedSkills = {}
---------------------------------------------------
for i, spell in ipairs({
---------------------------------------------------
'Alchemy', 'Cooking', 'Enchanting', 'Engineering',
'Blacksmithing', 'Tailoring', 'First Aid',
---------------------------------------------------
}) do
local spellID = select(7, GetSpellInfo(spell))
if spellID then
protectedSkills[spellID] = spell
end
end
---------------------------------------------------
for i, button in ipairs(StanceBarFrame.StanceButtons) do
stanceButtons['SHAPESHIFTBUTTON' .. i] = button
end
for i=1, 12 do
actionButtons['ACTIONBUTTON' .. i] = _G['ActionButton' .. i]
end
for i, button in ipairs(ActionBarButtonEventsFrame.frames) do
local barID = button.buttonType
local buttonID = button:GetID()
local identifier = buttonID and barID and ( barID .. buttonID )
if identifier then
actionButtons[identifier] = button
end
end
---------------------------------------------------
frame:EnableKeyboard(true)
frame:SetPropagateKeyboardInput(true)
frame:SetScript('OnKeyDown', function(self, key, down)
if IsMounted() then
local prefix = SecureButton_GetModifierPrefix()
local binding = GetBindingAction(prefix .. key)
local button = actionButtons[binding]
if button then
local action = ActionButton_CalculateAction(button)
if HasAction(action) then
local actionType, spellID = GetActionInfo(action)
if actionType == 'spell' and not protectedSkills[spellID] then
Dismount()
end
end
return
end
button = stanceButtons[binding]
if button and not button:GetChecked() then
Dismount()
end
end
end)