Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
Advertisement

Returns info for a spellbook item.

spellType, id = GetSpellBookItemInfo(spellName)
              = GetSpellBookItemInfo(index, bookType)

Arguments[]

spellName
string - Requires the spell to be in your Spellbook.
Spellbook args  
index
number - Spellbook slot index, ranging from 1 through the total number of spells across all tabs and pages.
bookType
string - BOOKTYPE_SPELL or BOOKTYPE_PET depending on if you wish to query the player or pet spellbook.
Internally the game only tests if this is equal to "pet" and treats any other string value as "spell".
Constant Value Description
BOOKTYPE_SPELL "spell" The General, Class, Specs and Professions tabs[1]
BOOKTYPE_PET "pet" The Pet tab

Returns[]

spellType
string - The type of the spell: ["SPELL", "FUTURESPELL", "PETACTION", "FLYOUT"]
id
number

Details[]

Related API GetSpellBookItemName

Example[]

Prints all spells in the spellbook for the player, except the profession tab ones.

API GetSpellBookItemInfo 01
local spellFunc = {
	SPELL = GetSpellInfo,
	FUTURESPELL = GetSpellInfo,
	FLYOUT = GetFlyoutInfo,
}

for i = 1, GetNumSpellTabs() do
	local _, _, offset, numSlots = GetSpellTabInfo(i)
	for j = offset+1, offset+numSlots do
		local spellType, id = GetSpellBookItemInfo(j, BOOKTYPE_SPELL)
		local spellName = spellFunc[spellType](id)
		print(i, j, spellType, id, spellName)
	end
end

Prints all pet spells.

API GetSpellBookItemInfo 02
for i = 1, HasPetSpells() do
	local spellType, id = GetSpellBookItemInfo(i, BOOKTYPE_PET)
	local spellID = bit.band(0xFFFFFF, id)
	-- not sure what the non-spell IDs are
	local spellName = spellID > 100 and GetSpellInfo(spellID) or GetSpellBookItemName(i, BOOKTYPE_PET)
	local hasActionButton = C_ActionBar.HasPetActionButtons(id)
	print(i, spellType, id, spellID, spellName, hasActionButton)
end
Advertisement