mirror of
https://repo.or.cz/minetest_hudbars.git
synced 2024-08-20 05:04:12 +02:00
Event-based health bar change
This commit is contained in:
parent
3c182884dc
commit
5c0f165ddf
13
init.lua
13
init.lua
@ -493,6 +493,9 @@ local function custom_hud(player)
|
||||
end
|
||||
end
|
||||
|
||||
local function update_health(player)
|
||||
hb.change_hudbar(player, "health", player:get_hp())
|
||||
end
|
||||
|
||||
-- update built-in HUD bars
|
||||
local function update_hud(player)
|
||||
@ -510,15 +513,21 @@ local function update_hud(player)
|
||||
hb.unhide_hudbar(player, "breath")
|
||||
hb.change_hudbar(player, "breath", math.min(breath, 10))
|
||||
end
|
||||
|
||||
--health
|
||||
hb.change_hudbar(player, "health", player:get_hp())
|
||||
update_health(player)
|
||||
elseif hb.settings.forceload_default_hudbars then
|
||||
hb.hide_hudbar(player, "health")
|
||||
hb.hide_hudbar(player, "breath")
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_on_player_hpchange(update_health)
|
||||
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
update_health(player)
|
||||
hb.hide_hudbar(player, "breath")
|
||||
end)
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
hide_builtin(player)
|
||||
custom_hud(player)
|
||||
|
Loading…
Reference in New Issue
Block a user