Thread: oUF PP
View Single Post
08-11-16, 08:44 PM   #13
Freebaser
A Molten Kobold Bandit
 
Freebaser's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 135
Here is a power tag that should match the power bar.

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 r) then
			if(r > 1) or (g > 1) or (b > 1) then
				r, g, b = r / 255, g / 255, b / 255
			end
		else
			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
oUF.Tags.Events['freeb:pp'] = 'UNIT_POWER UNIT_MAXPOWER'

Last edited by Freebaser : 08-11-16 at 09:10 PM. Reason: updated code
  Reply With Quote