Mercurial > wow > skeletonkey
comparison ActionTemplates.lua @ 93:f9df7cd7bfd6 tip
revert pet spell subText collation
remove an empty script handler
| author | Nenue |
|---|---|
| date | Tue, 04 Sep 2018 23:00:21 -0400 |
| parents | b80e78f4a17b |
| children |
comparison
equal
deleted
inserted
replaced
| 92:c1c9dd6063a8 | 93:f9df7cd7bfd6 |
|---|---|
| 12 local PetHasSpellbook, PetHasActionBar, GetPetActionInfo, HasPetSpells = PetHasSpellbook, PetHasActionBar, GetPetActionInfo, HasPetSpells | 12 local PetHasSpellbook, PetHasActionBar, GetPetActionInfo, HasPetSpells = PetHasSpellbook, PetHasActionBar, GetPetActionInfo, HasPetSpells |
| 13 local GetProfessions, GetProfessionInfo, GetTalentInfo = GetProfessions, GetProfessionInfo, GetTalentInfo | 13 local GetProfessions, GetProfessionInfo, GetTalentInfo = GetProfessions, GetProfessionInfo, GetTalentInfo |
| 14 local GetNumBindings, GetBinding = GetNumBindings, GetBinding | 14 local GetNumBindings, GetBinding = GetNumBindings, GetBinding |
| 15 | 15 |
| 16 local _, kb = ... | 16 local _, kb = ... |
| 17 local print = (DEVIAN_PNAME == 'SkeletonKey') and function(...) print('SK', ...) end or nop | 17 local print = (DEVIAN_PNAME == 'SkeletonKey') and function(...) print('AT', ...) end or nop |
| 18 local cprint = (DEVIAN_PNAME == 'SkeletonKey') and function(...) _G.print('Cfg', ...) end or nop | 18 local cprint = (DEVIAN_PNAME == 'SkeletonKey') and function(...) _G.print('Cfg', ...) end or nop |
| 19 | 19 |
| 20 local CLICK_KEYBINDER_MACRO = "CLICK SkeletonKeyMacro:" | 20 local CLICK_KEYBINDER_MACRO = "CLICK SkeletonKeyMacro:" |
| 21 local CLICK_KEYBINDER_KEY = "CLICK SkeletonKeyKey:" | 21 local CLICK_KEYBINDER_KEY = "CLICK SkeletonKeyKey:" |
| 22 local PET_BASIC_SUBTEXT = 'Basic Attack' | 22 local PET_BASIC_SUBTEXT = 'Basic Attack' |
| 71 end | 71 end |
| 72 return CLICK_KEYBINDER_KEY, attributeName, name, SkeletonKeyKey | 72 return CLICK_KEYBINDER_KEY, attributeName, name, SkeletonKeyKey |
| 73 end | 73 end |
| 74 | 74 |
| 75 atype['petaction'] = function(_, name) | 75 atype['petaction'] = function(_, name) |
| 76 print('|cFF00FF00atype:petaction|r', name) | |
| 76 -- ID doesn't exist for basic commands, even though they can be picked up | 77 -- ID doesn't exist for basic commands, even though they can be picked up |
| 77 local attributeName, attributeValue = "petaction_" .. tostring(name), "/cast "..tostring(name) | 78 local attributeName, attributeValue = "petaction_" .. tostring(name), "/use "..tostring(name) |
| 78 | 79 |
| 79 if not petSpellCache then | 80 if not petSpellCache then |
| 80 kb.UpdatePetInfo() | 81 kb.UpdatePetInfo() |
| 81 end | 82 end |
| 82 -- Compose a multi-macro for subtext abilities | 83 -- Compose a multi-macro for subtext abilities |
| 83 if petSpellCache[name] then | |
| 84 attributeValue = "" | |
| 85 for spellName, enabled in pairs(petSubtextCache[petSpellCache[name]]) do | |
| 86 attributeValue = attributeValue .. "/cast " .. spellName .. "\n" | |
| 87 end | |
| 88 end | |
| 89 | 84 |
| 90 if PETACTION_SCRIPT[name] then | 85 if PETACTION_SCRIPT[name] then |
| 91 attributeName, attributeValue = unpack(PETACTION_SCRIPT[name]) | 86 attributeName, attributeValue = unpack(PETACTION_SCRIPT[name]) |
| 92 elseif kb.PetCache.special[name] then | 87 |
| 93 attributeName = "petaction_"..kb.PetCache.special[name][3].."_" .. tonumber(kb.PetCache.special[name][6]) | 88 print(' scripts hit:', name, attributeName, attributeValue) |
| 94 end | 89 end |
| 95 return CLICK_KEYBINDER_MACRO, attributeName, attributeValue, SkeletonKeyMacro | 90 return CLICK_KEYBINDER_MACRO, attributeName, attributeValue, SkeletonKeyMacro |
| 96 end | 91 end |
| 97 | 92 |
| 98 atype['battlepet'] = function(id, name) | 93 atype['battlepet'] = function(id, name) |
| 596 end | 591 end |
| 597 | 592 |
| 598 | 593 |
| 599 | 594 |
| 600 kb.UpdatePetInfo = function() | 595 kb.UpdatePetInfo = function() |
| 596 print('|cFFFFFF00kb.UpdatePetInfo()') | |
| 601 local hasPetSpells, petType = HasPetSpells() | 597 local hasPetSpells, petType = HasPetSpells() |
| 602 | 598 |
| 603 -- reconcile saved data if it becomes available | 599 -- reconcile saved data if it becomes available |
| 604 if kb.db then | 600 if kb.db then |
| 605 kb.db.petSpellsDB = kb.db.petSpellsDB or {} | 601 kb.db.petSpellsDB = kb.db.petSpellsDB or {} |
| 627 petSpellCache = {} | 623 petSpellCache = {} |
| 628 petSubtextCache = {} | 624 petSubtextCache = {} |
| 629 end | 625 end |
| 630 | 626 |
| 631 if PetHasSpellbook() then | 627 if PetHasSpellbook() then |
| 632 --print('PET SPELLBOOK') | 628 print('PET SPELLBOOK') |
| 633 local spellbookOffset = 1 | 629 local spellbookOffset = 1 |
| 634 local specialNum = {} | 630 local specialNum = {} |
| 635 local newSubtextItems = false | 631 local newSubtextItems = false |
| 636 | 632 |
| 637 repeat | 633 repeat |
| 638 | 634 |
| 639 local spellType, spellID = GetSpellBookItemInfo(spellbookOffset, BOOKTYPE_PET) | 635 local spellType, spellID = GetSpellBookItemInfo(spellbookOffset, BOOKTYPE_PET) |
| 640 local spellName, subText = GetSpellBookItemName(spellbookOffset, BOOKTYPE_PET) | 636 local spellName, subText = GetSpellBookItemName(spellbookOffset, BOOKTYPE_PET) |
| 641 local texture = GetSpellBookItemTexture(spellbookOffset, BOOKTYPE_PET) | 637 local texture = GetSpellBookItemTexture(spellbookOffset, BOOKTYPE_PET) |
| 642 if (spellType == 'SPELL') and (not IsPassiveSpell(spellbookOffset, BOOKTYPE_PET)) then | 638 |
| 639 | |
| 640 if (spellType == 'PETACTION') and (not IsPassiveSpell(spellbookOffset, BOOKTYPE_PET)) then | |
| 641 | |
| 642 print('|cFF00FF00#'..spellbookOffset..'|r', spellType, spellID, spellName, subText, texture) | |
| 643 local info = kb.PetCache[spellName] or {} | 643 local info = kb.PetCache[spellName] or {} |
| 644 kb.PetCache.spellslot[spellName] = {spellbookOffset, spellName, subText, spellID, texture} | 644 kb.PetCache.spellslot[spellName] = {spellbookOffset, spellName, subText, spellID, texture} |
| 645 --print('|cFF00FF88spellslot['..spellName..']|r', '=>', i, subText) | 645 print('|cFF00FF88spellslot['..spellName..']|r', '=>', spellName, spellID) |
| 646 | 646 |
| 647 if subText then | 647 if subText then |
| 648 kb.PetCache.subtext[subText] = kb.PetCache.subtext[subText] or {} | 648 kb.PetCache.subtext[subText] = kb.PetCache.subtext[subText] or {} |
| 649 specialNum[subText] = (specialNum[subText] or 0) + 1 | 649 specialNum[subText] = (specialNum[subText] or 0) + 1 |
| 650 | 650 |
| 651 petSpellCache[spellName] = subText | 651 petSpellCache[spellName] = subText |
| 652 petSubtextCache[subText] = petSubtextCache[subText] or {} | 652 |
| 653 | 653 --local entry = {spellbookOffset, spellName, subText, spellID, texture, specialNum[subText] } |
| 654 -- add to the list | |
| 655 if not petSubtextCache[subText][spellName] then | |
| 656 petSubtextCache[subText][spellName] = true | |
| 657 newSubtextItems = true | |
| 658 --print('|cFF00FFFFspecial['..spellName..']|r', '\n','|cFF00FFFFsubtext['..subText..']['..specialNum[subText]..']|r', '=>', i, spellName, subText, spellID, texture, specialNum[subText]) | |
| 659 end | |
| 660 | |
| 661 | |
| 662 | |
| 663 local entry = {spellbookOffset, spellName, subText, spellID, texture, specialNum[subText] } | |
| 664 | 654 |
| 665 | 655 |
| 666 info.spellbookOffset = spellbookOffset | 656 info.spellbookOffset = spellbookOffset |
| 667 info.spellbookType = BOOKTYPE_PET | 657 info.spellbookType = BOOKTYPE_PET |
| 668 info.actionName = spellName | 658 info.actionName = spellName |
| 690 end | 680 end |
| 691 | 681 |
| 692 spellbookOffset = spellbookOffset + 1 | 682 spellbookOffset = spellbookOffset + 1 |
| 693 until spellType == nil | 683 until spellType == nil |
| 694 | 684 |
| 695 if newSubtextItems then | |
| 696 | |
| 697 local macrotext = "" | |
| 698 for subText, spells in pairs(petSubtextCache) do | |
| 699 if specialNum[subText] then | |
| 700 for spellName, enabled in pairs(spells) do | |
| 701 macrotext = macrotext .. "/cast " .. spellName .. "\n" | |
| 702 end | |
| 703 kb.SecureAttribute(SkeletonKeyMacro, "*macrotext-petaction_"..subText.."_"..specialNum[subText], macrotext) | |
| 704 end | |
| 705 end | |
| 706 end | |
| 707 | |
| 708 | 685 |
| 709 else | 686 else |
| 710 --print('NO PET SPELLBOOK') | 687 --print('NO PET SPELLBOOK') |
| 711 wipe(kb.PetCache.spell) | 688 wipe(kb.PetCache.spell) |
| 712 wipe(kb.PetCache.spellslot) | 689 wipe(kb.PetCache.spellslot) |
| 713 end | 690 end |
| 714 | 691 |
| 715 if PetHasActionBar() then | 692 if PetHasActionBar() then |
| 716 --print('PET ACTION BAR') | 693 print('PET ACTION BAR') |
| 717 for i = 1, 10 do | 694 for i = 1, 10 do |
| 718 | 695 local name, texture, _, _, _, _, spellId = GetPetActionInfo(i) |
| 719 | |
| 720 local name, subtext, texture, isToken, isActive = GetPetActionInfo(i) | |
| 721 if name then | 696 if name then |
| 722 kb.PetCache.action[i] = {name, subtext, texture, isToken, isActive } | 697 |
| 698 | |
| 699 print(i, name, texture, spellId) | |
| 700 | |
| 701 kb.PetCache.action[i] = {name, texture, spellId} | |
| 723 | 702 |
| 724 | 703 |
| 725 end | 704 end |
| 726 --print('|cFFFFFF00action['..i..']|r', name, subtext, texture) | 705 --print('|cFFFFFF00action['..i..']|r', name, subtext, texture) |
| 727 end | 706 end |
