Aarondmorgan

stripmine75

Jan 6th, 2013
650
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. --[[Fuel must be placed in slot 15, torches must be placed in slot 16.]]
  2. -- Create the function for refueling
  3. function checkFuel()
  4. if turtle.getFuelLevel() <= 20 then
  5. if turtle.getItemCount(15) == 0 then
  6. print("Out of fuel.")
  7. exit()
  8. else
  9. turtle.select(15)
  10. turtle.refuel(1)
  11. turtle.select(1)
  12. end --if
  13. end --if
  14. end --checkFuel()
  15.  
  16. -- Create the turnAround function
  17. function turnAround()
  18. turtle.turnRight()
  19. turtle.turnRight()
  20. end --turnAround()
  21.  
  22. -- Digs the tunnel for the given length
  23. function tunnel(givenLength)
  24. local torchDistance = 0
  25. d = 0
  26. while d <= 75 do
  27. if turtle.detect() then
  28. repeat
  29. turtle.dig()
  30. sleep(0.50)
  31. until turtle.detect() == false
  32. end --if
  33. turtle.forward()
  34. if turtle.detectUp() then
  35. repeat
  36. turtle.digUp()
  37. sleep(0.50)
  38. until turtle.detectUp() == false
  39. end --if
  40. turtle.turnLeft()
  41. if turtle.detect() then
  42. repeat
  43. turtle.dig()
  44. sleep(0.50)
  45. until turtle.detect() == false
  46. end --if
  47. turtle.up()
  48. if turtle.detect() then
  49. repeat
  50. turtle.dig()
  51. sleep(0.50)
  52. until turtle.detect() == false
  53. end--if
  54. turtle.turnRight()
  55. turtle.turnRight()
  56. if turtle.detect() then
  57. repeat
  58. turtle.dig()
  59. sleep(0.50)
  60. until turtle.detect() == false
  61. end
  62. turtle.down()
  63. if turtle.detect() then
  64. repeat
  65. turtle.dig()
  66. sleep(0.50)
  67. until turtle.detect() == false
  68. end
  69. turtle.turnLeft()
  70. d = d + 1
  71. torchDistance = torchDistance + 1
  72. -- attempts to place a block below
  73. turtle.select(1)
  74. turtle.placeDown()
  75. -- Places a torch every 9 blocks
  76. if torchDistance == 9 then
  77. print("Placing torch...")
  78. turtle.select(16)
  79. turnAround()
  80. turtle.place()
  81. turnAround()
  82. torchDistance = 0
  83. checkFuel()
  84. end --if
  85. end --for
  86. -- Sends the turtle back to the start
  87. turtle.up()
  88. turnAround()
  89. for index = 1,givenLength do
  90. checkFuel()
  91. if not turtle.detect() then
  92. turtle.forward()
  93. else
  94. repeat
  95. turtle.dig()
  96. turtle.sleep(0.25)
  97. until turtle.detect() == false
  98. turtle.forward()
  99. end --if
  100. end --for
  101. turtle.down()
  102. turnAround()
  103. end --tunnel()
  104.  
  105. -- Main script
  106. print("Input tunnel length:")
  107. local length = 75
  108. print("Starting excavation...")
  109. tunnel(length)
  110. term.clear()
  111. print("The tunnel has been excavated!")
Advertisement
Add Comment
Please, Sign In to add comment