WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   PitBull4 Lua texts - Colored health and power? (https://www.wowinterface.com/forums/showthread.php?t=40547)

jeffy162 06-20-11 10:51 PM

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.

Nibelheim 06-20-11 11:03 PM

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)


jeffy162 06-20-11 11:55 PM

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:

Quote:

["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.

Nibelheim 06-21-11 12:18 AM

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

jeffy162 06-21-11 12:53 AM

1 Attachment(s)
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:
Attachment 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.

Nibelheim 06-21-11 01:14 AM

Another attempt at full Power functionality. May work, may not :p
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


jeffy162 06-21-11 12:53 PM

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.

jeffy162 06-21-11 10:26 PM

1 Attachment(s)
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.

Attachment 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.:o

Nibelheim 06-21-11 10:55 PM

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.

jeffy162 06-22-11 08:06 PM

Quote:

Originally Posted by Nibelheim (Post 239753)
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.

Nibelheim 06-22-11 08:43 PM

Quote:

Originally Posted by jeffy162 (Post 239799)
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. :p Does any particular code block (in the latter posts) not work for you?

jeffy162 06-22-11 09:59 PM

OK. Just tested the last code, and it gives an error:
Quote:

["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.

Nibelheim 06-22-11 10:18 PM

Quote:

Originally Posted by jeffy162 (Post 239802)
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 ;)

jeffy162 06-23-11 07:46 AM

Quote:

Originally Posted by Nibelheim (Post 239804)
Oh well, at least one of them worked ;)

Yes it does! Thank you very much! Your work is much appreciated.

Necrophgst 07-09-11 07:39 PM

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)


jeffy162 07-13-11 10:55 AM

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).

slayos 03-08-16 05:59 PM

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 ?

sirann 03-09-16 11:02 AM

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

slayos 03-10-16 11:41 AM

Quote:

Originally Posted by sirann (Post 313497)
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!
Quote:

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!

Fizzlemizz 03-10-16 12:10 PM

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)


slayos 03-10-16 12:16 PM

Quote:

Originally Posted by Fizzlemizz (Post 313527)
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 you woulld need to substitute the function it's using to convert the values and replace it with Percent as in your code above.

Could you possible give me my code back fixed the way that you'd do it? I'm not really that good at coding.

Fizzlemizz 03-10-16 12:18 PM

Code:

local s = Status(unit)
if s then
        return s
end
local cur, max = HP(unit), MaxHP(unit)
local perc = Percent(cur,max)
if UnitIsFriend(unit,"player") then
        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
else
        return perc
end


slayos 03-10-16 12:23 PM

Quote:

Originally Posted by Fizzlemizz (Post 313529)
Code:

local s = Status(unit)
if s then
        return s
end
local cur, max = HP(unit), MaxHP(unit)
local perc = Percent(cur,max)
if UnitIsFriend(unit,"player") then
        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
else
        return perc
end


an issue has accured, on target "friendly" it shows their name exactly as i want it however with a % behind it, so let's say i got 418500 health it displays like this 418500% and on unfriendly target it displays like i want ut however 100 instred of 100%

Fizzlemizz 03-10-16 12:37 PM

Apologies, too early in the morning ;).

Code:

local s = Status(unit)
if s then
        return s
end
local cur, max = HP(unit), MaxHP(unit)
local perc = Percent(cur,max)
if UnitIsFriend(unit,"player") then
        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
else
        return "%s%%",perc
end


slayos 03-10-16 12:39 PM

Quote:

Originally Posted by Fizzlemizz (Post 313531)
Apologies, too early in the morning ;).

Code:

local s = Status(unit)
if s then
        return s
end
local cur, max = HP(unit), MaxHP(unit)
local perc = Percent(cur,max)
if UnitIsFriend(unit,"player") then
        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
else
        return "%s%%",perc
end


NICE! you have no idea how long i've been working on getting this fixed!!!, if it's not to much to ask since you're so good at this xD is it possible to make the unfriendly text colored like the friendly one to? i am a perfectionist xD

Fizzlemizz 03-10-16 12:44 PM

Something like:

Code:

local s = Status(unit)
if s then
        return s
end
local cur, max = HP(unit), MaxHP(unit)
local perc = Percent(cur,max)
local ret
if perc >= 76 then
        ret = "|cff00d036%s"
elseif perc >= 26 then
        ret = "|cfff19c08%s"
else
        ret = "|cfff10808%s"
end
if UnitIsFriend(unit,"player") then
        ret = ret.."|r"
        return ret,cur
else
        ret = ret.."%%"|r"
        return ret,perc
end


slayos 03-10-16 12:46 PM

Quote:

Originally Posted by Fizzlemizz (Post 313533)
Something like:

Code:

local s = Status(unit)
if s then
        return s
end
local cur, max = HP(unit), MaxHP(unit)
local perc = Percent(cur,max)
local ret
if perc >= 76 then
        ret = "|cff00d036%s"
elseif perc >= 26 then
        ret = "|cfff19c08%s"
else
        ret = "|cfff10808%s"
end
if UnitIsFriend(unit,"player") then
        ret = ret.."|r"
        return ret,cur
else
        ret = ret.."%%"|r"
        return ret,perc
end


Doesn't work :P

Fizzlemizz 03-10-16 12:50 PM

Way too early ..

Code:

local s = Status(unit)
if s then
        return s
end
local cur, max = HP(unit), MaxHP(unit)
local perc = Percent(cur,max)
local ret
if perc >= 76 then
        ret = "|cff00d036%s"
elseif perc >= 26 then
        ret = "|cfff19c08%s"
else
        ret = "|cfff10808%s"
end
if UnitIsFriend(unit,"player") then
        ret = ret.."|r"
        return ret,cur
else
        ret = ret.."%%|r"
        return ret,perc
end


slayos 03-10-16 12:53 PM

Quote:

Originally Posted by Fizzlemizz (Post 313535)
Way too early ..

Code:

local s = Status(unit)
if s then
        return s
end
local cur, max = HP(unit), MaxHP(unit)
local perc = Percent(cur,max)
local ret
if perc >= 76 then
        ret = "|cff00d036%s"
elseif perc >= 26 then
        ret = "|cfff19c08%s"
else
        ret = "|cfff10808%s"
end
if UnitIsFriend(unit,"player") then
        ret = ret.."|r"
        return ret,cur
else
        ret = ret.."%%|r"
        return ret,perc
end


worked xD thank you, i wish i was as good in coding, would've made this so much easyer lol xD

want to do 1 last before i got my whole ui complete? this one shouldn't be complicated :)
Quote:

local _,power_name = UnitPowerType(unit)
local r,g,b = PowerColor(power_name)
local max = MaxPower(unit)
if max > 0 then
return "|cff%02x%02x%02x%s | %s",r,g,b,Short(Power(unit),true),Short(max,true)
end
this code is showing the text code like this "32.0k | 32.0k" but I want it to display it like this "32000"

Fizzlemizz 03-10-16 01:09 PM

local _,power_name = UnitPowerType(unit)
local r,g,b = PowerColor(power_name)
local max = MaxPower(unit)
if max > 0 then
return "|cff%02x%02x%02x%s|r",r,g,b,Power(unit)
end

slayos 03-10-16 01:13 PM

Quote:

Originally Posted by Fizzlemizz (Post 313537)
local _,power_name = UnitPowerType(unit)
local r,g,b = PowerColor(power_name)
local max = MaxPower(unit)
if max > 0 then
return "|cff%02x%02x%02x%s|r",r,g,b,Power(unit)
end

i think that's it ;O thank you so much for the assistance m8, if i can do anything for you!

ceylina 03-11-16 12:30 PM

Not sure if you want it at all but here is my coding for health and power bars

I only color the health or power percentage and not the current/max health amount.

Health:

Code:

local cur, max = HP(unit), MaxHP(unit)
local r,g,b = HPColor(cur,max)
return "%s/%s |cff%02x%02x%02x(%s%%)|r",Short(cur,true),Short(max,true),r,g,b,Percent(cur,max)


Power:

Code:

local cur,max = Power(unit),MaxPower(unit)
local _,power_name = UnitPowerType(unit)
local r,g,b = PowerColor(power_name)
  return "%s/%s |cff%02x%02x%02x(%s%%)|r",Short(cur,true),Short(max,true),r,g,b,Percent(cur,max)


Druid mana

Code:

if UnitPowerType(unit) ~= 0 and DruidForm(unit) then
  local max = MaxPower(unit,0)
  local color = PitBull4.PowerColors["MANA"]
  local r,g,b = color[1]*255, color[2]*255, color[3]*255
    return "|cff%02x%02x%02x(%s%%)|r",r,g,b,Percent(Power(unit,0),max)
end


slayos 03-15-16 09:04 PM

Druid Mana
 
how can i get this code
Quote:

if UnitPowerType(unit) ~= 0 and DruidForm(unit) then
local max = MaxPower(unit,0)
local color = PitBull4.PowerColors["MANA"]
local r,g,b = color[1]*255, color[2]*255, color[3]*255
return "|cff%02x%02x%02x(%s%%)|r",r,g,b,Percent(Power(unit,0),max)
end
to show Cur insted of Percent?

like so "32000" if that's whatt my mana is? :)

Thanks in advanse

Fizzlemizz 03-15-16 09:08 PM

Code:

if UnitPowerType(unit) ~= 0 and DruidForm(unit) then
        local color = PitBull4.PowerColors["MANA"]
        local r,g,b = color[1]*255, color[2]*255, color[3]*255
        return "|cff%02x%02x%02x(%s)|r",r,g,b,Power(unit,0)
end


slayos 03-15-16 09:11 PM

Thanks
 
Quote:

Originally Posted by Fizzlemizz (Post 313623)
Code:

if UnitPowerType(unit) ~= 0 and DruidForm(unit) then
        local color = PitBull4.PowerColors["MANA"]
        local r,g,b = color[1]*255, color[2]*255, color[3]*255
        return "|cff%02x%02x%02x(%s)|r",r,g,b,Power(unit,0)
end


heh it's you again, seems like my UI just refuse to be done, there seem to duck up problems, after problems are solved heh ^ glad i got you to back me up though!

slayos 03-15-16 09:30 PM

You don't happen to know a code that displays the spec of the player?

let's say i meet a "Holy Paladin" i got a own code that says f.ex "Holy" with class colored text or eventually show a img of the spec? pref the img is possible but text is more than fine!

Fizzlemizz 03-16-16 09:59 AM

I don't know Pitbull well enough to tell you exactly how but the process of getting a specialisation comes in two parts.

First determine if the target can be inspected and if so send an inspect request to the server.
Code:

if CanInspect("target") then
        frame:RegisterEvent("INSPECT_READY")
        NotifyInspect("target")
else
        print("Can't inspect target")
end

Once the server has gathered the information it will send an "INSPECT_READY" event to the designated frame(s) which can then retrieve the information.

Frames OnEvent script for the "INSPECT_READY" event:
Code:

local spec_id = GetInspectSpecialization("target")
self:UnregisterEvent("INSPECT_READY")
ClearInspectPlayer()
local id, name, description, icon, background, role, class = GetSpecializationInfoByID(spec_id)
print(name) -- or set a texture to display the icon


slayos 03-16-16 10:18 AM

How do i perform this action?


All times are GMT -6. The time now is 09:34 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI