Thread Tools Display Modes
Prev Previous Post   Next Post Next
05-24-18, 06:23 PM   #1
Xancepants
A Deviate Faerie Dragon
Join Date: Oct 2014
Posts: 17
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
  Reply With Quote
 

WoWInterface » Developer Discussions » General Authoring Discussion » Personal Resource Bar: HP Color by % missing?


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