Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------------------------------------------------------------------------------
- --
- --
- --
- --
- -- cache
- cache = {}
- cache[1] = vector.new(0, 0, 0)
- cache[2] = vector.new(0, 0, -3)
- cache[3] = vector.new(0, 0, -6)
- -- chest to seek for
- Turtle.addWayPoint()
- Turtle.cache = function()
- while true do
- turtle.select(1)
- -- wait until we got at least one item
- print('Waiting for new items to arrive')
- while not turtle.suckDown() do
- sleep(0.1)
- end
- print('Grabbing items...')
- -- if there is something in the box, grab it
- while turtle.suckDown() do
- end
- print('Caching...')
- -- if we are here, our turtle grabbed ALL items or is at least full of items, however, we are dropping them to a cache chest
- for id, coords in pairs(cache) do
- Turtle.goTo(coords)
- -- try to drop items
- itemsLeft = false
- print('Dropping items to cache chest #' .. id .. '...')
- for slotId = 1, 16 do
- turtle.select(slotId)
- if not turtle.dropUp() and turtle.getItemCount(slotId) ~= 0 then
- itemsLeft = true
- end
- end
- -- if we gave up at at east one item, search another chest
- if not itemsLeft then
- break
- end
- print('Items remaining, but cache chest seems to be full...')
- end
- print('Returning to seeking chest')
- Turtle.goToLastWP2()
- end
- end
- term.clear()
- term.setCursorPos(1, 1)
- Turtle.cache()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement