Thread Tools Display Modes
06-20-11, 10:51 PM   #1
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,364
PitBull4 Lua texts - Colored health and power?

I'm using PitBull4 for my unit frames, and I've been trying to figure out how to get the health text to be health colored and the power text the color of the characters power using PB4's Lua texts. I've tried a few things, but only get errors. I found an example somewhere to color my characters' level by class, but can't seem to find anything about health color or power color.

What I'm using at the moment:

Class colored level:
Code:
Outline()
if UnitIsPlayer(unit) then
local cr,cg,cb = ClassColor(unit)
return "|cff%02x%02x%02x%s|r",cr,cg,cb,Level(unit)
end
Health (which is always bright green, but I want the color to change as the health goes down, if possible):
Code:
Outline()
return "|cff00ff00%s|r",HP(unit)
Power (which I'd like to be power colored):
Code:
Outline()
return "%s",Power(unit)
The characters' name is just fine in white, and this is what I use for that:
Code:
Outline()
return '%s %s%s%s',Name(unit),Angle(AFK(unit) or DND(unit))
I have posted a similar question on the WoWAce PitBull forum (Post), but I am posting it here, also, to try to get a "broader audience", as it were. Hopefully, someone can help me with this problem.

Last edited by jeffy162 : 06-20-11 at 10:54 PM.
  Reply With Quote
06-20-11, 11:03 PM   #2
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Some examples:

Power (supports Druid Mana and Alt Power types)
Code:
local color
local pType, pToken, altR, altG, altB = UnitPowerType(unit)
local pCur, pMax, pCurMana, pMaxMana = Power(unit), MaxPower(unit), Power(unit, 0), MaxPower(unit, 0)

if (pMax > 0) then
  if PitBull4.PowerColors[pToken] then
    color = PitBull4.PowerColors[pToken]
  else
    if (not altR) then
      color = PitBull4.PowerColors["MANA"]
    else
      color = {[1] = altR, [2] = altG, [3] = altB}
    end
  end
  
  if (pToken ~= "MANA") then
    if (pMaxMana > 0) then
      local DManaColor = PitBull4.PowerColors["MANA"]
      return "|cff%02x%02x%02x%s |cff%02x%02x%02x%s", color[1]*255, color[2]*255, color[3]*255, Short(pCur, true), DManaColor[1]*255, DManaColor[2]*255, DManaColor[3]*255, Short(pCurMana, true)
    end
  else
    return "|cff%02x%02x%02x%s", color[1]*255, color[2]*255, color[3]*255, Short(pCur, true)
  end
end


Health (green to red)
Code:
local cur, max = HP(unit), MaxHP(unit)
local PerHP = cur/max
local hr, hg, hb

if (PerHP < 0.5) then
  hr = 255
  hg = 255 * PerHP * 2
  hb = 0
else
  hr = 255 * (1 - ((PerHP - 0.5) * 2))
  hg = 255
  hb = 0
end

return "|cff%02x%02x%02x%s",hr,hg,hb,Short(cur,true)

Last edited by Nibelheim : 06-21-11 at 01:12 AM.
  Reply With Quote
06-20-11, 11:55 PM   #3
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,364
Thank you very much for your help, Nibelheim, I appreciate it.

The health text code works perfectly. The power text code, however, is another matter. I copied it and pasted it directly into PB4, and got this error through !BugGrabber.lua in my SavedVariables:

["message"] = {
"<string>:\"PitBull4_LuaTexts:Orctales:Lua:Power\":5: ambiguous syntax (function call x new statement) near '('\nPitBull4-v4.0.0-beta28\\ModuleHandling\\TextProviderModule.lua:118: in function `UpdateFrame'\nPitBull4-v4.0.0-beta28\\ModuleHandling\\TextProviderModule.lua:150: in function `ForceTextUpdate'\nPitBull4_LuaTexts-v4.0.0-beta28\\LuaTexts.lua:1436: in function <Interface\\AddOns\\PitBull4_LuaTexts\\LuaTexts.lua:1432>\nPitBull4_LuaTexts-v4.0.0-beta28\\LuaTexts.lua:1506: in function <Interface\\AddOns\\PitBull4_LuaTexts\\LuaTexts.lua:1502>\n(tail call): ?:\n<in C code>: ?\n<string>:\"safecall Dispatcher[2]\":9: in function <[string \"safecall Dispatcher[2]\"]:5>\n(tail call): ?:\nAceConfigDialog-3.0-54:798: in function <...nfig-3.0\\AceConfigDialog-3.0\\AceConfigDialog-3.0.lua:613>\n(tail call): ?:\n<in C code>: ?\n<string>:\"safecall Dispatcher[3]\":9: in function <[string \"safecall Dispatcher[3]\"]:5>\n(tail call): ?:\nAceGUI-3.0-33 (Ace3):314: in function `Fire'\n...AceGUI-3.0\\widgets\\AceGUIWidg", -- [1]
"et-MultiLineEditBox.lua:44: in function <...AceGUI-3.0\\widgets\\AceGUIWidget-MultiLineEditBox.lua:41>:\n", -- [2]
},
["type"] = "error",
["time"] = "2011/06/21 01:21:16",
["session"] = 4214,
["counter"] = 2,
I hope it makes sense to you, since it's like trying to read martian to me.

I'm not sure if it makes a difference, but PB4 uses another module for alternate power. There is nothing about alternate power in the "Events" drop down menu, but I am unsure if that would have caused a problem since, to my uneducated eyes, it appears to be written in such a way that it doesn't matter if it checks for that and finds it not there.

Anyway, thank you again. I really appreciate your help.

Last edited by jeffy162 : 06-20-11 at 11:59 PM.
  Reply With Quote
06-21-11, 12:18 AM   #4
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
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
06-21-11, 12:53 AM   #5
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,364
Many thanks, Nibelheim!! Both texts are working correctly (as far as I can tell). I'll know more tomorrow when I wake up and can try it on some other power types on different characters. One thing, though: There is no "UNIT_DISPLAYPOWER" in my Events drop down menu. Not that it matters, since it is apparently working.

Here's my PB4 frames (with your text coloring) for my Warlock:
Click image for larger version

Name:	PB4-Orctales.jpg
Views:	475
Size:	31.7 KB
ID:	6273

As you can see, my goal was to make everything gray-scale, except for the health, power and level texts. The "green steps" on the left of the name are from an addon I'm sure you are familiar with: nibPointDisplay. They represent my shards, and I have them set to display as: 1 - red, 2 - 1red 1yellow, 3 - all green.

Again, many thanks. I do appreciate your help, and the fact that you can't even log on to check out your code speaks volumes about your Lua skills.
  Reply With Quote
06-21-11, 01:14 AM   #6
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Another attempt at full Power functionality. May work, may not
Code:
local color
local pType, pToken, altR, altG, altB = UnitPowerType(unit)
local pCur, pMax, pCurMana, pMaxMana = Power(unit), MaxPower(unit), Power(unit, 0), MaxPower(unit, 0)

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
  
  if (pToken ~= "MANA") then
    if (pMaxMana > 0) then
      local DManaColor = PitBull4.PowerColors["MANA"]
      return "|cff%02x%02x%02x%s |cff%02x%02x%02x%s", color[1]*255, color[2]*255, color[3]*255, Short(pCur, true), DManaColor[1]*255, DManaColor[2]*255, DManaColor[3]*255, Short(pCurMana, true)
    end
  else
    return "|cff%02x%02x%02x%s", color[1]*255, color[2]*255, color[3]*255, Short(pCur, true)
  end
end
  Reply With Quote
06-21-11, 12:53 PM   #7
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,364
Yes, thank you. That code also seems to work well.

I haven't gotten a chance to try all of the power types, and probably won't for quite some time. I don't raid, so raid bosses I won't be able to test. I know that there are some other types of alternate power that show up while doing quests, but I have absolutely no idea when I would get to test that, since I don't know what quests it shows up on.

I have tried both codes on my Warlock (Mana), a Hunter (Focus) and a Warrior (Rage), and they both work for those. I'll try them on my Druid and DK later today.

Once again, many thanks. I was (and still am) totally clueless about how to get this to work.
  Reply With Quote
06-21-11, 10:26 PM   #8
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,364
OK. I finally got to play my Druid for a little bit, and the last block of code you posted works for showing Druid Mana, but the second doesn't.

Click image for larger version

Name:	Junathan-PB4 DM.jpg
Views:	468
Size:	28.4 KB
ID:	6280

At least, I'm guessing that's what the second mana bar is for (in cat form). I don't play Druids enough to remember.
  Reply With Quote
06-21-11, 10:55 PM   #9
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Woops, try this:
Code:
local color
local pType, pToken, altR, altG, altB = UnitPowerType(unit)
local pCur, pMax, pCurMana, pMaxMana = Power(unit), MaxPower(unit), Power(unit, 0), MaxPower(unit, 0)

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
  
  if (pToken ~= "MANA") and (pMaxMana > 0) then
      local DManaColor = PitBull4.PowerColors["MANA"]
      return "|cff%02x%02x%02x%s |cff%02x%02x%02x%s", color[1]*255, color[2]*255, color[3]*255, Short(pCur, true), DManaColor[1]*255, DManaColor[2]*255, DManaColor[3]*255, Short(pCurMana, true)
  else
    return "|cff%02x%02x%02x%s", color[1]*255, color[2]*255, color[3]*255, Short(pCur, true)
  end
end
Yep, you should get two power bars, and two power texts. I.e. In cat form, it'll be Energy and Mana.
  Reply With Quote
06-22-11, 08:06 PM   #10
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,364
Originally Posted by Nibelheim View Post
Woops, try this:
Code:
local color
local pType, pToken, altR, altG, altB = UnitPowerType(unit)
local pCur, pMax, pCurMana, pMaxMana = Power(unit), MaxPower(unit), Power(unit, 0), MaxPower(unit, 0)

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
  
  if (pToken ~= "MANA") and (pMaxMana > 0) then
      local DManaColor = PitBull4.PowerColors["MANA"]
      return "|cff%02x%02x%02x%s |cff%02x%02x%02x%s", color[1]*255, color[2]*255, color[3]*255, Short(pCur, true), DManaColor[1]*255, DManaColor[2]*255, DManaColor[3]*255, Short(pCurMana, true)
  else
    return "|cff%02x%02x%02x%s", color[1]*255, color[2]*255, color[3]*255, Short(pCur, true)
  end
end
Yep, you should get two power bars, and two power texts. I.e. In cat form, it'll be Energy and Mana.
OK. Thank you for letting me know (for sure ) what the other bar was. I do have a question, though, if you don't mind. What is the difference between the last block of code and the one posted in post #6? That one seems to work OK, and, as I mentioned, I don't know when I'll get a chance to test the alternate power you get with several other things (for want of a better word).

Please, do not misunderstand. I am not complaining, rather trying to understand the differences between the two codes. Believe me, I appreciate the work you do and all the help you give. Thank you.
  Reply With Quote
06-22-11, 08:43 PM   #11
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Originally Posted by jeffy162 View Post
OK. Thank you for letting me know (for sure ) what the other bar was. I do have a question, though, if you don't mind. What is the difference between the last block of code and the one posted in post #6? That one seems to work OK, and, as I mentioned, I don't know when I'll get a chance to test the alternate power you get with several other things (for want of a better word).

Please, do not misunderstand. I am not complaining, rather trying to understand the differences between the two codes. Believe me, I appreciate the work you do and all the help you give. Thank you.
Hmm, the last code I posted just had a bit of code cleaning done. Same functionality. Though I'm getting a little confused, too much code going on. Does any particular code block (in the latter posts) not work for you?
  Reply With Quote
06-22-11, 09:59 PM   #12
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,364
OK. Just tested the last code, and it gives an error:
["message"] = {
"<string>:\"PitBull4_LuaTexts:Junathan-Quest:Lua:Power\":5: ambiguous syntax (function call x new statement) near '('\nPitBull4-v4.0.0-beta28\\ModuleHandling\\TextProviderModule.lua:118: in function `UpdateFrame'\nPitBull4-v4.0.0-beta28\\ModuleHandling\\TextProviderModule.lua:150: in function `ForceTextUpdate'\nPitBull4_LuaTexts-v4.0.0-beta28\\LuaTexts.lua:1436: in function <Interface\\AddOns\\PitBull4_LuaTexts\\LuaTexts.lua:1432>\nPitBull4_LuaTexts-v4.0.0-beta28\\LuaTexts.lua:1506: in function <Interface\\AddOns\\PitBull4_LuaTexts\\LuaTexts.lua:1502>\n(tail call): ?:\n<in C code>: ?\n<string>:\"safecall Dispatcher[2]\":9: in function <[string \"safecall Dispatcher[2]\"]:5>\n(tail call): ?:\nAceConfigDialog-3.0-54:798: in function <...nfig-3.0\\AceConfigDialog-3.0\\AceConfigDialog-3.0.lua:613>\n(tail call): ?:\n<in C code>: ?\n<string>:\"safecall Dispatcher[3]\":9: in function <[string \"safecall Dispatcher[3]\"]:5>\n(tail call): ?:\nAceGUI-3.0-33 (Ace3):314: in function `Fire'\n...AceGUI-3.0\\widgets\\AceG", -- [1]
"UIWidget-MultiLineEditBox.lua:44: in function <...AceGUI-3.0\\widgets\\AceGUIWidget-MultiLineEditBox.lua:41>:\n", -- [2]
},
["type"] = "error",
["time"] = "2011/06/22 23:41:07",
["session"] = 4234,
["counter"] = 3,
}, -- [4]
{
["message"] = "<string>:\"PitBull4_LuaTexts:Junathan-Quest:Lua:Power\":5: ambiguous syntax (function call x new statement) near '('\nCallbackHandler-1.0-6 (Ace3):147: in function <...Ons\\Ace3\\CallbackHandler-1.0\\CallbackHandler-1.0.lua:147>\n<string>:\"safecall Dispatcher[3]\":4: in function <[string \"safecall Dispatcher[3]\"]:4>\n<in C code>: ?\n<string>:\"safecall Dispatcher[3]\":13: in function `?'\nCallbackHandler-1.0-6 (Ace3):92: in function `Fire'\nAceEvent-3.0-3 (Ace3):120: in function <Interface\\AddOns\\Ace3\\AceEvent-3.0\\AceEvent-3.0.lua:119>\n",
["type"] = "error",
["time"] = "2011/06/22 23:42:30",
["session"] = 4234,
["counter"] = 11,
}, -- [5]
{
["message"] = "<string>:\"PitBull4_LuaTexts:Junathan-Quest:Lua:Power\":5: ambiguous syntax (function call x new statement) near '('\nPitBull4-v4.0.0-beta28\\ModuleHandling\\TextProviderModule.lua:118: in function `UpdateFrame'\nPitBull4-v4.0.0-beta28\\ModuleHandling\\Module.lua:319: in function `Update'\nPitBull4-v4.0.0-beta28\\UnitFrameLayout.lua:1547: in function `UpdateLayout'\nPitBull4-v4.0.0-beta28\\ModuleHandling\\Module.lua:326: in function `Update'\nPitBull4_DruidManaBar-v4.0.0-beta28\\DruidManaBar.lua:86: in function `?'\nCallbackHandler-1.0-6 (Ace3):147: in function <...Ons\\Ace3\\CallbackHandler-1.0\\CallbackHandler-1.0.lua:147>\n<string>:\"safecall Dispatcher[2]\":4: in function <[string \"safecall Dispatcher[2]\"]:4>\n<in C code>: ?\n<string>:\"safecall Dispatcher[2]\":13: in function `?'\nCallbackHandler-1.0-6 (Ace3):92: in function `Fire'\nAceEvent-3.0-3 (Ace3):120: in function <Interface\\AddOns\\Ace3\\AceEvent-3.0\\AceEvent-3.0.lua:119>\n",
["type"] = "error",
["time"] = "2011/06/22 23:42:30",
["session"] = 4234,
["counter"] = 2,
}, -- [6]
{
["message"] = "<string>:\"PitBull4_LuaTexts:Junathan-Quest:Lua:Power\":5: ambiguous syntax (function call x new statement) near '('\nCallbackHandler-1.0-6 (Ace3):147: in function <...Ons\\Ace3\\CallbackHandler-1.0\\CallbackHandler-1.0.lua:147>\n<string>:\"safecall Dispatcher[2]\":4: in function <[string \"safecall Dispatcher[2]\"]:4>\n<in C code>: ?\n<string>:\"safecall Dispatcher[2]\":13: in function `?'\nCallbackHandler-1.0-6 (Ace3):92: in function `Fire'\nAceEvent-3.0-3 (Ace3):120: in function <Interface\\AddOns\\Ace3\\AceEvent-3.0\\AceEvent-3.0.lua:119>\n",
["type"] = "error",
["time"] = "2011/06/22 23:42:30",
["session"] = 4234,
["counter"] = 2,
}, -- [7]
},
["save"] = true,
["session"] = 4234,
The code from post #6 works perfectly for Druid Mana, and I also put it on a character that doesn't use mana, but a different power (I think it was a Warrior, so Rage) and it worked fine.

Last edited by jeffy162 : 06-22-11 at 10:06 PM.
  Reply With Quote
06-22-11, 10:18 PM   #13
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Originally Posted by jeffy162 View Post
OK. Just tested the last code, and it gives an error:


The code from post #6 works perfectly for Druid Mana, and I also put it on a character that doesn't use mana, but a different power (I think it was a Warrior, so Rage) and it worked fine.
Oh well, at least one of them worked
  Reply With Quote
06-23-11, 07:46 AM   #14
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,364
Originally Posted by Nibelheim View Post
Oh well, at least one of them worked
Yes it does! Thank you very much! Your work is much appreciated.
  Reply With Quote
07-09-11, 07:39 PM   #15
Necrophgst
A Deviate Faerie Dragon
 
Necrophgst's Avatar
Join Date: Apr 2008
Posts: 17
Gosh that's all kinds of confusing... Let try it using Luatext's... I believe you'll find this runs just a tad bit faster.

Try this for HPColor:
Code:
local curHP, maxHP = HPUnit(unit), MaxHP(unit)
local hpR, hpG, hpB = HPColor(curHP, maxHP)
local hpDif = maxHP - curHP
return "|cff%02x%02x%02x%s", hpR, hpG, hpB, Short(hpDif, true)
Try this power color...
Code:
local powType, maxPow, curPow = UnitPowerType(unit), MaxPower(unit), Power(unit)
local powR, powG, powB = PowerColor(powType)
local powDif = maxPow - curPow
return "|cff%02x%02x%02x%s", powR, powG, powB, Short(powDif, true)
__________________
The beat goes, Boom Badda Bing

Last edited by Necrophgst : 07-09-11 at 07:44 PM.
  Reply With Quote
07-13-11, 10:55 AM   #16
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,364
Nope. Health gives an error (it just says "table" in Bugsack). Power just puts my power, which on my Warlock is 2902 Mana, at a greyed-out 0 (zero).
__________________
Ahhhh, the vagueries of the aging mind. Wait.... What was I saying?


Carbonite <----- GitHub main module (Maps ONLY) download link. The other modules are also available on GitHub.
Carbonite-CLASSIC<----- GitHub link to Carbonite Classic. Thanks to ircdirk for this!
  Reply With Quote
03-08-16, 05:59 PM   #17
slayos
A Deviate Faerie Dragon
 
slayos's Avatar
Join Date: May 2015
Posts: 15
Diffrent text!

[quote=Nibelheim;239706]Some examples:

Power (supports Druid Mana and Alt Power types)
Code:
local color
local pType, pToken, altR, altG, altB = UnitPowerType(unit)
local pCur, pMax, pCurMana, pMaxMana = Power(unit), MaxPower(unit), Power(unit, 0), MaxPower(unit, 0)

if (pMax > 0) then
  if PitBull4.PowerColors[pToken] then
    color = PitBull4.PowerColors[pToken]
  else
    if (not altR) then
      color = PitBull4.PowerColors["MANA"]
    else
      color = {[1] = altR, [2] = altG, [3] = altB}
    end
  end
  
  if (pToken ~= "MANA") then
    if (pMaxMana > 0) then
      local DManaColor = PitBull4.PowerColors["MANA"]
      return "|cff%02x%02x%02x%s |cff%02x%02x%02x%s", color[1]*255, color[2]*255, color[3]*255, Short(pCur, true), DManaColor[1]*255, DManaColor[2]*255, DManaColor[3]*255, Short(pCurMana, true)
    end
  else
    return "|cff%02x%02x%02x%s", color[1]*255, color[2]*255, color[3]*255, Short(pCur, true)
  end
end

Is it possible to make this code show as "current insted of short" f.ex show mana aka power as 32000 insted of 32.0k ?

Last edited by slayos : 03-08-16 at 06:03 PM.
  Reply With Quote
03-09-16, 11:02 AM   #18
sirann
A Flamescale Wyrmkin
Join Date: Mar 2007
Posts: 142
I think swapping the two instances of "Short(pCur, true)" with "pCur" no quotes, and the one instance of "Short(pCurMana, true)" with "pCurMana" no quotes should work
  Reply With Quote
03-10-16, 11:41 AM   #19
slayos
A Deviate Faerie Dragon
 
slayos's Avatar
Join Date: May 2015
Posts: 15
Originally Posted by sirann View Post
I think swapping the two instances of "Short(pCur, true)" with "pCur" no quotes, and the one instance of "Short(pCurMana, true)" with "pCurMana" no quotes should work
it worked! thank you, i have an otther issue aswell if you'd like to help me out? here it goes!
local s = Status(unit)
if s then
return s
end
local s = Status(unit)
if s then
return s
end
local cur, max = HP(unit), MaxHP(unit)
if UnitIsFriend(unit,"player") then
local perc = Percent(cur,max)
if perc >= 76 then
return "|cff00d036%s%%|r", perc
elseif perc >= 26 then
return "|cfff19c08%s%%|r",perc
else
return "|cfff10808%s%%|r",perc
end
else
return "%s/%s",Short(cur,true),Short(max,true)
end
This code is displaying player health names like this "100%" with some nice coloring from green -> orange -> red depending on your health, but I want it to look like this "418500" with the coloring ofc., also displays bosses like this "17.2k/17.2k" with no coloring but that's fine, but whatt I want is it to display bosses like this "17200 | 100%", I really do appreciate in advance!

Last edited by slayos : 03-10-16 at 12:09 PM.
  Reply With Quote
03-10-16, 12:10 PM   #20
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
local perc = Percent(cur,max)

Would appear to be converting current health into a percentage of max so if you just change perc to cur as the return by:
Code:
	if perc >= 76 then
		return "|cff00d036%s%%|r", cur
	elseif perc >= 26 then
		return "|cfff19c08%s%%|r",cur
	else
		return "|cfff10808%s%%|r",cur
	end
You also have duplicate
Code:
local s = Status(unit)
if s then
    return s
end
Statements.

For the boss (this will change the display for any unfriendly target) you woulld need to substitute
Code:
else
	return "%s/%s",Short(cur,true),Short(max,true)
for
Code:
else
	return Percent(cur,max)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 03-10-16 at 12:16 PM.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » PitBull4 Lua texts - Colored health and power?

Thread Tools
Display Modes

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