Add some error messages in case of failure

This commit is contained in:
Wuzzy 2015-02-24 07:02:35 +01:00
parent b169a0307d
commit 5947496935
2 changed files with 12 additions and 4 deletions

View File

@ -7,13 +7,16 @@ end)
function hbarmor.get_armor(player) function hbarmor.get_armor(player)
if not player or not armor.def then if not player or not armor.def then
return return false
end end
local name = player:get_player_name() local name = player:get_player_name()
local def = armor.def[name] or nil local def = armor.def[name] or nil
if def and def.state and def.count then if def and def.state and def.count then
hbarmor.set_armor(name, def.state, def.count) hbarmor.set_armor(name, def.state, def.count)
else
return false
end end
return true
end end
function hbarmor.set_armor(player_name, ges_state, items) function hbarmor.set_armor(player_name, ges_state, items)

View File

@ -34,7 +34,10 @@ local function custom_hud(player)
local name = player:get_player_name() local name = player:get_player_name()
if minetest.setting_getbool("enable_damage") then 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]) local arm = tonumber(hbarmor.armor[name])
if not arm then arm = 0 end if not arm then arm = 0 end
local hide local hide
@ -97,8 +100,10 @@ minetest.register_globalstep(function(dtime)
for _,player in ipairs(minetest.get_connected_players()) do for _,player in ipairs(minetest.get_connected_players()) do
local name = player:get_player_name() local name = player:get_player_name()
if hbarmor.player_active[name] == true then 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 all hud elements
update_hud(player) update_hud(player)
end end