Advertisement
bali3355

Script for Mining Turtle

Dec 17th, 2019
2,031
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.81 KB | None | 0 0
  1. --3x3 tunnel maker With TurtleOS 1.8
  2. --based on Luke Ryszard script
  3.  
  4. --[[
  5. ITEMS IN GUI!
  6. [  ][  ][  ][  ]
  7. [  ][  ][  ][  ]
  8. [  ][  ][  ][  ]
  9. [  ][  ][15][16]
  10.  
  11. 15 - fuel spot
  12. 16 - torch spot
  13. ]]
  14. function RMine()
  15.     turtle.turnRight()
  16.     turtle.dig()
  17.     turtle.forward()
  18.     turtle.digUp()
  19.     turtle.digDown()
  20.     turtle.turnLeft()
  21.     turtle.turnLeft()
  22.     turtle.forward()
  23.     turtle.digDown()
  24.     turtle.turnRight()
  25. end -- end RMine()
  26.  
  27. function LMine()
  28.     turtle.turnLeft()
  29.     turtle.dig()
  30.     turtle.forward()
  31.     turtle.digUp()
  32.     turtle.digDown()
  33.     turtle.turnRight()
  34.     turtle.turnRight()
  35.     turtle.forward()
  36.     turtle.digDown()
  37.     turtle.turnLeft()
  38. end -- end LMine()
  39.  
  40. function checkFuel()
  41.   if turtle.getFuelLevel() <= 10 then
  42.     turtle.select(15)
  43.     turtle.refuel(1)
  44.     turtle.select(1)
  45.   end --if
  46. end --checkFuel()
  47.  
  48. -- Create the turnAround function
  49. function turnAround()
  50.   turtle.turnRight()
  51.   turtle.turnRight()
  52. end --turnAround()
  53.  
  54. -- Digs the tunnel for the given length
  55. function tunnel(givenLength)
  56.   local distance = 0
  57.   turtle.up()
  58.   for index = 1,givenLength do
  59.     turtle.dig()
  60.     if turtle.forward() then
  61.       distance = distance + 1
  62.     end --if
  63.     turtle.digUp()
  64.     turtle.select(1)
  65.     turtle.placeDown()
  66.     LMine()
  67.     RMine()
  68. -- Places a torch every 10 blocks
  69.     if distance == 10 then
  70.       turtle.select(16)
  71.       print("Placing torch...")
  72.       turnAround()
  73.       turtle.place()
  74.       turnAround()
  75.       distance = 0
  76.       checkFuel()
  77.     end --if
  78.   end --for
  79.  
  80. -- Sends the turtle back to the start
  81.     turtle.up()
  82.     for index = 1,givenLength do
  83.       turtle.back()
  84.     end --for
  85.     turtle.down()
  86. end --tunnel()
  87.  
  88. -- Main script
  89. print("Input tunnel length:")
  90. local length = read()
  91. print("starting excavation...")
  92. checkFuel()
  93. tunnel(length)
  94. print("The tunnel has been excavated!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement