Advertisement
Guest User

Strip1

a guest
Oct 17th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.92 KB | None | 0 0
  1. -- Strip mining turtle program.
  2. -- Luke *********, Ryszard ********. 13/12/12
  3.  
  4. --[[fuel must be placed in slot 15,
  5. torches must be placed in slot 16.]]
  6.  
  7. -- Create the function for refueling
  8. function checkFuel()
  9.   if turtle.getFuelLevel() <= 10 then
  10.     turtle.select(15)
  11.     turtle.refuel(1)
  12.     turtle.select(1)
  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 distance = 0
  25.   local gang = 0
  26.   for index = 1,givenLength do
  27.     turtle.dig()
  28.     if turtle.forward() then
  29.       distance = distance + 1
  30.       gang = gang + 1
  31.     end --if
  32.     turtle.digUp()
  33.     turtle.select(1)
  34.     turtle.turnLeft()
  35.     if gang == 0 then
  36.       for index = 1,2 do
  37.         for index = 0,5 do
  38.           turtle.dig()
  39.           turtle.forward()
  40.           turtle.digUp()
  41.           turtle.select(1)
  42.           turtle.placeDown()
  43.         end --for
  44.         turtle.turnLeft()
  45.         turtle.turnLeft()  
  46.         turtle.placeDown()
  47.         turtle.forward()
  48.         turtle.forward()
  49.         turtle.forward()
  50.         turtle.forward()
  51.         turtle.forward()
  52.         if gang == 2 then
  53.           gang = 0
  54.         end --if
  55.       end --for
  56.       turtle.turnRight()
  57.     end --function
  58.    
  59. -- Places a torch every 10 blocks
  60.     if distance == 10 then
  61.       turtle.select(16)
  62.       print("Placing torch...")
  63.       turnAround()
  64.       turtle.place()
  65.       turnAround()
  66.       distance = 0
  67.       checkFuel()
  68.     end --if
  69.   end --for
  70.  
  71. -- Sends the turtle back to the start
  72.     turtle.up()
  73.     for index = 1,givenLength do
  74.       turtle.back()
  75.     end --for
  76.     turtle.down()
  77. end --tunnel()
  78.  
  79. -- Main script
  80. print("Input tunnel length:")
  81. local length = read()
  82. print("starting excavation...")
  83. checkFuel()
  84. tunnel(length)
  85. print("The tunnel has been excavated!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement