Thread Tools Display Modes
01-07-11, 01:12 AM   #1
potbellypig
A Defias Bandit
Join Date: Jan 2011
Posts: 2
GetTalentInfo(x,y)

Code:
function TEST()
	local numTabs = GetNumTalentTabs();
	DEFAULT_CHAT_FRAME:AddMessage(numTabs)
	for x=1, numTabs do
		DEFAULT_CHAT_FRAME:AddMessage(GetTalentTabInfo(x));
		local numTalents = GetNumTalents(x);
		for y=1, numTalents do
			talentName, icon, tier, column, rank, maxRank= GetTalentInfo(x,y);
			DEFAULT_CHAT_FRAME:AddMessage(talentName..": "..rank.."/"..maxRank);
		end
This works for every class except for mages. When executed on a mage the following error occurs:

Message: Interface\AddOns\GearComparison\GearComparison.lua:109: attempt to concatenate global 'talentName' (a nil value)
Time: 01/07/11 17:08:32
Count: 1
Stack: Interface\AddOns\GearComparison\GearComparison.lua:109: in function `?'
Interface\FrameXML\ChatFrame.lua:4126: in function `ChatEdit_ParseText'
Interface\FrameXML\ChatFrame.lua:3737: in function `ChatEdit_SendText'
Interface\FrameXML\ChatFrame.lua:3775: in function `ChatEdit_OnEnterPressed'
[string "*:OnEnterPressed"]:1: in function <[string "*:OnEnterPressed"]:1>

Locals: numTabs = 3
(for index) = 1
(for limit) = 3
(for step) = 1
x = 1
numTalents = 22
(for index) = 15
(for limit) = 22
(for step) = 1
y = 15
(*temporary) = nil
(*temporary) = ": 0/0"
(*temporary) = "0"
(*temporary) = "/"
(*temporary) = "0"
(*temporary) = "attempt to concatenate global 'talentName' (a nil value)"
Whats going on here?
  Reply With Quote
01-07-11, 02:57 AM   #2
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
This works fine for me:
Lua Code:
  1. for tab = 1, GetNumTalentTabs() do
  2.     for talent = 1, GetNumTalents(tab) do
  3.         print(GetTalentInfo(tab, talent))
  4.     end
  5. end
  Reply With Quote
01-08-11, 05:55 AM   #3
potbellypig
A Defias Bandit
Join Date: Jan 2011
Posts: 2
Okay, for every other class, using the cose i posted I am able to sort through and determine spec by currRank / maxRank. How would I do this with the rainbow of pretty text that your code prints? (I've been teaching myself so far, treat me like an infant if you must, just don't put me down for it... I know its probably very obvious)
  Reply With Quote
01-08-11, 06:24 AM   #4
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
If all you are interested in is determining which spec a player is, you can use GetPrimaryTalentTree in conjunction with GetTalentTabInfo.

Code:
local tab = GetPrimaryTalentTree()
local name = select(2, GetTalentTabInfo(tab))
print(name)
This prints Survival for example, on a hunter who has chosen Survival as their main tree.

http://wowprogramming.com/docs/api/GetPrimaryTalentTree
http://wowprogramming.com/docs/api/GetTalentTabInfo
__________________
Oh, the simulated horror!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » GetTalentInfo(x,y)


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off