mirror of
https://repo.or.cz/minetest_hudbars.git
synced 2024-11-28 01:53:46 +01:00
Bar length is now rounded towards nearest integer
This commit is contained in:
parent
390c24c193
commit
fb2cf988de
10
init.lua
10
init.lua
@ -81,9 +81,15 @@ function hb.value_to_barlength(value, max)
|
||||
return 0
|
||||
else
|
||||
if hb.settings.bar_type == "progress_bar" then
|
||||
return math.ceil((value/max) * hb.settings.max_bar_length)
|
||||
local x
|
||||
if value < 0 then x=-0.5 else x = 0.5 end
|
||||
local ret = math.modf((value/max) * hb.settings.max_bar_length + x)
|
||||
return ret
|
||||
else
|
||||
return math.ceil((value/max) * 20)
|
||||
local x
|
||||
if value < 0 then x=-0.5 else x = 0.5 end
|
||||
local ret = math.modf((value/max) * 20 + x)
|
||||
return ret
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user