# HG changeset patch # User Nenue # Date 1471763612 14400 # Node ID a545933ddf3d89c05848fd1cd63a8abf366e1817 # Parent 29c89dbe07acf6718982aa6b9e5cc56e6c74d036 - pet ability binding macro now contains a /cast line for all known abilities with the same subtext, fixing an issue where swapping pets during combat breaks the key binding diff -r 29c89dbe07ac -r a545933ddf3d SkeletonKey/ActionTemplates.lua --- a/SkeletonKey/ActionTemplates.lua Fri Aug 19 10:47:06 2016 -0400 +++ b/SkeletonKey/ActionTemplates.lua Sun Aug 21 03:13:32 2016 -0400 @@ -36,6 +36,7 @@ [9] = 5, [10] = 6 } +local petSpellCache,petSubtextCache local SUMMON_RANDOM_FAVORITE_MOUNT_SPELL = 150544 --kb.ChangedBindings = {} @@ -71,6 +72,18 @@ atype['petaction'] = function(_, name) -- ID doesn't exist for basic commands, even though they can be picked up local attributeName, attributeValue = "petaction_" .. tostring(name), "/cast "..tostring(name) + + if not petSpellCache then + kb.UpdatePetInfo() + end + -- Compose a multi-macro for subtext abilities + if petSpellCache[name] then + attributeValue = "" + for spellName, enabled in pairs(petSubtextCache[petSpellCache[name]]) do + attributeValue = attributeValue .. "/cast " .. spellName .. "\n" + end + end + if PETACTION_SCRIPT[name] then attributeName, attributeValue = unpack(PETACTION_SCRIPT[name]) elseif kb.PetCache.special[name] then @@ -305,6 +318,14 @@ --kb.PetCache.specNum = GetSpecialization(nil, true) --kb.PetCache.specID, kb.PetCache.specName = GetSpecializationInfo(petSpec, nil, true) + kb.db.petSpellsDB = kb.db.petSpellsDB or {} + kb.db.petSpellsDB.subtext = kb.db.petSpellsDB.subtext or {} + kb.db.petSpellsDB.spell = kb.db.petSpellsDB.spell or {} + petSpellCache = kb.db.petSpellsDB.spell + petSubtextCache = kb.db.petSpellsDB.subtext + + + if PetHasSpellbook() then print('PET SPELLBOOK') local i = 1 @@ -325,17 +346,30 @@ --if match(subText, kb.PetCache.specName) then -- subText = 'specialization' --end - kb.PetCache.subtext[subText] = kb.PetCache.subtext[subText] or {} specialNum[subText] = (specialNum[subText] or 0) + 1 + petSpellCache[spellName] = subText + petSubtextCache[subText] = petSubtextCache[subText] or {} + + -- add to the list + if not petSubtextCache[subText][spellName] then + petSubtextCache[subText][spellName] = true + + local macrotext = "" + for spellName, enabled in pairs(petSubtextCache[subText]) do + macrotext = macrotext .. "/cast " .. spellName .. "\n" + end + kb.SecureAttribute(KeyBinderMacro, "*macrotext-petaction_"..subText.."_"..specialNum[subText], macrotext) + print('|cFF00FFFFspecial['..spellName..']|r', '\n','|cFF00FFFFsubtext['..subText..']['..specialNum[subText]..']|r', '=>', i, spellName, subText, spellID, texture, specialNum[subText]) + end + + + local entry = {i, spellName, subText, spellID, texture, specialNum[subText]} kb.PetCache.special[spellName] = entry kb.PetCache.subtext[subText][specialNum[subText]] = entry - kb.SecureAttribute(KeyBinderMacro, "*macrotext-petaction_"..subText.."_"..specialNum[subText], "/cast "..spellName) - - print('|cFF00FFFFspecial['..spellName..']|r', '\n','|cFF00FFFFsubtext['..subText..']['..specialNum[subText]..']|r', '=>', i, spellName, subText, spellID, texture, specialNum[subText]) end if spellID then diff -r 29c89dbe07ac -r a545933ddf3d SkeletonKey/HotKey.lua --- a/SkeletonKey/HotKey.lua Fri Aug 19 10:47:06 2016 -0400 +++ b/SkeletonKey/HotKey.lua Sun Aug 21 03:13:32 2016 -0400 @@ -80,6 +80,7 @@ hotkey.wrapEvent('UNIT_PET', 'pet') end + hotkey.init = function() hooksecurefunc("ActionBarButtonEventsFrame_RegisterFrame", hotkey.RegisterFrame) end diff -r 29c89dbe07ac -r a545933ddf3d SkeletonKey/SkeletonKey.lua --- a/SkeletonKey/SkeletonKey.lua Fri Aug 19 10:47:06 2016 -0400 +++ b/SkeletonKey/SkeletonKey.lua Sun Aug 21 03:13:32 2016 -0400 @@ -5,14 +5,7 @@ -- @file-revision@ @file-hash@ -- Created: 6/16/2016 3:47 AM -------------------------------------------- --- kb --- .StoreBinding(button, key) bind current keystroke to command --- .GetSlot(index) return display slot --- .SetSlot(button, command, name, icon) assign display slot --- .ReleaseSlot(button) clear button command --- .UpdateSlot(button) update button contents --- .SelectProfile(name) set profile character --- .ApplyBindings(bindings) walk table with SetBinding() +-- Header script local _ local kb, print = LibStub("LibKraken").register(KeyBinder) @@ -22,7 +15,6 @@ local L = kb.L --- Caps Lock literals -local CLASS_ICON_TEXTURE = "Interface\\GLUES\\CHARACTERCREATE\\UI-CHARACTERCREATE-CLASSES" L.BINDING_ASSIGNED = '|cFF00FF00%s|r assigned to |cFFFFFF00%s|r (%s).' L.BINDING_REMOVED = '|cFFFFFF00%s|r (|cFF00FFFF%s|r) unbound.' L.BINDING_FAILED_PROTECTED = '|cFFFF4400Cannot use |r|cFF00FF00%s|r|cFFFF4400 (currently |cFFFFFF00%s|r|cFFFF4400). Uncheck "Safety" to ignore this restraint.|r'