SY573M_404

Untitled

May 27th, 2023
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. relative_x = 0
  2. relative_y = 0
  3. rotation = 0
  4.  
  5. function rotateTo(targetRotation)
  6. while rotation % 4 ~= targetRotation do
  7. turtle.turnRight()
  8. rotation = rotation + 1
  9. end
  10.  
  11. rotation = rotation % 4
  12. end
  13.  
  14.  
  15. function goTo(x, y)
  16. if x ~= relative_x then
  17. if x > relative_x then
  18. rotateTo(1)
  19. else
  20. rotateTo(3)
  21. end
  22.  
  23. while x ~= relative_x do
  24. turtle.dig()
  25. assert(turtle.forward())
  26.  
  27. if x > relative_x then
  28. relative_x = relative_x + 1
  29. else
  30. relative_x = relative_x - 1
  31. end
  32. end
  33. end
  34.  
  35. if y ~= relative_y then
  36. if y > relative_y then
  37. rotateTo(0)
  38. else
  39. rotateTo(2)
  40. end
  41.  
  42. while y ~= relative_y do
  43. while true do
  44. local exists, _ = turtle.inspect()
  45.  
  46. if exists then
  47. if not turtle.dig() then
  48. break
  49. end
  50. else
  51. break
  52. end
  53. end
  54.  
  55. assert(turtle.forward())
  56.  
  57. if y > relative_y then
  58. relative_y = relative_y + 1
  59. else
  60. relative_y = relative_y - 1
  61. end
  62. end
  63. end
  64. end
  65.  
  66. for y = 0,20 do
  67. for x = 0,4 do
  68. if x % 2 == 0 then
  69. goTo(x, 0)
  70. goTo(x, 4)
  71. else
  72. goTo(x, 4)
  73. goTo(x, 0)
  74. end
  75.  
  76. for slot = 1,16 do
  77. turtle.select(slot)
  78. detail = turtle.getItemDetail()
  79.  
  80. if detail ~= nil then
  81. turtle.refuel(64)
  82.  
  83. if not string.find(detail["name"], "ore") and not string.find(detail["name"], "raw") and not string.find(detail["name"], "diamond") then
  84. turtle.drop(64)
  85. end
  86. end
  87. end
  88. end
  89.  
  90. goTo(0, 0)
  91. rotateTo(2)
  92.  
  93. for i = 1,y do
  94. turtle.up()
  95. end
  96.  
  97. for slot = 1,16 do
  98. turtle.select(slot)
  99. turtle.drop(64)
  100. end
  101.  
  102. for i = 1,y do
  103. turtle.down()
  104. end
  105.  
  106. rotateTo(0)
  107.  
  108. if y ~= -40 then
  109. turtle.digDown()
  110. assert(turtle.down())
  111. end
  112. end
  113.  
Advertisement
Add Comment
Please, Sign In to add comment