diff options
author | Wuzzy <almikes@aol.com> | 2016-10-24 16:26:34 +0200 |
---|---|---|
committer | Wuzzy <almikes@aol.com> | 2016-10-24 16:26:34 +0200 |
commit | a161aae09c07489764678f7603e6ecd23557cb78 (patch) | |
tree | cf1086137283fa659ad736105edb22dd8e7b1132 | |
parent | 7e30f89d13d49188213c97801fa5da19c75d78de (diff) |
Check if player object is nil
-rw-r--r-- | init.lua | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -1040,14 +1040,16 @@ local function reveal_items_in_inventory(player) end minetest.register_on_dignode(function(pos, oldnode, digger) + if digger == nil then return end local playername = digger:get_player_name() - if digger ~= nil and playername ~= nil and playername ~= "" and oldnode ~= nil then + if playername ~= nil and playername ~= "" and oldnode ~= nil then reveal_item(playername, oldnode.name) reveal_items_in_inventory(digger) end end) minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing) + if puncher == nil then return end local playername = puncher:get_player_name() if playername ~= nil and playername ~= "" and node ~= nil then reveal_item(playername, node.name) @@ -1055,22 +1057,25 @@ minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing) end) minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing) + if placer == nil then return end local playername = placer:get_player_name() - if placer ~= nil and playername ~= nil and playername ~= "" and itemstack ~= nil and not itemstack:is_empty() then + if playername ~= nil and playername ~= "" and itemstack ~= nil and not itemstack:is_empty() then reveal_item(playername, itemstack:get_name()) end end) minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv) + if player == nil then return end local playername = player:get_player_name() - if player ~= nil and playername ~= nil and playername ~= "" and itemstack ~= nil and not itemstack:is_empty() then + if playername ~= nil and playername ~= "" and itemstack ~= nil and not itemstack:is_empty() then reveal_item(playername, itemstack:get_name()) end end) minetest.register_on_item_eat(function(hp_change, replace_with_item, itemstack, user, pointed_thing) + if user == nil then return end local playername = user:get_player_name() - if user ~= nil and playername ~= nil and playername ~= "" and itemstack ~= nil and not itemstack:is_empty() then + if playername ~= nil and playername ~= "" and itemstack ~= nil and not itemstack:is_empty() then reveal_item(playername, itemstack:get_name()) if replace_with_item ~= nil then reveal_item(playername, replace_with_item) |