Advertisement
krakaen

For RB

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