Advertisement
Josqus

turtleStorage

Nov 2nd, 2023 (edited)
1,173
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.92 KB | Gaming | 0 0
  1. currentX = 0
  2. currentY = 0
  3.  
  4. function moveToCoordinates(targetX, targetY)
  5.     --local currentX, currentY = getPosition() -- You'll need to implement this function
  6.     local safeY = 3 -- Choose a safe height that is above all chests
  7.  
  8.     -- Move up to a safe height first
  9.     if currentX ~= 0 then
  10.         turtle.back()
  11.     end
  12.     while currentY < safeY do
  13.         turtle.up()
  14.         currentY = currentY + 1
  15.     end
  16.  
  17.     -- Move to the correct X coordinate
  18.     while currentX < targetX do
  19.         turtle.forward()
  20.         currentX = currentX + 1
  21.     end
  22.     while currentX > targetX do
  23.         turtle.back()
  24.         currentX = currentX - 1
  25.     end
  26.  
  27.     -- Move down to the target Y coordinate
  28.     while currentY > targetY do
  29.         turtle.down()
  30.         currentY = currentY - 1
  31.     end
  32.     while currentY < targetY do
  33.         turtle.down()
  34.         currentY = currentY + 1
  35.     end
  36. end
  37.  
  38. --moveToCoordinates(2, , targetZ)
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement