mirror of
https://github.com/parnic/ice-hud.git
synced 2025-06-16 06:40:13 -05:00
Added rounding for MobHealth3 numbers
This commit is contained in:
@ -100,8 +100,12 @@ function TargetHealth.prototype:Update(unit)
|
||||
|
||||
if (self.moduleSettings.mobhealth and MobHealth3) then
|
||||
self.health, self.maxHealth, _ = MobHealth3:GetUnitHealth(self.unit, self.health, self.maxHealth)
|
||||
|
||||
self.health = self:Round(self.health)
|
||||
self.maxHealth = self:Round(self.maxHealth)
|
||||
end
|
||||
|
||||
|
||||
-- assumption that if a unit's max health is 100, it's not actual amount
|
||||
-- but rather a percentage - this obviously has one caveat though
|
||||
|
||||
@ -113,6 +117,21 @@ function TargetHealth.prototype:Update(unit)
|
||||
end
|
||||
|
||||
|
||||
function TargetHealth.prototype:Round(health)
|
||||
if (health > 1000000) then
|
||||
return self:MathRound(health/100000, 1) .. "M"
|
||||
end
|
||||
if (health > 1000) then
|
||||
return self:MathRound(health/1000, 1) .. "k"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function TargetHealth.prototype:MathRound(num, idp)
|
||||
local mult = 10^(idp or 0)
|
||||
return math.floor(num * mult + 0.5) / mult
|
||||
end
|
||||
|
||||
|
||||
-- Load us up
|
||||
TargetHealth:new()
|
||||
|
Reference in New Issue
Block a user