View Single Post
06-23-19, 07:25 PM   #3
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
Oh, boy.

Lua Code:
  1. local frame = CreateFrame('Frame')
  2. local actionButtons = {}
  3. local stanceButtons = {}
  4. local protectedSkills = {}
  5.  
  6. ---------------------------------------------------
  7. for i, spell in ipairs({
  8.     ---------------------------------------------------
  9.     'Alchemy', 'Cooking', 'Enchanting', 'Engineering',
  10.     'Blacksmithing', 'Tailoring', 'First Aid',
  11.     ---------------------------------------------------
  12. }) do
  13.     local spellID = select(7, GetSpellInfo(spell))
  14.     if spellID then
  15.         protectedSkills[spellID] = spell
  16.     end
  17. end
  18.  
  19. ---------------------------------------------------
  20. for i, button in ipairs(StanceBarFrame.StanceButtons) do
  21.     stanceButtons['SHAPESHIFTBUTTON' .. i] = button
  22. end
  23.  
  24. for i=1, 12 do
  25.     actionButtons['ACTIONBUTTON' .. i] = _G['ActionButton' .. i]
  26. end
  27.  
  28. for i, button in ipairs(ActionBarButtonEventsFrame.frames) do
  29.     local barID = button.buttonType
  30.     local buttonID  = button:GetID()
  31.     local identifier = buttonID and barID and ( barID .. buttonID )
  32.     if identifier then
  33.         actionButtons[identifier] = button
  34.     end
  35. end
  36. ---------------------------------------------------
  37.  
  38. frame:EnableKeyboard(true)
  39. frame:SetPropagateKeyboardInput(true)
  40. frame:SetScript('OnKeyDown', function(self, key, down)
  41.     if IsMounted() then
  42.         local prefix = SecureButton_GetModifierPrefix()
  43.         local binding = GetBindingAction(prefix .. key)
  44.         local button = actionButtons[binding]
  45.  
  46.         if button then
  47.             local action = ActionButton_CalculateAction(button)
  48.             if HasAction(action) then
  49.                 local actionType, spellID = GetActionInfo(action)
  50.                 if actionType == 'spell' and not protectedSkills[spellID] then
  51.                     Dismount()
  52.                 end
  53.             end
  54.             return
  55.         end
  56.  
  57.         button = stanceButtons[binding]
  58.         if button and not button:GetChecked() then
  59.             Dismount()
  60.         end
  61.     end
  62. end)
__________________

Last edited by MunkDev : 06-23-19 at 07:36 PM.
  Reply With Quote