Advertisement
Smokefag

Mining

Feb 21st, 2023 (edited)
832
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.42 KB | Software | 0 0
  1. function turtle.forwards(numForw)
  2.     for i = 1, numForw do
  3.         turtle.forward()
  4.     end
  5. end
  6.  
  7. function turtle.upwards(numUpw)
  8.     for i = 1, numUpw do
  9.         turtle.up()
  10.     end
  11. end
  12.  
  13. function turtle.downwards(numDownw)
  14.     for i = 1, numDownw do
  15.         turtle.down()
  16.     end
  17. end
  18.  
  19. function turtle.turns180()
  20.     for i = 1, 2 do
  21.         turtle.turnRight()
  22.     end
  23. end    
  24.  
  25. function scan()
  26.     if turtle.detect() then
  27.         turtle.dig()
  28.     end
  29. end
  30. function scanUp()
  31.     if turtle.detectUp() then
  32.         turtle.digUp()
  33.     end
  34. end
  35.  
  36. function mining(distance)
  37.     for i = 1, distance do
  38.         scan();
  39.         scanUp();
  40.         turtle.forward()
  41.         i = i + 1;
  42.     end
  43.         scanUp();
  44.     for i = 1, distance do
  45.         turtle.back()
  46.         i = i - 1;
  47.     end      
  48. end
  49.  
  50. print("input mining length")
  51. local distance = tonumber(io.read())
  52. while not distance do
  53.     print("Invalid input. Please enter a number.")
  54.     distance = tonumber(io.read())
  55. end    
  56.  
  57. mining(distance)
  58. turtle.turnRight()
  59. turtle.forward()
  60. turtle.turnLeft()
  61. mining(distance)
  62. turtle.turnRight()
  63. turtle.forward()
  64. turtle.turnLeft()
  65. mining(distance)
  66. turtle.turnRight()
  67. turtle.forward()
  68. turtle.turnLeft()
  69. mining(distance)
  70. turtle.turnRight()
  71. turtle.forward()
  72. turtle.turnLeft()
  73. mining(distance)
  74. turtle.turnRight()
  75. turtle.forward()
  76. turtle.turnLeft()
  77. mining(distance)
  78. turtle.turnLeft()
  79. turtle.forwards(5)
  80. turtle.turnRight()
  81.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement