This site makes extensive use of JavaScript.
Please enable JavaScript in your browser.
Live
PTR
10.2.7
PTR
10.2.6
Beta
"Rotten apple % health" so to speak
Post Reply
Return to board index
Post by
164227
This post was from a user who has deleted their account.
Post by
GTMistral
Can you work with hexadecimal value? Otherwise, use string value.
What is the error please? That would help debugging your code.
What is function
Short(...)
?
What is this?
color = 0x10FF30 + floor((1-pct)*235)*131072
. I assume you try to determine the color of the bar according to the current health. It works with 95%, 63%, but not with 5%. It gives a 7 digits-long hexadecimal number. This is also assuming you directly work with hexa values in LUA and also work with mixed hexa and decimal values. 0x10FF30 + 29229056 = 0x10FF30 + 0x1BE0000.
A short of "max-cur" and a boolean value? I don't know if you're trying to shorten something here.
In your return value, what is
%x
and
%s
? Where do you initialize those two?
Post by
164227
This post was from a user who has deleted their account.
Post by
GTMistral
Ok, so you want to progressively switch from green to yellow to orange and then to red as life goes down? Or just directly switch color as you go down the scale? Second option is much easier!
local currhp,maxhp = UnitHealth(unit),UnitHealthMax(unit);
pct = currhp/maxhp;
if (pct >= 0.75) then
return format("|cFF00FF00%.2f%%|r",pct*100); -- opaque green
elseif (pct < 0.75 and pct >= 0.50) then
return format("|cFFFFFF00%.2f%%|r",pct*100); -- opaque yellow
elseif (pct < 0.50 and pct >= 0.25) then
return format("|cFFFF7F00%.2f%%|r",pct*100); -- opaque orange
else
return format("|cFFFF0000%.2f%%|r",pct*100); -- opaque red
end
Post by
164227
This post was from a user who has deleted their account.
Post by
GTMistral
It will return something like "63.86%" and colored. If you want real value instead, just replace
pct*100
with
currhp
or whatever value you wish to have in there.
In formatted string,
%.2f
output number with floating number. In this case, 2. It's rounded according to the third floating number (which is not shown).
%%
output a single %.
Post by
164227
This post was from a user who has deleted their account.
Post Reply
You are not logged in. Please
log in
to post a reply or
register
if you don't already have an account.