Thread Tools Display Modes
11-19-10, 12:56 PM   #1
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
UnitName coloring

My issue was the following.

After instance ends some players leave the group. The name is based on [name] and updates correctly. But I set the color in my postUpdateHealth which does not get fired because all units have 100% hp at that moment and so no update. But since I have some of my coloring for units in that function the names do not get recolored. Need to fix that now...

Are there any tipps on that?

Is there any
Code:
string.classColored = true
string.classFactionColored = true
etc...?

Or how do I combine [dead][offline][happinesscolor][factioncolor][raidcolor] with [name] ?

I think it is probably the best to create my own [diablo:name] tag and do all the checks in that, right?
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 11-19-10 at 01:14 PM.
  Reply With Quote
11-19-10, 01:23 PM   #2
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
I would go with a tag.

You can get all the checks in there, probably [factioncolor] for not UnitIsPlayer(unit), etc.

I wouldn't include happiness, though. This is obviously only needed for pets and you can always make just a tag for pets or simply use the existing font string for your name tag and change what's in it.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
11-19-10, 01:24 PM   #3
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Yeah ... wow @ me. I just understood oUF tags. Never really digged into that.

I only had one event per tag. But you can have ... moar! Always new stuff to learn.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
11-19-10, 01:28 PM   #4
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Tags are awesome, imho.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
11-19-10, 02:12 PM   #5
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
This is what I have now for names

lua Code:
  1. [code]  
  2.   ---------------------------------------------
  3.   -- TAGS
  4.   ---------------------------------------------
  5.  
  6.   --rgb to hex func
  7.   local function RGBPercToHex(r, g, b)
  8.     r = r <= 1 and r >= 0 and r or 1
  9.     g = g <= 1 and g >= 0 and g or 1
  10.     b = b <= 1 and b >= 0 and b or 1
  11.     return string.format("%02x%02x%02x", r*255, g*255, b*255)
  12.   end
  13.  
  14.   ---------------------------------------------
  15.  
  16.   --color tag
  17.   oUF.Tags["diablo:color"] = function(unit)
  18.     local color = { r=1, g=1, b=1, }
  19.     if UnitIsDeadOrGhost(unit) or not UnitIsConnected(unit) then
  20.       color = {r = 0.4, g = 0.4, b = 0.4}
  21.     elseif UnitIsPlayer(unit) then
  22.       color = rRAID_CLASS_COLORS[select(2, UnitClass(unit))] or RAID_CLASS_COLORS[select(2, UnitClass(unit))]
  23.     elseif UnitIsUnit(unit, "pet")  then
  24.       color = cfg.happycolors[GetPetHappiness()]
  25.     else
  26.       color = FACTION_BAR_COLORS[UnitReaction(unit, "player")]
  27.     end
  28.     return RGBPercToHex(color.r,color.g,color.b)
  29.   end
  30.  
  31.   ---------------------------------------------
  32.  
  33.   --colorsimple tag
  34.   oUF.Tags["diablo:colorsimple"] = function(unit)
  35.     local color = { r=1, g=1, b=1, }
  36.     if UnitIsDeadOrGhost(unit) or not UnitIsConnected(unit) then
  37.       color = {r = 0.4, g = 0.4, b = 0.4}
  38.     end
  39.     return RGBPercToHex(color.r,color.g,color.b)
  40.   end
  41.  
  42.   ---------------------------------------------
  43.  
  44.   --name tag
  45.   oUF.Tags["diablo:name"] = function(unit, rolf)
  46.     local color = oUF.Tags["diablo:color"](unit)
  47.     local name = UnitName(rolf or unit)
  48.     return "|cff"..color..(name or "").."|r"
  49.   end
  50.   oUF.TagEvents["diablo:name"] = "UNIT_NAME_UPDATE UNIT_HEALTH UNIT_MAXHEALTH UNIT_CONNECTION"
  51.  
  52.   ---------------------------------------------
  53.  
  54.   --hp value
  55.   oUF.Tags["diablo:hpval"] = function(unit)
  56.     local color = oUF.Tags["diablo:colorsimple"](unit)
  57.     local hpval
  58.     if UnitIsDeadOrGhost(unit) then
  59.       hpval = "dead"
  60.     elseif not UnitIsConnected(unit) then
  61.       hpval = "off"
  62.     else
  63.       hpval = func.numFormat(UnitHealth(unit) or 0).." / "..oUF.Tags["perhp"](unit).."%"
  64.     end
  65.     return "|cff"..color..(hpval or "").."|r"
  66.   end
  67.   oUF.TagEvents["diablo:hpval"] = "UNIT_HEALTH UNIT_MAXHEALTH UNIT_CONNECTION"
  68.  
  69.     ---------------------------------------------
  70.  
  71.   --short hp value
  72.   oUF.Tags["diablo:shorthpval"] = function(unit)
  73.     local color = oUF.Tags["diablo:colorsimple"](unit)
  74.     local hpval
  75.     if UnitIsDeadOrGhost(unit) then
  76.       hpval = "dead"
  77.     elseif not UnitIsConnected(unit) then
  78.       hpval = "off"
  79.     else
  80.       hpval = func.numFormat(UnitHealth(unit) or 0)
  81.     end
  82.     return "|cff"..color..(hpval or "").."|r"
  83.   end
  84.   oUF.TagEvents["diablo:shorthpval"] = "UNIT_HEALTH UNIT_MAXHEALTH UNIT_CONNECTION"
  85.  
  86.   ---------------------------------------------
  87.  
  88.   --power value
  89.   oUF.Tags["diablo:ppval"] = function(unit)
  90.     local ppval = func.numFormat(UnitPower(unit) or 0).." / "..oUF.Tags["perpp"](unit).."%"
  91.     return ppval or ""
  92.   end
  93.   oUF.TagEvents["diablo:ppval"] = "UNIT_POWER UNIT_MAXPOWER"
  94.  
  95.   ---------------------------------------------
  96.  
  97.   oUF.Tags["diablo:misshp"] = function(unit)
  98.     local color = oUF.Tags["diablo:colorsimple"](unit)
  99.     local hpval
  100.     if UnitIsDeadOrGhost(unit) then
  101.       hpval = "dead"
  102.     elseif not UnitIsConnected(unit) then
  103.       hpval = "off"
  104.     else
  105.       local max, min = UnitHealthMax(unit), UnitHealth(unit)
  106.       if max-min > 0 then
  107.         hpval = "-"..func.numFormat(max-min)
  108.       end
  109.     end    
  110.     return "|cff"..color..(hpval or "").."|r"
  111.   end
  112.   oUF.TagEvents["diablo:misshp"] = "UNIT_HEALTH UNIT_MAXHEALTH UNIT_CONNECTION"
  113.  
  114.   ---------------------------------------------
  115.  
  116.   oUF.Tags["diablo:raidhp"] = function(unit, rolf)
  117.     local color = oUF.Tags["diablo:colorsimple"](unit)
  118.     local hpval
  119.     if UnitIsDeadOrGhost(unit) then
  120.       hpval = "dead"
  121.     elseif not UnitIsConnected(unit) then
  122.       hpval = "off"
  123.     else
  124.       local max, min = UnitHealthMax(unit), UnitHealth(unit)
  125.       if max-min > 0 then
  126.         hpval = "-"..func.numFormat(max-min)
  127.         --rewrite color to white
  128.         color = "ffffff"
  129.       else
  130.         hpval = UnitName(rolf or unit)
  131.       end
  132.     end    
  133.     return "|cff"..color..(hpval or "").."|r"
  134.   end
  135.   oUF.TagEvents["diablo:raidhp"] = "UNIT_NAME_UPDATE UNIT_HEALTH UNIT_MAXHEALTH UNIT_CONNECTION"
  136.  
  137.   ---------------------------------------------
  138.  
  139. [/code]

Works so far .

*edit* Finished. Man tags are awesome!
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 11-19-10 at 03:19 PM.
  Reply With Quote
11-19-10, 03:41 PM   #6
Luzzifus
A Warpwood Thunder Caller
 
Luzzifus's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 94
Originally Posted by zork View Post
Man tags are awesome!
They rock!
Hooray for boo... .. tags!

Let's turn this into a praise-the-tags-thread!
  Reply With Quote
11-19-10, 04:16 PM   #7
Monolit
A Black Drake
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 81
Originally Posted by Luzzifus View Post
They rock!
Hooray for boo... .. tags!

Let's turn this into a praise-the-tags-thread!
even banana smile is not nearly as cool as tags!

Last edited by Monolit : 11-19-10 at 04:18 PM.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » [name] tag update on party/raid member change


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off