m=peripheral.wrap("top") while 1 do slots=m.getSizeInventory() while slots==0 do os.sleep(2) print("slept for 2s") slots=m.getSizeInventory() end for i=0,slots-1 do info=m.getStackInSlot(i) if info~= nil then key,value=next(info) if value=="item.lootbag" then print("Found lootbag in slot "..i+1) m.push("down",i,1) turtle.place() break end end os.sleep(0) end os.sleep(0) end