Improve error logging a little

This commit is contained in:
stujones11 2015-01-04 21:37:12 +00:00
parent b5db0f1aa6
commit e3c2616328

View File

@ -94,10 +94,10 @@ armor.set_player_armor = function(self, player)
local name = player:get_player_name() local name = player:get_player_name()
local player_inv = player:get_inventory() local player_inv = player:get_inventory()
if not name then if not name then
minetest.log("error", "Failed to read player name") minetest.log("error", "set_player_armor: Failed to read player name")
return return
elseif not player_inv then elseif not player_inv then
minetest.log("error", "Failed to read player inventory") minetest.log("error", "set_player_armor: Failed to read player inventory")
return return
end end
local armor_texture = "3d_armor_trans.png" local armor_texture = "3d_armor_trans.png"
@ -182,9 +182,14 @@ end
armor.update_armor = function(self, player) armor.update_armor = function(self, player)
if not player then if not player then
minetest.log("error", "update_armor: Invalid player object reference")
return return
end end
local name = player:get_player_name() local name = player:get_player_name()
if not name then
minetest.log("error", "update_armor: Invalid player name")
return
end
local hp = player:get_hp() or 0 local hp = player:get_hp() or 0
if hp == 0 or hp == self.player_hp[name] then if hp == 0 or hp == self.player_hp[name] then
return return
@ -193,10 +198,10 @@ armor.update_armor = function(self, player)
local player_inv = player:get_inventory() local player_inv = player:get_inventory()
local armor_inv = minetest.get_inventory({type="detached", name=name.."_armor"}) local armor_inv = minetest.get_inventory({type="detached", name=name.."_armor"})
if not player_inv then if not player_inv then
minetest.log("error", "Failed to read player inventory") minetest.log("error", "update_armor: Failed to read player inventory")
return return
elseif not armor_inv then elseif not armor_inv then
minetest.log("error", "Failed to read detached inventory") minetest.log("error", "update_armor: Failed to read detached inventory")
return return
end end
local heal_max = 0 local heal_max = 0
@ -253,7 +258,15 @@ armor.get_armor_formspec = function(self, name)
end end
armor.update_inventory = function(self, player) armor.update_inventory = function(self, player)
if not player then
minetest.log("error", "update_inventory: Invalid player object reference")
return
end
local name = player:get_player_name() local name = player:get_player_name()
if not name then
minetest.log("error", "update_inventory: Invalid player name")
return
end
if inv_mod == "unified_inventory" then if inv_mod == "unified_inventory" then
if unified_inventory.current_page[name] == "armor" then if unified_inventory.current_page[name] == "armor" then
unified_inventory.set_inventory_formspec(player, "armor") unified_inventory.set_inventory_formspec(player, "armor")