diff --git a/src/_bastion.lua b/src/_bastion.lua index 6d92449..11d1e88 100644 --- a/src/_bastion.lua +++ b/src/_bastion.lua @@ -251,41 +251,61 @@ function Bastion.Bootstrap() end end) + Command:Register('dumpspells', 'Dump spells to a file', function() - local i = 1 local rand = math.random(100000, 999999) - local BOOKTYPE_SPELL = BOOKTYPE_SPELL or (Enum.SpellBookSpellBank.Player and Enum.SpellBookSpellBank.Player or 'spell') - while true do - local spellName, spellSubName - - if C_SpellBook.GetSpellBookItemName then - spellName, spellSubName = C_SpellBook.GetSpellBookItemName(i, BOOKTYPE_SPELL) - else - spellName, spellSubName = GetSpellBookItemName(i, BOOKTYPE_SPELL) - end - if not spellName then do break end end - - -- use spellName and spellSubName here - local spellID - - if C_Spell.GetSpellInfo then - local info = C_Spell.GetSpellInfo(spellName) - spellID = info.spellID - else - spellID = select(7, GetSpellInfo(spellName)) + if C_SpellBook.GetNumSpellBookSkillLines then + for i = 1, C_SpellBook.GetNumSpellBookSkillLines() do + local skillLineInfo = C_SpellBook.GetSpellBookSkillLineInfo(i) + local offset, numSlots = skillLineInfo.itemIndexOffset, skillLineInfo.numSpellBookItems + for j = offset+1, offset+numSlots do + local name, subName = C_SpellBook.GetSpellBookItemName(j, Enum.SpellBookSpellBank.Player) + local spellID = select(2,C_SpellBook.GetSpellBookItemType(j, Enum.SpellBookSpellBank.Player)) + if spellID then + spellName = name:gsub("[%W%s]", "") + WriteFile('bastion-' .. UnitClass('player') .. '-' .. rand .. + '.lua', + "local " .. spellName .. + " = Bastion.Globals.SpellBook:GetSpell(" .. + spellID .. ")\n", true) + end + end end - - if spellID then - spellName = spellName:gsub("[%W%s]", "") - WriteFile('bastion-' .. UnitClass('player') .. '-' .. rand .. - '.lua', - "local " .. spellName .. - " = Bastion.Globals.SpellBook:GetSpell(" .. - spellID .. ")\n", true) + end + if C_SpellBook.GetSpellBookSkillLineInfo then + for _, i in pairs{GetProfessions()} do + local skillLineInfo = C_SpellBook.GetSpellBookSkillLineInfo(i) + local offset, numSlots = skillLineInfo.itemIndexOffset, skillLineInfo.numSpellBookItems + Bastion.Globals.Log:Log(59, { offset = offset, numSlots = numSlots}, logCat) + local name, subName = C_SpellBook.GetSpellBookItemName(j, Enum.SpellBookSpellBank.Player) + local spellID = select(2,C_SpellBook.GetSpellBookItemType(j, Enum.SpellBookSpellBank.Player)) + if spellID then + spellName = name:gsub("[%W%s]", "") + WriteFile('bastion-' .. UnitClass('player') .. '-' .. rand .. + '.lua', + "local " .. spellName .. + " = Bastion.Globals.SpellBook:GetSpell(" .. + spellID .. ")\n", true) + end end end - i = i + 1 end + local numSpells, petToken = C_SpellBook.HasPetSpells() -- nil if pet does not have spellbook, 'petToken' will usually be "PET" + if petToken then + for i=1, numSpells do + local petSpellName, petSubType = C_SpellBook.GetSpellBookItemName(i, Enum.SpellBookSpellBank.Pet) + local spellID = select(2,C_SpellBook.GetSpellBookItemType(i, Enum.SpellBookSpellBank.Pet)) + if spellID then + spellName = petSpellName:gsub("[%W%s]", "") + WriteFile('bastion-' .. UnitClass('player') .. '-' .. rand .. + '.lua', + "local " .. spellName .. + " = Bastion.Globals.SpellBook:GetSpell(" .. + spellID .. ")\n", true) + end + end + end + end) Command:Register('module', 'Toggle a module on/off', function(args)