WoW:API GetSpellName: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
 
m (Move page script moved page API GetSpellName to API GetSpellName without leaving a redirect)
 
(6 intermediate revisions by 6 users not shown)
Line 1: Line 1:
Retrieves the spell name and spell rank for a spell in the player's spellbook.
{{wowapi}}
Retrieves the spell name and spell rank for a spell in the player's spellbook. If you're trying to read the spell book at login, register for the [[Events P (Party, Petition, Pet, PlayerBank, Player)#PLAYER_LOGIN|PLAYER_LOGIN]] event.


  ''spellName'', ''spellRank'' = GetSpellName( ''spellId'', ''bookType'' );
  ''spellName'', ''spellRank'' = GetSpellName( ''spellId'', ''bookType'' );
Line 36: Line 37:


----
----
--[[User:Sahazhe|Sahazhe]] 07:52, 24 Feb 2005 (EST)
== Cataclysm Change ==
----
This function has been renamed to {{api|GetSpellBookItemName}}().
{{Template:WoW API}}
Also in 4.0.1, certain spells will not appear in the player's spell book, such as Track Beasts.  As such, it will not be searchable from this function.
[[Category:API Spell Functions|CastSpell]]

Latest revision as of 04:46, 15 August 2023

WoW API < GetSpellName

Retrieves the spell name and spell rank for a spell in the player's spellbook. If you're trying to read the spell book at login, register for the PLAYER_LOGIN event.

spellName, spellRank = GetSpellName( spellId, bookType );

Arguments
spellId
Integer - Spell ID. Valid values are 1 through total number of spells in the spellbook on all pages and all tabs, ignoring empty slots.
bookType
String - Either BOOKTYPE_SPELL ("spell") or BOOKTYPE_PET ("pet").

Returns
spellName
String - Name of the spell as it appears in the spellbook, eg. "Lesser Heal"
spellRank
String - The spell rank or type, eg. "Rank 3", "Racial Passive". This can be an empty string. Note: for the Enchanting trade skill at rank Apprentice, the returned string contains a trailing space, ie. "Apprentice ". This might be the case for other trade skills and ranks also.

Example
local i = 1
while true do
   local spellName, spellRank = GetSpellName(i, BOOKTYPE_SPELL)
   if not spellName then
      do break end
   end
   
   -- use spellName and spellRank here
   DEFAULT_CHAT_FRAME:AddMessage( spellName .. '(' .. spellRank .. ')' )
   
   i = i + 1
end
Result
Displays every spell in the player's spellbook, on all pages and all tabs, in the format required by CastSpellByName.

Cataclysm Change[edit]

This function has been renamed to GetSpellBookItemName(). Also in 4.0.1, certain spells will not appear in the player's spell book, such as Track Beasts. As such, it will not be searchable from this function.