Make the code more robust

This commit is contained in:
PilzAdam 2012-09-09 17:04:27 +02:00
parent 4aa8cdfdb2
commit 56a1d32476

@ -5,7 +5,7 @@ minetest.register_globalstep(function(dtime)
local inv = player:get_inventory()
for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 1)) do
if not object:is_player() and object:get_luaentity().name == "__builtin:item" then
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
if inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
inv:add_item("main", ItemStack(object:get_luaentity().itemstring))
if object:get_luaentity().itemstring ~= "" then
@ -20,7 +20,7 @@ minetest.register_globalstep(function(dtime)
end
for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 2)) do
if not object:is_player() and object:get_luaentity().name == "__builtin:item" then
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
if object:get_luaentity().collect then
if inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
local pos1 = pos