delay = 0.5

while true do
  if turtle.detectUp() then
    turtle.digUp()
  else
    os.sleep(delay)
  end
end
