View Single Post
07/05/14, 05:41 AM   #2
Harven
 
Harven's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 135
Hey,
I think the skillIndex is dynamic so with one character it can be 2 but with other - 1. It's that way because:

Lua Code:
  1. for skillIndex=1,GetNumSkillLines(SKILL_TYPE_GUILD) do
  2.     d("Name: "..GetSkillLineInfo(SKILL_TYPE_GUILD, skillIndex)
  3. end

So if you're only member of the Mages guild, then the guild skillIndex is 1, but if you're only member of the Figters guild, then the guild skillIndex is also 1. Looks like the only way is to check the skill name.

When your addon is loaded you can do:

Lua Code:
  1. local magesGuild = 0
  2. local fightersGuild = 0
  3. local undaunted = 0
  4.  
  5. local function SetGuildIndex(skillIndex)
  6.     local guildName = GetSkillLineInfo(SKILL_TYPE_GUILD, skillIndex)
  7.     if guildName == "Fighters Guild" then
  8.         fightersGuild = skillIndex
  9.     elseif guildName == "Mages Guild" then
  10.         magesGuild = skillIndex
  11.     elseif guildName == "Undaunted" then
  12.         undaunted = skillIndex
  13.     end
  14. end
  15.  
  16. for skillIndex=1,GetNumSkillLines(SKILL_TYPE_GUILD) do
  17.     SetGuildIndex(skillIndex)
  18. end
Of course you should use localized names instead.

You must also remember that you start without any guild skill. So you should respond to the EVENT_SKILL_LINE_ADDED event, like this:

Lua Code:
  1. EVENT_MANAGER:RegisterForEvent("someuniquename", EVENT_SKILL_LINE_ADDED, function(_, skillType, skillIndex)
  2.     if skillType == SKILL_TYPE_GUILD then
  3.         SetGuildIndex(skillIndex)
  4.     end
  5. end)
  Reply With Quote