Advertisement
Josqus

Untitled

Nov 6th, 2023
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. -- Ensure the turtle has a tool (diamond pickaxe) to dig stone
  2. if not turtle.dig() then
  3. print("Unable to dig. Do I have the correct tool?")
  4. end
  5.  
  6. function mineLayer(x, y, z)
  7. if z < 1 then
  8. return
  9. else
  10. -- Dig down
  11. if turtle.detectDown() then
  12. if turtle.digDown() then
  13. print("Dug down.")
  14. else
  15. print("Failed to dig down. Is there a bedrock?")
  16. end
  17. end
  18. if turtle.down() then
  19. print("Moved down.")
  20. else
  21. print("Failed to move down.")
  22. end
  23.  
  24. -- Call the function to mine the next layer
  25. mineLayer(x, y, z - 1)
  26.  
  27. -- Dig up and return to original position
  28. if turtle.detectUp() then
  29. if turtle.digUp() then
  30. print("Dug up.")
  31. else
  32. print("Failed to dig up. Is there a bedrock?")
  33. end
  34. end
  35. if turtle.up() then
  36. print("Moved up.")
  37. else
  38. print("Failed to move up.")
  39. end
  40. end
  41. end
  42.  
  43. function mineStrip(length)
  44. for i = 1, length do
  45. if turtle.detect() then
  46. if turtle.dig() then
  47. print("Dug forward.")
  48. else
  49. print("Failed to dig forward.")
  50. end
  51. end
  52. if turtle.forward() then
  53. print("Moved forward.")
  54. else
  55. print("Failed to move forward.")
  56. end
  57. end
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement