diff --git a/armor.lua b/armor.lua index f16aa77..511640d 100644 --- a/armor.lua +++ b/armor.lua @@ -7,13 +7,16 @@ end) function hbarmor.get_armor(player) if not player or not armor.def then - return + return false end local name = player:get_player_name() local def = armor.def[name] or nil if def and def.state and def.count then hbarmor.set_armor(name, def.state, def.count) + else + return false end + return true end function hbarmor.set_armor(player_name, ges_state, items) diff --git a/init.lua b/init.lua index 87382f2..8b42a4a 100644 --- a/init.lua +++ b/init.lua @@ -34,7 +34,10 @@ local function custom_hud(player) local name = player:get_player_name() if minetest.setting_getbool("enable_damage") then - hbarmor.get_armor(player) + local ret = hbarmor.get_armor(player) + if ret == false then + minetest.log("error", "[hbarmor] Call to hbarmor.get_armor in custom_hud returned with false!") + end local arm = tonumber(hbarmor.armor[name]) if not arm then arm = 0 end local hide @@ -97,8 +100,10 @@ minetest.register_globalstep(function(dtime) for _,player in ipairs(minetest.get_connected_players()) do local name = player:get_player_name() if hbarmor.player_active[name] == true then - hbarmor.get_armor(player) - + local ret = hbarmor.get_armor(player) + if ret == false then + minetest.log("error", "[hbarmor] Call to hbarmor.get_armor in globalstep returned with false!") + end -- update all hud elements update_hud(player) end