View Single Post
11-14-09, 08:58 PM   #316
Gandoch
A Wyrmkin Dreamwalker
 
Gandoch's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 50
Originally Posted by p3lim View Post
Mind showing your layout's tags.lua file?
Code:
oUF.Tags['[ghealth]'] = function(unit)
	local min, max = UnitHealth(unit), UnitHealthMax(unit)
(50)	local color = hex(oUF.ColorGradient(min/max, unpack(oUF.colors.smooth)))

	local def = min ~= max and ("-%s%s|r"):format(color, shortVal(max-min))
	local full = min == max and ("%s%s|r"):format(color, shortVal(max))
	local detailed = ("%s%s|r - %s%d|r%%"):format(color, shortVal(min), color, min/max*100)
	local status = UnitIsAFK(unit) and "|cffabababAFK|r" or not UnitIsConnected(unit) and "|cffcbcbcbOffline|r" or UnitIsGhost(unit) and "|cffdededeGhost|r" or UnitIsDead(unit) and "|cffff0000Dead|r"
	
	return status and status or (unit == "target" or unit == "targettarget" or unit == "focus") and detailed or (unit ~= "player" and unit ~= "pet" and not UnitInRaid(unit)) and full or def
end
Originally Posted by haste
The reason it happens it because you divide by zero, then feed that as a percentage value into oUF's ColorGradient function. What I'm trying to do however is fix that error.
I can try to add error checking to the tag, but nothing I've tried in modifying the ColorGradient function has worked.