hudbars+hbhunger+hbarmor - fix armor bar set to 0% due old loading engines

* for minetest 0.4.16 and 0.4.17 loading of mods is a pain, the
  `on_mods_loaded` still do not exits and only using dependency
  we can get sure a mod its present.
  hudbars need armors parts be present and 100% lodaed to property
  check the armor.def so made optional dependencies only in depends.txt
  cos mod.conf is for newer engines and those works perfectly.
  This only happened at player join or initialization, due
  several errors in the already buggy 3d_armor mod, check:
  https://github.com/minetest-mods/3d_armor/issues/49
master
mckaygerhard 2023-08-06 01:00:47 -04:00
parent 02120d280e
commit 6327ac1eb0
2 changed files with 6 additions and 4 deletions

View File

@ -1,6 +1,9 @@
default?
intllib?
3d_armor?
3d_armor_gloves?
shields?
wieldview?
flowers?
animalmaterials?
bucket?

View File

@ -629,6 +629,7 @@ if not modhbarm and modarmors then
function hbarmor.get_armor(player)
if not player or not armor.def then
minetest.log("error", "[hbarmor] Call to hbarmor.get_armor cannot do it cos the payer armor definition its not set at this moment!")
return false
end
local name = player:get_player_name()
@ -637,7 +638,7 @@ if not modhbarm and modarmors then
if def and def.state and def.count then
hbarmor.set_armor(name, def.state, def.count)
else
minetest.log("error", "[hudbars] Call to hbarmor.get_armor returned with false!")
minetest.log("error", "[hudbars] Call to hbarmor.get_armor returned with false! armor.def[player] invalid")
return false
end
return true
@ -675,11 +676,9 @@ local function custom_hud(player)
hb.init_hudbar(player, "breath", math.min(breath, breath_max), breath_max, hide_breath)
if not modhbarm and modarmors then
local arm = tonumber(hbarmor.armor[name])
if not arm then arm = 0 end
local arm = tonumber(hbarmor.armor[name] or 0)
local hide_ar = hbarmor.autohide and must_hide(name, arm)
hbarmor.get_armor(player)
arm = tonumber(hbarmor.armor[name])
hb.init_hudbar(player, "armor", arm_printable(arm), 100, hide_ar)
end