Thread Tools Display Modes
11-29-10, 04:42 PM   #1
MoonWitch
A Firelord
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 455
bordercolor change based on UnitClassification

Hi,

Was updating oUF_alekk, and I am struck by one issue that I can't solve.
Basically, he had built in a function (in OverrideName) to change the bordercolor based on UnitClassificiation. I placed said if structure in the Shared section (line 836), but it doesn't seem to work. Any pointers?

https://github.com/moonwitch/oUF_ale...alekk.lua#L836
  Reply With Quote
11-29-10, 10:03 PM   #2
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Shared() is executed once, and that's during frame initialization. A hack is to insert your function into the self.__elements table, which is executed every OnShow, and :UpdateAllElements().

Code:
local UpdateClassification = function(self)
	local class = UnitClassification(self.unit)
	if(class == 'elite' or class = 'rareelite' or class == 'worldboss') then
		self:SetBackdropBorderColor(1,0.84,0,1)
	else
		self:SetBackdropBorderColor(1,1,1,1)
	end
end
-- 8<8<8<8<8<8<8<
	table.insert(self.__elements, UpdateClassification)
	self:RegisterEvent('UNIT_CLASSIFICATION_CHANGED', UpdateClassification)
You'll want the event as well, to handle those elites turning normal and such.
__________________
「貴方は1人じゃないよ」
  Reply With Quote
11-29-10, 10:08 PM   #3
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Also, your if(not unit) probably won't work. As of oUF 1.4.x it should be set to whatever single-unit is spawned or {party,raid}{,pet,target}.
__________________
「貴方は1人じゃないよ」
  Reply With Quote
11-30-10, 06:33 AM   #4
MoonWitch
A Firelord
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 455
Fixed both issues Thank you!

I thought the shared would be called every time I changed target as well... Hence the why I put it there.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » bordercolor change based on UnitClassification


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