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:
for skillIndex=1,GetNumSkillLines(SKILL_TYPE_GUILD) do
d("Name: "..GetSkillLineInfo(SKILL_TYPE_GUILD, skillIndex)
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:
local magesGuild = 0
local fightersGuild = 0
local undaunted = 0
local function SetGuildIndex(skillIndex)
local guildName = GetSkillLineInfo(SKILL_TYPE_GUILD, skillIndex)
if guildName == "Fighters Guild" then
fightersGuild = skillIndex
elseif guildName == "Mages Guild" then
magesGuild = skillIndex
elseif guildName == "Undaunted" then
undaunted = skillIndex
end
end
for skillIndex=1,GetNumSkillLines(SKILL_TYPE_GUILD) do
SetGuildIndex(skillIndex)
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:
EVENT_MANAGER:RegisterForEvent("someuniquename", EVENT_SKILL_LINE_ADDED, function(_, skillType, skillIndex)
if skillType == SKILL_TYPE_GUILD then
SetGuildIndex(skillIndex)
end
end)