From a3fede159bc48de59dd07b06d3a4e8bcca0d5740 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 30 Mar 2019 13:44:48 +0100 Subject: [PATCH] Support custom hp_max/breath_max --- init.lua | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/init.lua b/init.lua index eba3747..bf96da6 100644 --- a/init.lua +++ b/init.lua @@ -444,16 +444,20 @@ local function custom_hud(player) else hide = true end - hb.init_hudbar(player, "health", player:get_hp(), nil, hide) + local hp = player:get_hp() + local hp_max = player:get_properties().hp_max + hb.init_hudbar(player, "health", math.min(hp, hp_max), hp_max, hide) local breath = player:get_breath() + local breath_max = player:get_properties().breath_max local hide_breath - if breath == 11 and hb.settings.autohide_breath == true then hide_breath = true else hide_breath = false end - hb.init_hudbar(player, "breath", math.min(breath, 10), nil, hide_breath or hide) + if breath >= breath_max and hb.settings.autohide_breath == true then hide_breath = true else hide_breath = false end + hb.init_hudbar(player, "breath", math.min(breath, breath_max-1), breath_max-1, hide_breath or hide) end end local function update_health(player) - hb.change_hudbar(player, "health", player:get_hp()) + local hp_max = player:get_properties().hp_max + hb.change_hudbar(player, "health", player:get_hp(), hp_max) end -- update built-in HUD bars @@ -464,13 +468,14 @@ local function update_hud(player) hb.unhide_hudbar(player, "health") end --air + local breath_max = player:get_properties().breath_max local breath = player:get_breath() - if breath == 11 and hb.settings.autohide_breath == true then + if breath >= breath_max and hb.settings.autohide_breath == true then hb.hide_hudbar(player, "breath") else hb.unhide_hudbar(player, "breath") - hb.change_hudbar(player, "breath", math.min(breath, 10)) + hb.change_hudbar(player, "breath", math.min(breath, breath_max-1), breath_max-1) end --health update_health(player)