-- Uses lots of stuff from SpellBookFrame.lua function FindBookThingyByName(name, subname, booktype) local spellName = "smurf"; local subSpellName = "Rank 5"; local index = 1; -- thanks to Munelear for the nice loop condition :) while spellName do spellName, subSpellName = GetSpellName(index, booktype); if ( ( spellName ~= nil) and ( string.find(spellName, name) ~= nil) ) then if ( ( subname == nil ) or ( string.find(subSpellName, subname) ~= nil) ) ) then return index; end end index = index + 1; end return nil; end function FindSpellByName(name, subname) return FindBookThingyByName(name, subname, BOOKTYPE_SPELL); end function FindPetByName(name, subname) return FindBookThingy(name, subname, BOOKTYPE_PET); end function FindAbilityByName(name, subname) return FindBookThingyByName(name, subname, BOOKTYPE_ABILITY); end -- will return an index and then a book type. -- if the thingy is not found in any book it will return nil, nil function FindInAnyBookType(name, subname) local index = nil; for bookType, value in SPELLBOOK_PAGENUMBERS do index = FindBookThingyByName(name, subname, bookType); if (index ~= nil) then return index, bookType; end end return nil, nil; end