Advertisement
Guest User

Untitled

a guest
Jul 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. write("How many levels should I dig: ")
  2. local levels = tonumber(io.read())
  3.  
  4. write("Enter fuel slot (1-9): ")
  5. local fuelSlot = tonumber(io.read())
  6.  
  7. write("Enter torches slot (1-9): ")
  8. local torchSlot = tonumber(io.read())
  9.  
  10. write("Digging a 3x3 for "..levels.." levels!\n")
  11.  
  12. function checkFuel()
  13. if turtle.getFuelLevel() < 5 then
  14. turtle.select(1)
  15. if not turtle.refuel(1) then
  16. error("Out of fuel")
  17. end
  18. end
  19. end
  20.  
  21. function placeTorch()
  22. turtle.select(torchSlot)
  23. turtle.turnLeft()
  24. turtle.turnLeft()
  25. turtle.place()
  26. turtle.turnRight()
  27. turtle.turnRight()
  28. end
  29.  
  30. function dig()
  31. while turtle.detect() do
  32. turtle.dig()
  33. end
  34. end
  35.  
  36. function digUp()
  37. while turtle.detectUp() do
  38. turtle.digUp()
  39. end
  40. end
  41.  
  42. function mineLayer()
  43. dig()
  44. turtle.forward()
  45.  
  46. turtle.turnLeft()
  47. dig()
  48. digUp()
  49. turtle.up()
  50. dig()
  51. digUp()
  52. turtle.up()
  53. dig()
  54.  
  55. turtle.turnRight()
  56. turtle.turnRight()
  57. dig()
  58. turtle.down()
  59. dig()
  60. turtle.down()
  61. dig()
  62.  
  63. turtle.turnLeft()
  64. end
  65.  
  66. local levelsSinceTorch = 1
  67.  
  68. for i=1,levels do
  69. checkFuel()
  70. mineLayer()
  71. if levelsSinceTorch % 6 == 0 then
  72. placeTorch()
  73. end
  74. levelsSinceTorch = levelsSinceTorch + 1
  75. end
  76.  
  77. turtle.turnLeft()
  78. turtle.turnLeft()
  79. for i=1,levels do
  80. if turtle.detect() then
  81. turtle.dig()
  82. end
  83. turtle.forward()
  84. end
  85.  
  86. write("Finished mining\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement