Calculation precision change
Scott King [01-16-14 - 04:19]
Calculation precision change
diff --git a/PortraitHealth.lua b/PortraitHealth.lua
index 77b16c6..cebb9b1 100755
--- a/PortraitHealth.lua
+++ b/PortraitHealth.lua
@@ -31,7 +31,7 @@ end
function HealthPercentage()
-- Health value to display. Whole numbers only.
- TargetPercentHealth = math.ceil((UnitHealth("target") / UnitHealthMax("target") * 100));
+ TargetPercentHealth = (UnitHealth("target") / UnitHealthMax("target") * 100);
-- Class detection
@@ -69,12 +69,14 @@ function HealthPercentage()
PortraitHealth_Health:SetTextColor(1,1,0);
end
+ -- reformat health without decimals
+ local h = string.format("%0f",TargetPercentHealth);
-- change the portrait to show current health
if UnitIsDead("target") then
PortraitHealth_Health:SetText('Dead');
else
- PortraitHealth_Health:SetText(TargetPercentHealth .. '%');
+ PortraitHealth_Health:SetText(h .. '%');
end
end