C_SpellBook.GetSpellBookItemInfo

From Warcraft Wiki
Jump to navigation Jump to search
Flavors
Links
Info
Added in 11.0.0

Returns info for a spellbook item.

spellBookItemInfo = C_SpellBook.GetSpellBookItemInfo(index, spellBank)

Arguments

index
number - Spellbook slot index, ranging from 1 through the total number of spells across all tabs and pages
spellBank
enum - Enum.SpellBookSpellBank.Player or Enum.SpellBookSpellBank.Pet

Returns

spellBookItemInfo
SpellBookItemInfo
Field Type Description
actionID number Represents a spellID for spells, flyoutID for flyouts, or petActionID for pet actions
spellID number May be nil if item is not a spell; may be different from actionID if spell is overridden
itemType enum Enum.SpellBookItemType
name string The localized name of the spell
subName string May be empty if flyout, or if spell's data isn't loaded yet
iconID number fileID - The spell icon texture
isPassive boolean True if the item is a passive spell; Will always be false if it is not a spell
isOffSpec boolean True if the item belongs to a non-active specialization
skillLineIndex number Index of the SkillLine this SpellBookItem is part of; nil if this SpellBookItem isn't part of a SkillLine

Details

Related API C_SpellBook.GetSpellBookItemName

Example

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

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 spellBookItemInfo = C_SpellBook.GetSpellBookItemInfo(j, Enum.SpellBookSpellBank.Player)
		local spellType, id = spellBookItemInfo.itemType, spellBookItemInfo.actionID
		local spellName
		if spellType == 1 then
			spellName = C_Spell.GetSpellName(id)
			spellType = "Spell"
		elseif spellType == 2 then
			spellName = C_Spell.GetSpellName(id)
			spellType = "Future Spell"
		elseif spellType == 4 then
			spellName = GetFlyoutInfo(id)
			spellType = "Flyout"
		end
		print(i, j, spellType, id, spellName)
	end
end

API GetSpellBookItemInfo 01.png

Prints all pet spells.

for i = 1, C_SpellBook.HasPetSpells() do
	local spellBookItemInfo = C_SpellBook.GetSpellBookItemInfo(i, Enum.SpellBookSpellBank.Pet)
	local id = spellBookItemInfo.actionID
	local spellID = bit.band(0xFFFFFF, id)
	-- not sure what the non-spell IDs are
	local spellName = spellID > 100 and C_Spell.GetSpellName(spellID) or C_SpellBook.GetSpellBookItemName(i, Enum.SpellBookSpellBank.Pet)
	local hasActionButton = C_ActionBar.HasPetActionButtons(id)
	print(i, "Pet", id, spellID, spellName, hasActionButton)
end

API GetSpellBookItemInfo 02.png

Patch changes