mirror of
https://github.com/minetest-mods/gauges.git
synced 2025-07-27 04:20:18 +02:00
Compare commits
10 Commits
master
...
0341fe1ef9
Author | SHA1 | Date | |
---|---|---|---|
0341fe1ef9 | |||
b6cfb91717 | |||
b7051168f1 | |||
3b2552d655 | |||
cdbbff71de | |||
1d6848bc9c | |||
5e76ccfa78 | |||
e1cae85e42 | |||
e1534c2139 | |||
d5f2404ddd |
8
init.lua
8
init.lua
@ -3,6 +3,10 @@
|
||||
-- Copyright © 2014-2020 4aiman, Hugo Locurcio and contributors - MIT License
|
||||
-- See `LICENSE.md` included in the source distribution for details.
|
||||
|
||||
local function round(v)
|
||||
return math.floor(v + 0.5)
|
||||
end
|
||||
|
||||
local enabled = minetest.settings:get_bool("health_bars") ~= false
|
||||
if enabled then
|
||||
enabled = minetest.settings:get_bool("enable_damage")
|
||||
@ -36,7 +40,7 @@ local function scaleToDefault(player, field)
|
||||
-- Scale "hp" or "breath" to supported amount
|
||||
local current = player["get_" .. field](player)
|
||||
local max_display = math.max(player:get_properties()[field .. "_max"], current)
|
||||
return math.round(current / max_display * max[field])
|
||||
return round(current / max_display * max[field])
|
||||
end
|
||||
|
||||
minetest.register_entity("gauges:hp_bar", {
|
||||
@ -90,3 +94,5 @@ if enabled then
|
||||
minetest.after(1, add_gauge, player)
|
||||
end)
|
||||
end
|
||||
|
||||
minetest.log("action", "[gauges] loaded.")
|
||||
|
Reference in New Issue
Block a user