local selectedSlot = 1
local fails = 0
turtle.select(1)
while true do
  if not turtle.forward() then
    break
  end
  while not turtle.placeDown() do
  if selectedSlot==16 then
    error("Not enough items.")
  end
    if turtle.detectDown() then
      fails = fails + 1
      break
    else
      turtle.select(selectedSlot + 1)
      selectedSlot = selectedSlot + 1
    end
  end
end
