Advertisement
GNOOR1S

CC Minecraft - Turtle Clearing Program WIP

Oct 25th, 2022
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | Gaming | 0 0
  1. local tArgs = {...}
  2. local direction = 1 -- 0 = forward, 1 = back
  3.  
  4. --[[
  5. Add saving functionality
  6. ]]
  7.  
  8. if #tArgs < 1 then
  9. printError("Needs Arguments")
  10. printError("quarry [x][y][z]")
  11. return
  12. end
  13.  
  14. function fuel()
  15. if turtle.getFuelLevel() < 10 then
  16. turtle.select(16)
  17. turtle.refuel(1)
  18. turtle.select(1)
  19. end
  20. if turtle.getItemCount(16) < 1 then
  21. print("turtle requires fuel and will resume after")
  22. repeat
  23.  
  24. until turtle.getItemCount(16) > 10
  25. fuel()
  26. end
  27.  
  28. end
  29.  
  30. function tr()
  31. turtle.turnRight()
  32. end
  33.  
  34. function tl()
  35. turtle.turnLeft()
  36. end
  37.  
  38. function fwd()
  39. fuel()
  40. while not turtle.forward() do turtle.dig() end
  41. end
  42.  
  43. function toggleDir()
  44. if tonumber(direction) == 0 then
  45. direction = 1
  46. print("facing backward")
  47. elseif tonumber(direction) == 1 then
  48. direction = 0
  49. print("facing forward")
  50. end
  51. end
  52.  
  53. function getDirection()
  54. if direction == 0 then
  55. return "forward"
  56. elseif direction == 1 then
  57. return "back"
  58. end
  59. end
  60.  
  61. local length = tonumber(tArgs[3]) -- z axis from turtle facing forward
  62. local height = tonumber(tArgs[2]) -- starts from the top
  63. local width = tonumber(tArgs[1]) -- starts from the left
  64.  
  65. -- implement saving and loading function here
  66.  
  67. -- starts on the top left of placement of turtle in the forward direction
  68.  
  69.  
  70. for x = 1, width do
  71. for y = 1, height do
  72. for z = 1, length - 1 do
  73. fwd()
  74. end
  75. -- end of z access run
  76. if y < height then
  77. turtle.digDown()
  78. tl()
  79. tl()
  80. turtle.down()
  81. end
  82. if y % 2 == 0 then
  83. direction = 1
  84. else
  85. direction = 0
  86. end
  87. end
  88.  
  89. for y = 1, height do
  90. turtle.up()
  91. fuel()
  92. end
  93.  
  94. -- if ends in forward direction
  95. if direction == 0 then
  96. for i = 1, length - 1 do
  97. fuel()
  98. turtle.back()
  99. end
  100. tr()
  101. fwd()
  102. tl()
  103. end
  104.  
  105. if direction == 1 then
  106. return
  107. end
  108.  
  109. end
  110.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement