Merge pull request 'Minor fixes on potion behavior on damage disabled servers (closes 4586)' (#4599) from goodspeed/VoxeLibre:potion-hud into master

Reviewed-on: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4599
Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land>
This commit is contained in:
the-real-herowl 2024-08-18 05:49:44 +02:00
commit 09aba760cf
2 changed files with 12 additions and 1 deletions

@ -330,9 +330,16 @@ function hb.change_hudbar(player, identifier, new_value, new_max_value, new_icon
local name = player:get_player_name()
local hudtable = hb.get_hudtable(identifier)
-- hb.change_hudbar may be called with a non-existing hudbar like hunger.
if hudtable == nil then
return false
end
if not hudtable.hudstate[name] then
return false
end
local value_changed, max_changed = false, false
if new_value then

@ -1260,7 +1260,11 @@ local function potions_init_icons(player)
})
table.insert(icon_ids[name], id)
end
hb.init_hudbar(player, "absorption")
-- Absorption bar in damage disabled server is unneccessary
if minetest.settings:get_bool("enable_damage") == true then
hb.init_hudbar(player, "absorption")
end
end
local function potions_set_icons(player)