Hello,
I am trying to combine these two functions. I would like the player frame to follow the first function, which has the health displayed as a percent value. I would like the target frame to follow the second function, which has the health displayed as current health + percent value.
How can these be combined so Player Frame receives the "percent function" and Target/Focus Frames receive the "current health + percent function"? If someone coule help right it and rename the new format if (GhettoFramesSaveX.hformat==2) This is because the only way I know how to change format is thru the config menu provided by the author's original work.
The lua code has been pulled from the addon Ghetto Frames.
If Framelist = {"Target", "Focus", "Player"} could be separated so Function A effects "Target/Focus" and Function B effects "Player"
Percent Function Code:
if (GhettoFramesSaveX.hformat==1) then--percent
FrameList = {"Target", "Focus", "Player"}
function UpdateHealthValues(...)
for i = 1, select("#", unpack(FrameList)) do
local FrameName = (select(i, unpack(FrameList)))
if (0 < UnitHealth(FrameName)) then
local Health = UnitHealth(FrameName)
local HealthMax = UnitHealthMax(FrameName)
local HealthPercent = (UnitHealth(FrameName)/UnitHealthMax(FrameName))*100
_G[FrameName.."FrameHealthBar"].TextString:SetText(format("%.0f",HealthPercent).."%")
end
end
end
hooksecurefunc("TextStatusBar_UpdateTextStringWithValues", UpdateHealthValues)
end
Current Health + Percent Function Code:
if (GhettoFramesSaveX.hformat==3) then --currenthealth + percent
FrameList = {"Target", "Focus", "Player"}
function UpdateHealthValues(...)
for i = 1, select("#", unpack(FrameList)) do
local FrameName = (select(i, unpack(FrameList)))
if (0 < UnitHealth(FrameName)) then
if UnitHealth(FrameName) < 1000 then
local Health = UnitHealth(FrameName)
local HealthMax = UnitHealthMax(FrameName)
local HealthPercent = (UnitHealth(FrameName)/UnitHealthMax(FrameName))*100
_G[FrameName.."FrameHealthBar"].TextString:SetText(Health.." ("..format("%.0f",HealthPercent).."%)")
elseif (UnitHealth(FrameName) < 1000000) then
local Health = (UnitHealth(FrameName))/1000
local HealthMax = (UnitHealthMax(FrameName))/1000
local HealthPercent = (UnitHealth(FrameName)/UnitHealthMax(FrameName))*100
_G[FrameName.."FrameHealthBar"].TextString:SetText(format("%.0f",Health).."k ("..format("%.0f",HealthPercent).."%)")
elseif (1000000<=UnitHealth(FrameName)) then
local Health = (UnitHealth(FrameName))/1000000
local HealthMax = (UnitHealthMax(FrameName))/1000000
local HealthPercent = (UnitHealth(FrameName)/UnitHealthMax(FrameName))*100
_G[FrameName.."FrameHealthBar"].TextString:SetText(format("%.0f",Health).."m ("..format("%.0f",HealthPercent).."%)")
end
end
end
end
hooksecurefunc("TextStatusBar_UpdateTextStringWithValues", UpdateHealthValues)
end