-
Posted by blahshaw on Tue, 13 Sep 2011 21:13:33
I'm trying to get the names of the professions that the player has. Here's my code:
prof1, prof2, archaeology, fishing, cooking, firstAid = GetProfessions("player"); name, icon, skillLevel, maxSkillLevel, numAbilities, spelloffset, skillLine, skillModifier = GetProfessionInfo(prof1) print(name) name, icon, skillLevel, maxSkillLevel, numAbilities, spelloffset, skillLine, skillModifier = GetProfessionInfo(prof2) print(name)
The result is an error:
Message: `Interface\AddOns\PimpMyToon\PimpMyToon.lua:2: Usage: GetProfessionSkillLine(index) Time: 09/13/11 14:08:11 Count: 1 Stack: [C]: in function `GetProfessionInfo Locals: (*temporary) = nil'
HOWEVER, if I type /reload ui then the addon works. Here's a sample output from my character that has tailoring/enchanting:
Enchanting Tailoring
Additionaly, if I log out and back in on the same character, I get the same Lua error message as mentioned above. What is causing this? Why do I have to type /reload ui before it works?
Thanks for the help!
-
Posted by jnwhiteh on Tue, 13 Sep 2011 21:59:45
That information is not available immediately when the addon is being loaded. You should wait for an event that occurs that is relevant to the profession information being loaded. This is why it works on a reload but not when the cache is cold.
-
Posted by blahshaw on Wed, 14 Sep 2011 00:46:27
Open/close a profession window perhaps? Is there a function that does this?
-
Posted by jnwhiteh on Wed, 14 Sep 2011 07:19:25
That's unnecessary. Glancing at the spellbook frame, you can use the
SKILL_LINES_CHANGED
event.