Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. -- Variable decleration.
  2. local cycleCount
  3. local inFront, blockInfo = turtle.inspect()
  4.  
  5. -- Functions.
  6. function digSuckMove(direction)
  7. if direction == "up" then
  8. if turtle.detect() == true then
  9. print("Block above! Mining, picking up and moving up!")
  10. turtle.digUp()
  11. turtle.suckUp()
  12. turtle.up()
  13. else
  14. print("Nothing above! Moving up!")
  15. turtle.up()
  16. end
  17.  
  18. elseif direction == "down" then
  19. if turtle.detectDown() == true then
  20. print("Block below! Mining, picking up and moving down!")
  21. turtle.digDown()
  22. turtle.suckDown()
  23. turtle.Down()
  24. else
  25. print("Nothing below! Moving down!")
  26. turtle.Down()
  27. end
  28.  
  29. elseif direction == "forward" then
  30. if turtle.detect() == true then
  31. print("Block in front! Mining, picking up and moving forward!")
  32. turtle.dig()
  33. turtle.suck()
  34. turtle.forward()
  35. else
  36. print("Nothing in front! Moving forward!")
  37. turtle.forward()
  38. end
  39. else
  40. print("Invalid argument!")
  41. end
  42. end
  43.  
  44. function returnToStart()
  45. for i3 = 1, cycleCount, 1 do
  46. turtle.back()
  47. end
  48. end
  49.  
  50. -- Read the cycle count.
  51. print("How many cycles to run?")
  52. cycleCount = read()
  53.  
  54. -- Run the cycle.
  55. for i = 1, cycleCount, 1 do
  56.  
  57. -- Print the current cycle number.
  58. print("Running cycle number "..i..".")
  59.  
  60. digSuckMove("forward")
  61. digSuckMove("up")
  62. digSuckMove("up")
  63. turtle.turnLeft()
  64.  
  65. for i2 = 1, 2, 1 do
  66. turtle.dig()
  67. turtle.down()
  68. end
  69. turtle.dig()
  70.  
  71. turtle.turnRight()
  72. turtle.turnRight()
  73.  
  74. for i2 = 1, 2, 1 do
  75. turtle.dig()
  76. turtle.up()
  77. end
  78. turtle.dig();
  79.  
  80. turtle.back()
  81. turtle.turnLeft()
  82. turtle.down()
  83. turtle.down()
  84.  
  85. -- End of for.
  86. end
  87.  
  88. print("Run completed successfuly! Returning to base!")
  89. returnToStart()
  90.  
  91. print("Returned to starting position! Press any button to clear screen!");
  92. os.pullEvent('key')
  93. term.clear()
  94. term.setCursorPos(1,1)
  95.  
  96. -- Prevent instant termination.
  97. -- read()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement