Thread: Stuf + Threat
View Single Post
Old 06-10-11, 09:01 PM   #30
Lily.Petal
A Molten Giant
 
Lily.Petal's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 537
Originally Posted by Taryble View Post
Well, it's mostly for doing things that StUF's (fairly limited) tag system won't handle.

...

Here's a more interesting text that I use (my "Power" text).
Code:
function(unit, cache, textframe)
  local powtype, maxmp, curmp = UnitPowerType(unit), UnitPowerMax(unit), UnitPower(unit)
  local cc = PowerBarColor[powtype]
  local permp = 100*curmp/maxmp 
  if (powtype == 1 or powtype == 3) then
    local _, class = UnitClass(unit)
    if (class == "DRUID" and unit == "player") then
      local maxdmp, curdmp, ccd = UnitPowerMax(unit,0), UnitPower(unit,0), PowerBarColor[0]
      if curdmp ~= maxdmp then
        return "|cff%02x%02x%02x%.0f|r%% | |cff%02x%02x%02x%s|r",ccd.r*255,ccd.g*255,ccd.b*255,100*curdmp/maxdmp,cc.r*255,cc.g*255,cc.b*255,curmp
      else
        return "|cff%02x%02x%02x%s|r",cc.r*255,cc.g*255,cc.b*255,curmp 
      end
    else        
      return "|cff%02x%02x%02x%s|r",cc.r*255,cc.g*255,cc.b*255,curmp
    end 
  elseif curmp ~= maxmp then 
    return "|cff%02x%02x%02x%.0f|r%%",cc.r*255,cc.g*255,cc.b*255,permp 
  elseif powtype == 0 then 
    return "|cff%02x%02x%02x%s|r",cc.r*255,cc.g*255,cc.b*255,maxmp 
  end
end
This one is rather fun. Basically, if you're a druid in shapeshift form, it shows your rage/energy - and if you're below full mana, it shows your mana as a percentage (separated by a pipe character). If you're a Warrior or Rogue, it just shows your rage/energy.

If you're anything else, it shows your percentage of power - but if you're at full power, it just shows your maximum power. (ie, 99% OR 78532, for example).

And, yes, all you Lua coders out there, please feel free to take a look at it and give me advice on how to make it better.

I haven't really done any programming since 1997, and Lua wasn't very common back then, so this is all sorta tossed together with half-remembered scraps of programming theory and style.
Maybe this may be of some help?
__________________

Aggro Color to KG Panels Borders - Nibelheim
Lua Based UI Hider - Nibelheim
Custom LUA PowerText - Stuf - Nibelheim, Seerah

Last edited by Lily.Petal : 06-10-11 at 09:03 PM.
Lily.Petal is offline   Reply With Quote