This commit is contained in:
Alexsandro Percy 2022-03-23 20:18:30 -03:00
parent 6213cfaa71
commit 3575ea26ad
1 changed files with 16 additions and 14 deletions

View File

@ -90,23 +90,25 @@ end
function airutils.remove_inventory(self) function airutils.remove_inventory(self)
local inventory = airutils.get_inventory(self) local inventory = airutils.get_inventory(self)
if inventory:is_empty("main") then if inventory then
return minetest.remove_detached_inventory(self._inv_id) if inventory:is_empty("main") then
else return minetest.remove_detached_inventory(self._inv_id)
local inv_content = inventory:get_list("main") else
if inv_content then local inv_content = inventory:get_list("main")
local pos = self.object:get_pos() if inv_content then
for k, v in pairs(inv_content) do local pos = self.object:get_pos()
local count = 0 for k, v in pairs(inv_content) do
for i = 0,v:get_count()-1,1 local count = 0
do for i = 0,v:get_count()-1,1
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},v:get_name()) do
count = count + 1 minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},v:get_name())
if count >= 5 then break end count = count + 1
if count >= 5 then break end
end
end end
end end
return minetest.remove_detached_inventory(self._inv_id)
end end
return minetest.remove_detached_inventory(self._inv_id)
end end
return false return false
end end