mirror of
https://repo.or.cz/minetest_hudbars.git
synced 2024-08-20 05:04:12 +02:00
Do not register health/breath bar if damage is off
This commit is contained in:
parent
eb4e72c5a4
commit
ea9a303e48
31
init.lua
31
init.lua
@ -229,9 +229,10 @@ function hb.get_hudbar_state(player, identifier)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--register built-in HUD bars
|
--register built-in HUD bars
|
||||||
hb.register_hudbar("health", 0xFFFFFF, "Health", { bar = "hudbars_bar_health.png", icon = "hudbars_icon_health.png" }, 20, 20, false)
|
if minetest.setting_getbool("enable_damage") then
|
||||||
hb.register_hudbar("breath", 0xFFFFFF, "Breath", { bar = "hudbars_bar_breath.png", icon = "hudbars_icon_breath.png" }, 10, 10, true)
|
hb.register_hudbar("health", 0xFFFFFF, "Health", { bar = "hudbars_bar_health.png", icon = "hudbars_icon_health.png" }, 20, 20, false)
|
||||||
|
hb.register_hudbar("breath", 0xFFFFFF, "Breath", { bar = "hudbars_bar_breath.png", icon = "hudbars_icon_breath.png" }, 10, 10, true)
|
||||||
|
end
|
||||||
|
|
||||||
--load custom settings
|
--load custom settings
|
||||||
local set = io.open(minetest.get_modpath("hudbars").."/hudbars.conf", "r")
|
local set = io.open(minetest.get_modpath("hudbars").."/hudbars.conf", "r")
|
||||||
@ -255,18 +256,20 @@ end
|
|||||||
|
|
||||||
-- update built-in HUD bars
|
-- update built-in HUD bars
|
||||||
local function update_hud(player)
|
local function update_hud(player)
|
||||||
--air
|
if minetest.setting_getbool("enable_damage") then
|
||||||
local air = player:get_breath()
|
--air
|
||||||
|
local air = player:get_breath()
|
||||||
if air == 11 then
|
|
||||||
hb.hide_hudbar(player, "breath")
|
if air == 11 then
|
||||||
else
|
hb.hide_hudbar(player, "breath")
|
||||||
hb.unhide_hudbar(player, "breath")
|
else
|
||||||
hb.change_hudbar(player, "breath", air)
|
hb.unhide_hudbar(player, "breath")
|
||||||
|
hb.change_hudbar(player, "breath", air)
|
||||||
|
end
|
||||||
|
|
||||||
|
--health
|
||||||
|
hb.change_hudbar(player, "health", player:get_hp())
|
||||||
end
|
end
|
||||||
|
|
||||||
--health
|
|
||||||
hb.change_hudbar(player, "health", player:get_hp())
|
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
|
Loading…
Reference in New Issue
Block a user