SryNotToxic

Untitled

Sep 29th, 2024
7
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. -- Function to check if the turtle's inventory is full
  2. function isInventoryFull()
  3. for slot = 1, 16 do
  4. if turtle.getItemCount(slot) == 0 then
  5. return false -- There's an empty slot
  6. end
  7. end
  8. return true -- All slots are full
  9. end
  10.  
  11. -- Function to fill the turtle's inventory from the chest in front
  12. function fillInventory()
  13. while not isInventoryFull() do
  14. turtle.suck() -- Try to pull items from the chest in front
  15. sleep(0.5) -- Slight delay to allow for more items to be available
  16. end
  17. end
  18.  
  19. -- Function to perform the required movements: turn left, move forward, down, turn right
  20. function moveToDropLocation()
  21. turtle.turnLeft() -- Turn left
  22. turtle.forward() -- Move forward
  23. turtle.down() -- Move down
  24. turtle.turnRight()-- Turn right
  25. end
  26.  
  27. -- Function to move back to the original position
  28. function returnToStart()
  29. turtle.turnLeft() -- Turn left
  30. turtle.up() -- Move up
  31. turtle.back() -- Move back to the original spot
  32. turtle.turnRight()-- Turn right
  33. end
  34.  
  35. -- Function to transfer all items from turtle to chest
  36. function transferItems()
  37. for slot = 1, 16 do
  38. turtle.select(slot)
  39. turtle.drop() -- Drop items into the chest in front
  40. end
  41. end
  42.  
  43. -- Main loop
  44. while true do
  45. fillInventory() -- Fill the turtle's inventory from the first chest
  46. moveToDropLocation() -- Perform the movements to get to the second chest
  47. transferItems() -- Drop the items into the second chest
  48. returnToStart() -- Move back to the original position
  49. sleep(5) -- Wait 5 seconds before repeating
  50. end
  51.  
Add Comment
Please, Sign In to add comment