Mercurial > wow > skeletonkey
diff SkeletonKey/ActionTemplates.lua @ 54:a545933ddf3d
- 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
author | Nenue |
---|---|
date | Sun, 21 Aug 2016 03:13:32 -0400 |
parents | 1aba8a6fd4a9 |
children | 2a95f4010c5a |
line wrap: on
line diff
--- 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