Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to check if the turtle's inventory is full
- function isInventoryFull()
- for slot = 1, 16 do
- if turtle.getItemCount(slot) == 0 then
- return false -- There's an empty slot
- end
- end
- return true -- All slots are full
- end
- -- Function to fill the turtle's inventory from the chest in front
- function fillInventory()
- while not isInventoryFull() do
- turtle.suck() -- Try to pull items from the chest in front
- sleep(0.5) -- Slight delay to allow for more items to be available
- end
- end
- -- Function to perform the required movements: turn left, move forward, down, turn right
- function moveToDropLocation()
- turtle.turnLeft() -- Turn left
- turtle.forward() -- Move forward
- turtle.down() -- Move down
- turtle.turnRight()-- Turn right
- end
- -- Function to move back to the original position
- function returnToStart()
- turtle.turnLeft() -- Turn left
- turtle.up() -- Move up
- turtle.back() -- Move back to the original spot
- turtle.turnRight()-- Turn right
- end
- -- Function to transfer all items from turtle to chest
- function transferItems()
- for slot = 1, 16 do
- turtle.select(slot)
- turtle.drop() -- Drop items into the chest in front
- end
- end
- -- Main loop
- while true do
- fillInventory() -- Fill the turtle's inventory from the first chest
- moveToDropLocation() -- Perform the movements to get to the second chest
- transferItems() -- Drop the items into the second chest
- returnToStart() -- Move back to the original position
- sleep(5) -- Wait 5 seconds before repeating
- end
Add Comment
Please, Sign In to add comment