WoW:API GetNumTalentTabs: Difference between revisions
m ({{wowapi}}) |
m (Move page script moved page API GetNumTalentTabs to API GetNumTalentTabs without leaving a redirect) |
||
| (5 intermediate revisions by 5 users not shown) | |||
| Line 2: | Line 2: | ||
Returns the total number of tabs of talents one has. | Returns the total number of tabs of talents one has. | ||
numTabs = GetNumTalentTabs(); | local numTabs = GetNumTalentTabs([inspect[,pet]]); | ||
---- | |||
;''Arguments'' | |||
:;inspect : [[Boolean]] - If true returns the information for the inspected unit instead of the player. New with 2.3. | |||
:;pet : [[Boolean]] - If true returns the information for the pet instead of the player. New with 2.3. | |||
---- | ---- | ||
| Line 14: | Line 21: | ||
local numTabs = GetNumTalentTabs() | local numTabs = GetNumTalentTabs() | ||
DEFAULT_CHAT_FRAME:AddMessage( numTabs ) | DEFAULT_CHAT_FRAME:AddMessage( numTabs ) | ||
;''Results'' : Displays the number of talents tabs one has. | ;''Results'' : Displays the number of talents tabs one has. | ||
;''Useful code: iteration over all talents'' | |||
function talentpairs(inspect,pet) | |||
local tab,tal=1,0 | |||
return function() | |||
tal=tal+1 | |||
if tal>GetNumTalents(tab,inspect,pet) then | |||
tal=1 | |||
tab=tab+1 | |||
end | |||
if tab<=GetNumTalentTabs(inspect,pet) then | |||
return tab,tal | |||
end | |||
end | |||
end | |||
Now, | |||
for tab,talent in talentpairs() do DEFAULT_CHAT_FRAME:AddMessage(tab..","..talent) end | |||
- prints all player's tab-talent pairs from 1,1 through 3,20-something. | |||
for tab,talent in talentpairs(false,true) do DEFAULT_CHAT_FRAME:AddMessage(tab..","..talent) end | |||
- prints all player's pet's tab-talent pairs; doesn't execute at all if the player has no pet. | |||
for tab,talent in talentpairs(true) do DEFAULT_CHAT_FRAME:AddMessage(tab..","..talent) end | |||
- prints all inspected player's tab-talent pairs; doesn't execute at all if there is no inspected player. | |||
---- | |||
;''Caveats'' | |||
There is a really annoying bug with this where it will sometimes return that there are 0 tabs. Doing a reload of the User Interface appears to clear it up, but that's of limited utility. Either avoid using this API, or include code to handle the case where it returns 0. | |||
This has only happened to me at startup, if talents are checked before [[Events_P_(Party,_Petition,_Pet,_PlayerBank,_Player)#PLAYER_ALIVE|PLAYER_ALIVE]] fires. They may not be available to the API before that event. - [[User:Sine Pi|Sine Pi]] ([[User talk:Sine Pi|talk]]) 12:42, 28 July 2009 (UTC) | |||
--- | |||
;Cataclysm | |||
This API has been changed for Cataclysm: | |||
(unknown), TreeNameLocalized, TreeDescription, TreeIcon, PointsSpent, TreeNameUnlocalized , (unknown), (unknown) = GetTalentTabInfo(i) | |||
For instance, as paladin you could get: | |||
unknown A = 831 | |||
TreeNameLocalized = Holy | |||
TreeDescription = Invokes the power of the Light to protect and to heal. | |||
TreeIcon = Interface\Icons\Spell_Holy_HolyBolt | |||
PointsSpent = 5 | |||
TreeNameUnlocalized = PALADINHOLY | |||
unknown B = 0 | |||
unknown C = true | |||
== Patch changes == | |||
{{Patch 5.0.4|note=Replaced by {{api|GetNumSpecializations}}.}} | |||
== See also == | |||
* {{api|SetActiveSpecGroup}} | |||
* {{api|GetNumSpecGroups}} | |||
* {{api|GetSpecialization}} | |||
* {{api|GetNumUnspentTalents}} | |||
* {{api|GetNumSpecializations}} | |||
* {{api|GetSpecializationInfo}} | |||
* {{api|GetSpecializationRole}} | |||
* {{api|t=e|ACTIVE_TALENT_GROUP_CHANGED}} | |||
Latest revision as of 04:46, 15 August 2023
Returns the total number of tabs of talents one has.
local numTabs = GetNumTalentTabs([inspect[,pet]]);
- Arguments
- inspect
- Boolean - If true returns the information for the inspected unit instead of the player. New with 2.3.
- pet
- Boolean - If true returns the information for the pet instead of the player. New with 2.3.
- Returns
- numTabs
- Integer - The number of tabs one has.
- Example
local numTabs = GetNumTalentTabs() DEFAULT_CHAT_FRAME:AddMessage( numTabs )
- Results
- Displays the number of talents tabs one has.
- Useful code: iteration over all talents
function talentpairs(inspect,pet)
local tab,tal=1,0
return function()
tal=tal+1
if tal>GetNumTalents(tab,inspect,pet) then
tal=1
tab=tab+1
end
if tab<=GetNumTalentTabs(inspect,pet) then
return tab,tal
end
end
end
Now,
for tab,talent in talentpairs() do DEFAULT_CHAT_FRAME:AddMessage(tab..","..talent) end
- prints all player's tab-talent pairs from 1,1 through 3,20-something.
for tab,talent in talentpairs(false,true) do DEFAULT_CHAT_FRAME:AddMessage(tab..","..talent) end
- prints all player's pet's tab-talent pairs; doesn't execute at all if the player has no pet.
for tab,talent in talentpairs(true) do DEFAULT_CHAT_FRAME:AddMessage(tab..","..talent) end
- prints all inspected player's tab-talent pairs; doesn't execute at all if there is no inspected player.
- Caveats
There is a really annoying bug with this where it will sometimes return that there are 0 tabs. Doing a reload of the User Interface appears to clear it up, but that's of limited utility. Either avoid using this API, or include code to handle the case where it returns 0.
This has only happened to me at startup, if talents are checked before PLAYER_ALIVE fires. They may not be available to the API before that event. - Sine Pi (talk) 12:42, 28 July 2009 (UTC)
---
- Cataclysm
This API has been changed for Cataclysm:
(unknown), TreeNameLocalized, TreeDescription, TreeIcon, PointsSpent, TreeNameUnlocalized , (unknown), (unknown) = GetTalentTabInfo(i)
For instance, as paladin you could get:
unknown A = 831
TreeNameLocalized = Holy
TreeDescription = Invokes the power of the Light to protect and to heal.
TreeIcon = Interface\Icons\Spell_Holy_HolyBolt
PointsSpent = 5
TreeNameUnlocalized = PALADINHOLY
unknown B = 0
unknown C = true
Patch changes
Template:Mists-inline <span style="" title="Patch 5.0.4">Patch 5.0.4</span> (patch date::28-August-2012): Replaced by GetNumSpecializations.