Thread Tools Display Modes
Prev Previous Post   Next Post Next
09-11-10, 03:35 AM   #1
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 331
UnitSetRole() -- Cataclysm Help.

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?
  Reply With Quote
 

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » UnitSetRole() -- Cataclysm Help.


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