Quantcast WoWInterface - View Single Post - PitBull4 Lua texts - Colored health and power?
View Single Post
06-21-11, 12:18 AM   #4
Nibelheim
local roygbi-
 
Nibelheim's Avatar
Featured
Join Date: Jan 2010
Posts: 1,600
Let's try something a bit simpler first, see if we can narrow down the error. I can't login to WoW these days, so dry coding can be a pain.

Code:
local color
local pType, pToken, altR, altG, altB = UnitPowerType(unit)
local pCur, pMax = Power(unit), MaxPower(unit)

if (pMax > 0) then
  if PitBull4.PowerColors[pToken] then
    color = PitBull4.PowerColors[pToken]
  else
    if (altR == nil) then
      color = PitBull4.PowerColors["MANA"]
    else
      color = {[1] = altR, [2] = altG, [3] = altB}
    end
  end
  
  return "|cff%02x%02x%02x%s", color[1]*255, color[2]*255, color[3]*255, Short(pCur, true)
end
The only events you should need are:
UNIT_POWER
UNIT_DISPLAYPOWER
  Reply With Quote