Advertisement
HeatedDZN

Item Pick Up

May 18th, 2024 (edited)
652
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.38 KB | None | 0 0
  1. -- Function to pick up items from the chest below
  2. local function pickUpItems()
  3.     for slot = 1, 16 do
  4.         turtle.select(slot)
  5.         while turtle.suckDown() do end
  6.     end
  7. end
  8.  
  9. -- Function to move up by a specified number of blocks
  10. local function moveUp(n)
  11.     for i = 1, n do
  12.         while not turtle.up() do
  13.             turtle.digUp()
  14.         end
  15.     end
  16. end
  17.  
  18. -- Function to move down by a specified number of blocks
  19. local function moveDown(n)
  20.     for i = 1, n do
  21.         while not turtle.down() do
  22.             turtle.digDown()
  23.         end
  24.     end
  25. end
  26.  
  27. -- Function to move forward by a specified number of blocks
  28. local function moveForward(n)
  29.     for i = 1, n do
  30.         while not turtle.forward() do
  31.             turtle.dig()
  32.         end
  33.     end
  34. end
  35.  
  36. -- Function to drop items from the turtle's inventory
  37. local function dropItems()
  38.     for slot = 1, 16 do
  39.         turtle.select(slot)
  40.         turtle.drop()
  41.     end
  42. end
  43.  
  44. -- Main function
  45. local function main()
  46.     while true do
  47.         pickUpItems()
  48.         moveUp(4)
  49.         moveForward(32)
  50.         turtle.turnLeft()
  51.         moveForward(7)
  52.         dropItems()
  53.         turtle.turnLeft()
  54.         moveForward(32)
  55.         turtle.turnLeft()
  56.         moveForward(7)
  57.         moveDown(4)
  58.         turtle.turnLeft()
  59.         os.sleep(30) -- Sleep for 30 seconds
  60.     end
  61. end
  62.  
  63. -- Start the script
  64. main()
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement