itsonlym3

doit

May 31st, 2024 (edited)
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. -- Variables for dimensions
  2. local width = 5
  3. local length = 5
  4. local depth = 5
  5.  
  6. -- Function to dig a row
  7. local function digRow()
  8. for i = 1, width - 1 do
  9. turtle.dig()
  10. turtle.forward()
  11. end
  12. end
  13.  
  14. -- Function to return to the start of the row
  15. local function returnToStartOfRow()
  16. turtle.turnLeft()
  17. turtle.turnLeft()
  18. for i = 1, width - 1 do
  19. turtle.forward()
  20. end
  21. turtle.turnLeft()
  22. turtle.turnLeft()
  23. end
  24.  
  25. -- Function to move down a level
  26. local function moveDown()
  27. turtle.digDown()
  28. turtle.down()
  29. end
  30.  
  31. -- Main digging function
  32. local function digPit()
  33. for d = 1, depth do
  34. for l = 1, length do
  35. digRow()
  36. if l < length then
  37. if l % 2 == 1 then
  38. turtle.turnRight()
  39. turtle.dig()
  40. turtle.forward()
  41. turtle.turnRight()
  42. else
  43. turtle.turnLeft()
  44. turtle.dig()
  45. turtle.forward()
  46. turtle.turnLeft()
  47. end
  48. end
  49. end
  50.  
  51. -- Return to the starting position
  52. if length % 2 == 1 then
  53. returnToStartOfRow()
  54. else
  55. turtle.turnLeft()
  56. for i = 1, length - 1 do
  57. turtle.forward()
  58. end
  59. turtle.turnRight()
  60. end
  61.  
  62. -- Move down to the next layer
  63. if d < depth then
  64. moveDown()
  65. end
  66. end
  67. end
  68.  
  69. -- Start the digging process
  70. digPit()
Advertisement
Add Comment
Please, Sign In to add comment