Advertisement
Josqus

Untitled

Nov 6th, 2023
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. function mineLayer(x, y, z)
  2. if z < 1 then
  3. return
  4. else
  5. -- Dig down
  6. if not turtle.detectDown() then
  7. turtle.digDown()
  8. end
  9. turtle.down()
  10.  
  11. -- Call the function to mine the next layer
  12. mineLayer(x, y, z - 1)
  13.  
  14. -- Dig up and return to original position
  15. turtle.up()
  16. end
  17. end
  18.  
  19. function mineStrip(length)
  20. for i = 1, length do
  21. if not turtle.detect() then
  22. turtle.dig()
  23. end
  24. turtle.forward()
  25. end
  26. end
  27.  
  28. function mineField(width, length, depth)
  29. for w = 1, width do
  30. -- Mine a strip of the specified length
  31. mineStrip(length)
  32.  
  33. -- Position the turtle to start the next strip
  34. if w < width then
  35. if w % 2 == 1 then
  36. turtle.turnRight()
  37. if not turtle.detect() then
  38. turtle.dig()
  39. end
  40. turtle.forward()
  41. turtle.turnRight()
  42. else
  43. turtle.turnLeft()
  44. if not turtle.detect() then
  45. turtle.dig()
  46. end
  47. turtle.forward()
  48. turtle.turnLeft()
  49. end
  50. end
  51. end
  52.  
  53. -- Recursive call to mine the next layer down
  54. mineLayer(width, length, depth)
  55. end
  56.  
  57. -- Start the mining operation
  58. mineField(6, 1, 6)
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement