Advertisement
LostMiner

Untitled

Oct 27th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. t = turtle
  2. function moveForward()
  3.     if t.detect() then
  4.         t.dig()
  5.         t.forward()
  6.     else
  7.         t.forward()
  8.     end
  9. end
  10. function fuelTurtle(distance)
  11.     t.refuel(distance/80)
  12. end
  13. function moveDistance(distance)
  14.     while distance > 0 do
  15.         moveForward()
  16.         distance = distance - 1
  17.     end
  18. end
  19. function distanceInput()
  20.   num = io.read()
  21.   num = tonumber(num)
  22.   return num
  23. end
  24. function turnAround()
  25.     t.turnLeft()
  26.     t.turnLeft()
  27. end
  28. function moveUp()
  29.     if t.detectUp() then
  30.         t.digUp()
  31.         t.up()
  32.     else
  33.         t.up()
  34.     end
  35. end
  36. function main()
  37.     distance = distanceInput()
  38.     fuelTurtle(distance)
  39.     moveDistance(distance)
  40.     t.refuel(1)
  41.     moveUp()
  42.     turnAround()
  43.     fuelTurtle(distance)
  44.     moveDistance(distance)
  45. end
  46.  
  47. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement