Advertisement
Josqus

Untitled

Nov 6th, 2023
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. -- Function to mine a single row
  2. function mineRow(length)
  3. if length == 0 then
  4. return
  5. else
  6. -- Mine the block in front
  7. turtle.dig()
  8. -- Move forward
  9. if turtle.forward() then
  10. -- Recursively mine the next block
  11. mineRow(length - 1)
  12. end
  13. end
  14. end
  15.  
  16. -- Function to mine the entire field
  17. function mineField(width, depth)
  18. if depth == 0 then
  19. return
  20. else
  21. -- Mine a single row
  22. mineRow(width)
  23. -- Turn around
  24. turtle.turnRight()
  25. turtle.turnRight()
  26. -- Go back to the start of the row
  27. for i=1, width do
  28. turtle.forward()
  29. end
  30. -- Position for the next row
  31. turtle.turnRight()
  32. if turtle.forward() then
  33. turtle.turnRight()
  34. -- Recursively mine the next layer
  35. mineField(width, depth - 1)
  36. else
  37. -- If we can't move forward, we've hit an obstacle or the edge of the field
  38. print("Unable to move to the next row.")
  39. return
  40. end
  41. end
  42. end
  43.  
  44. -- Start mining the field
  45. mineField(6, 6)
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement