So I'm attempting to add an addition to an addon of mine to automatically set your roles when you join a party.
So far what I've got seems to work however I can't seem to set 2 roles at once.
Current configuration:
Code:
local s = {
[1] = {
[1] = 0,
[2] = 0,
[3] = 0
},
[2] = {
[1] = 0,
[2] = 0,
[3] = 0
}
}
local function GetTreeMaxPoints(number)
local treePicked
local active = GetActiveTalentGroup()
for z=1, GetNumTalentTabs() do
local _,_,_,_,pointsSpent = GetTalentTabInfo(z, false, false, number)
s[number][z] = pointsSpent
end
local t = s[number]
if t[1] > t[2] and t[1] > t[3] then
return 1
elseif t[2] > t[1] and t[2] > t[3] then
return 2
elseif t[3] > t[1] and t[3] > t[2] then
return 3
else
return 0
end
end
function osAR()
if GetNumPartyMembers() >= 1 then
for i=1, GetNumTalentGroups() do
local tree = GetTreeMaxPoints(i)
local role = GetTalentTreeRoles(tree)
if role then
UnitSetRole("player", role)
end
end
end
end
local f = CreateFrame("frame")
f:SetScript("OnEvent", osAR)
f:RegisterEvent("PARTY_MEMBERS_CHANGED")
This does set the roles but if you have more than one role it spams and swaps the roles.
UnitSetRole() hasn't been defined yet, and the wow UI addon usage of it doesn't seem to give much insight.
Any ideas?