View Single Post
03-17-09, 11:21 AM   #912
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Originally Posted by Caellian View Post
If it has to be something like this which look quite weird to me:

Code:
oUF.Tags['[perchealth]'] = function(unit) 
	local min, max = UnitHealth(unit), UnitHealthMax(unit)
	if UnitHealthMax(unit) > UnitHealth(unit) then
		return Hex(self.ColorGradient(min/max, 0.69, 0.31, 0.31, 0.65, 0.63, 0.35, 0.33, 0.59, 0.33))..oUF.Tags['[perhp]'](unit)
	end
end
Then

Code:
oUF_cTags.lua:33: attempt to index global 'self' (a nil value)
But i guess that's not how it's supposed to be.
You have to create a local reference to the function, or access it through oUF.ColorGradient. You should also add |r to mark the end of your color.

Another thing you should do is to use the local variables you create, and not call the Unit* function again.

Originally Posted by Balkeep View Post
1 more noob question...
If i have updateName AND updateHealth in my layout i just call updateName from updateHealth, and then create a link on updateHealth like
self.PostUpdateHealth = updateHealth
But what if i dont have PostUpdateHealth in layout, how should i call updateName then? In some1s layout ive seen something like
self.UNIT_NAME_UPDATE(thats not exact refference =P) = updateName, but it doesnt work for me =(
The following will do what you want:
Code:
self:RegisterEvent('UNIT_NAME_UPDATE', updateName)
table.insert(self.__elements, updateName)
What this does is registering the event to your function (which makes it update if the name changes while you have the unit targeted). The second line inject your function to the table oUF uses to do full updates on a frame (which happens when a frame is shown). It's also the table oUF uses on eventless units to do updates.