stripmine75 v0.1


SUBMITTED BY: Guest

DATE: Aug. 14, 2013, 3:18 a.m.

FORMAT: Text only

SIZE: 2.9 kB

HITS: 902

  1. --[[Computer slot 1, Filter slot 2, Timer slot 3, Chest slot 4, Fuel slot 15, torches 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. -- Create the turnAround function
  16. function turnAround()
  17. turtle.turnRight()
  18. turtle.turnRight()
  19. end --turnAround()
  20. -- Digs the tunnel for the given length
  21. function tunnel(givenLength)
  22. local torchDistance = 0
  23. d = 0
  24. while d <= 75 do
  25. if turtle.detect() then
  26. repeat
  27. turtle.dig()
  28. sleep(0.50)
  29. until turtle.detect() == false
  30. end --if
  31. turtle.forward()
  32. if turtle.detectUp() then
  33. repeat
  34. turtle.digUp()
  35. sleep(0.50)
  36. until turtle.detectUp() == false
  37. end --if
  38. turtle.turnLeft()
  39. if turtle.detect() then
  40. repeat
  41. turtle.dig()
  42. sleep(0.50)
  43. until turtle.detect() == false
  44. end --if
  45. turtle.up()
  46. if turtle.detect() then
  47. repeat
  48. turtle.dig()
  49. sleep(0.50)
  50. until turtle.detect() == false
  51. end--if
  52. turtle.turnRight()
  53. turtle.turnRight()
  54. if turtle.detect() then
  55. repeat
  56. turtle.dig()
  57. sleep(0.50)
  58. until turtle.detect() == false
  59. end
  60. turtle.down()
  61. if turtle.detect() then
  62. repeat
  63. turtle.dig()
  64. sleep(0.50)
  65. until turtle.detect() == false
  66. end
  67. turtle.turnLeft()
  68. d = d + 1
  69. torchDistance = torchDistance + 1
  70. -- attempts to place a block below
  71. turtle.select(1)
  72. turtle.placeDown()
  73. -- Places a torch every 9 blocks
  74. if torchDistance == 9 then
  75. print("Placing torch...")
  76. turtle.select(16)
  77. turnAround()
  78. turtle.place()
  79. turnAround()
  80. torchDistance = 0
  81. checkFuel()
  82. end --if
  83. end --for
  84. -- Sends the turtle back to the start
  85. turtle.up()
  86. turnAround()
  87. for index = 1,givenLength do
  88. checkFuel()
  89. if not turtle.detect() then
  90. turtle.forward()
  91. else
  92. repeat
  93. turtle.dig()
  94. turtle.sleep(0.25)
  95. until turtle.detect() == false
  96. turtle.forward()
  97. end --if
  98. end --for
  99. turtle.down()
  100. turnAround()
  101. end --tunnel()
  102. -- Main script
  103. print("Input tunnel length:")
  104. local length = 75
  105. print("Starting excavation...")
  106. tunnel(length)
  107. term.clear()
  108. print("The tunnel has been excavated!")

comments powered by Disqus