forked from minetest-mods/item_drop
Make the code more robust
This commit is contained in:
parent
4aa8cdfdb2
commit
56a1d32476
4
init.lua
4
init.lua
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user