Advertisement
azrylaero

Mining Turtle Strip Mine Program

May 2nd, 2013
65,954
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. -- Strip mining turtle program.
  2. -- Luke *********, Ryszard ********. 13/12/12
  3. -- updated by AzrylAero 5/3/2013
  4.  
  5. --[[fuel must be placed in slot 14,
  6. mainshaft torches must be placed in slot 15
  7. tunnel torches must be placed in slot 16.]]
  8.  
  9. -- Create the function for refueling
  10. function checkFuel()
  11. if turtle.getFuelLevel() <= 10 then
  12. turtle.select(14)
  13. turtle.refuel(1)
  14. turtle.select(1)
  15. end --if
  16. end --checkFuel()
  17.  
  18. -- Create the turnAround function
  19. function turnAround()
  20. turtle.turnRight()
  21. turtle.turnRight()
  22. end --turnAround()
  23.  
  24. -- Go to the next tunnel
  25. function digNext(torchCounter)
  26. turtle.turnRight()
  27. turtle.dig()
  28. turtle.forward()
  29. turtle.digUp()
  30. turtle.dig()
  31. turtle.forward()
  32. turtle.digUp()
  33. if torchCounter == 2 then
  34.  
  35. turnAround()
  36. turtle.select(15)
  37. turtle.place()
  38. turnAround()
  39. print("Placing mainshaft torch")
  40. end
  41. turtle.turnLeft()
  42. print("turn Right")
  43. print("Next Tunnel")
  44. end
  45.  
  46.  
  47. --Dig Next End
  48.  
  49. -- Digs the tunnel for the given length
  50. function tunnel(givenLength)
  51. local distance = 0
  52. for index = 1,givenLength do
  53. turtle.dig()
  54. if turtle.forward() then
  55. distance = distance + 1
  56. end --if
  57. turtle.digUp()
  58. turtle.select(1)
  59. turtle.placeDown()
  60.  
  61. -- Places a torch every 10 blocks
  62. if distance == 10 then
  63. turtle.select(16)
  64. print("Placing tunnel torch...")
  65. turnAround()
  66. turtle.place()
  67. turnAround()
  68. distance = 0
  69. checkFuel()
  70. end --if
  71. end --for
  72.  
  73. -- Sends the turtle back to the start
  74. turtle.up()
  75. for index = 1,givenLength do
  76. turtle.back()
  77. end --for
  78. turtle.down()
  79. end --tunnel()
  80.  
  81. -- Main script
  82. print("Input tunnel length:")
  83. local length = read()
  84. print("Tunnel quantity")
  85. local quantity = read()
  86. local torchNext = 0
  87. print("starting excavation...")
  88. checkFuel()
  89. -- Tunnel loop
  90. for index=1,quantity do
  91. if torchNext == 3 then
  92. torchNext = 0
  93. end
  94. tunnel(length)
  95. checkFuel()
  96. digNext(torchNext)
  97. torchNext = torchNext + 1
  98. end
  99. print("The tunnel(s) has been excavated!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement