Personal Resource Bar: HP Color by % missing?
Hello all, I'm aware of a few addons that can achieve what I am looking for, such as KuiNamePlates, but I was wondering if any programming language guru(s) out there might know how to make a Macro / Script, or some LUA Code to make the Health on your Personal Resource Bar change color, based on % Value of missing HP? (That's the HP/MANA bar that appears directly below your character). For example:
100% = Green 75% = Green/Yellow 50% = Yellow 25% = Orange >25% = Red I found a similar script that does the same thing, but it's for Player Frame and Target Frame. Here is the code if it helps to give anybody an idea or starting point. --[Color HP Bars Green at Full & Red at Low Health] hooksecurefunc("HealthBar_OnValueChanged",function(self,value) local min,max = self:GetMinMaxValues() if not value or value<min or value>max then return end -- change value to a percentage value = (max-min)>0 and (value-min)/(max-min) or 0 -- recolor based on percentage if value>0.5 then self:SetStatusBarColor((1-value)*2,1,0) else self:SetStatusBarColor(1,value*2,0) end end) Not sure if this is the correct place for this question and I apologize if it's not, but it seemed like the closest match! Any Help is greatly appreciated, and thank you in advance :) |
That should do it, up to you to check more thoroughly to see if using SetStatusBarColor on nameplates doesn't taint anything in a bad way though (and to check whether it doesn't leave random other nameplates colored wrong, but it shouldn't.)
lua Code:
Hacky, but eh. Not like that other script was any better. :p |
:banana::banana::banana:
<3 <3 <3 <3 <3 <3 <3 <3 Works Flawlessly! Thank you very much for the help and quick reply! :) Ya know... people should start offering to pay for having things custom scripted/coded for them in the form of WoW Game Time Tokens. Is that possible? If so... does that violate forum rules in some way? |
Tipping doesn't break this forum's rules on its own, but WoW token would imply in-game gold, and that would be breaking Blizzard rules if you were giving that in exchange for out-of-game services (which addon development falls under.)
Gifting directly from the battle.net shop (or gifting battle.net balance directly) would be the way to go for what you are suggesting. Still, I don't think this should be the norm whenever someone asks for help on this forum. There's nothing wrong with it but there's nothing wrong with just nicely asking for help either. |
All times are GMT -6. The time now is 03:08 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI