Plieax

testmovement

May 3rd, 2024 (edited)
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. local x = 1
  2. local y = 1
  3. local z = 1
  4.  
  5.  
  6. local function backD(distance)
  7. turtle.turnLeft()
  8. turtle.turnLeft()
  9. for i=1,distance do
  10. if turtle.detect() then
  11. turtle.dig()
  12. end
  13. turtle.forward()
  14. z = z - 1
  15. end
  16. turtle.turnLeft()
  17. turtle.turnLeft()
  18. end
  19.  
  20. local function rightD(distance)
  21. turtle.turnRight()
  22. for i=1,distance do
  23. if turtle.detect() then
  24. turtle.dig()
  25. end
  26. turtle.forward()
  27. x = x - 1
  28. end
  29. turtle.turnLeft()
  30. end
  31.  
  32. local function leftD(distance)
  33. turtle.turnLeft()
  34. for i=1,distance do
  35. if turtle.detect() then
  36. turtle.dig()
  37. end
  38. turtle.forward()
  39. x = x + 1
  40. end
  41. turtle.turnRight()
  42. end
  43.  
  44. local function forwardD(distance)
  45. for i=1,distance do
  46. if turtle.detect() then
  47. turtle.dig()
  48. end
  49. turtle.forward()
  50. z = z + 1
  51. end
  52. end
  53.  
  54. local function downD(distance)
  55. for i=1,distance do
  56. if turtle.detectDown() then
  57. turtle.digDown()
  58. end
  59. y = y - 1
  60. turtle.down()
  61. end
  62. end
  63.  
  64. local function upD(distance)
  65. for i=1,distance do
  66. if turtle.detectUp() then
  67. turtle.digUp()
  68. end
  69. y = y + 1
  70. turtle.up()
  71. end
  72. end
  73.  
  74.  
  75.  
  76.  
  77. local xoff = 1
  78. local yoff = 1
  79. local zoff = 1
  80.  
  81. local movingForward = true
  82. local movingLeft = false
  83.  
  84. while true do
  85. -- navigation sysstem
  86.  
  87. -- this number must be even for this to work
  88. if zoff == 4 then
  89. if movingForward then
  90. movingForward = false
  91. movingLeft = true
  92. zoff = 1
  93. rightD(3)
  94. forwardD(1)
  95. else
  96. movingForward = true
  97. movingLeft = false
  98. zoff = 1
  99. rightD(3)
  100. backD(1)
  101. end
  102. xoff = xoff + 1
  103. else
  104.  
  105. if movingLeft then
  106. leftD(1)
  107. else
  108. rightD(1)
  109. end
  110.  
  111. if movingForward then
  112. forwardD(2)
  113. else
  114. backD(2)
  115. end
  116.  
  117. if movingLeft then
  118. movingLeft = false
  119. else
  120. movingLeft = true
  121. end
  122.  
  123. zoff = zoff + 1
  124. end
  125.  
  126. turtle.digDown()
  127. end
Advertisement
Add Comment
Please, Sign In to add comment