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() Code:
Outline() Code:
Outline() Code:
Outline() |
Some examples:
Power (supports Druid Mana and Alt Power types) Code:
local color Health (green to red) Code:
local cur, max = HP(unit), MaxHP(unit) |
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:
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. |
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 UNIT_POWER UNIT_DISPLAYPOWER |
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. |
Another attempt at full Power functionality. May work, may not :p
Code:
local color |
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. |
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 |
Woops, try this:
Code:
local color |
Quote:
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. |
Quote:
|
OK. Just tested the last code, and it gives an error:
Quote:
|
Quote:
|
Quote:
|
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) Code:
local powType, maxPow, curPow = UnitPowerType(unit), MaxPower(unit), Power(unit) |
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).
|
Diffrent text!
[quote=Nibelheim;239706]Some examples:
Power (supports Druid Mana and Alt Power types) Code:
local color 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 ? |
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
|
Quote:
Quote:
|
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 Code:
local s = Status(unit) For the boss (this will change the display for any unfriendly target) you woulld need to substitute Code:
else Code:
else |
All times are GMT -6. The time now is 05:49 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI