Advertisement
Guest User

Untitled

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