diff --git a/lib/tror.lua b/lib/tror.lua index 2bb0a4b..260f9cc 100644 --- a/lib/tror.lua +++ b/lib/tror.lua @@ -134,12 +134,14 @@ tror.trocar_plus = function(player, item_rem, item_add) -- Transfere todos os itens ao jogador (e dropa os que nao couberem no inventario) local dropou = false - for _,item in ipairs(item_add) do - if inv:room_for_item("main", item) then - inv:add_item("main", item) - else - dropou = true - minetest.env:add_item({x = pos.x + math.random() * 2 - 1, y = pos.y+1, z = pos.z + math.random() * 2 - 1}, item) + if item_add ~= nil then + for _,item in ipairs(item_add) do + if inv:room_for_item("main", item) then + inv:add_item("main", item) + else + dropou = true + minetest.env:add_item({x = pos.x + math.random() * 2 - 1, y = pos.y+1, z = pos.z + math.random() * 2 - 1}, item) + end end end