Thread: oUF PP
View Single Post
08-17-16, 09:38 PM   #17
Freebaser
A Molten Kobold Bandit
 
Freebaser's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 135
Guess we can try updating the hex function instead. Replace it with this.

Code:
local function hex(r, g, b)
  if(type(r) == 'table') then
    if(r.r) then r, g, b = r.r, r.g, r.b else r, g, b = unpack(r) end
  end

  if(r > 1) then
    return ('|cff%02x%02x%02x'):format(r, g, b)
  else
    return ('|cff%02x%02x%02x'):format(r * 255, g * 255, b * 255)
  end
end
And update the power tag again.

Code:
oUF.Tags.Methods['freeb:pp'] = function(u) 
	local power, powermax = UnitPower(u), UnitPowerMax(u)

	if power > 0 then
		local ptype, ptoken, r, g, b = UnitPowerType(u)
		local t = oUF.colors.power[ptoken]

		if(not t and not r) then
			t = oUF.colors.power[ptype]
		end

		if(t) then
			r, g, b = t[1], t[2], t[3]
		end

		local perc = floor((power/powermax)*100+.5)
		perc = powermax > 150 and " | "..perc.."%|r" or ""

		return hex(r, g, b)..siValue(power)..perc.."|r"
	end
end
  Reply With Quote