Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --routerbot!
- function suck()
- print "Starting suck cycle!"
- turtle.select(1)
- while not turtle.suck() do
- print "Nothing in the Ender chest. Waiting a while..."
- sleep(20)
- end
- local sucked = 1
- print "Sucking!!"
- while turtle.suck() do
- sucked = sucked + 1
- end
- print ("Finished sucking. Got ".. sucked .. " items.")
- end
- function spin()
- turtle.turnRight()
- turtle.turnRight()
- end
- function unclog()
- print "Possible Clog?"
- sleep(1)
- local counter = 0
- for i = 1, 10 do
- sleep(1)
- print "Trying to drop!"
- if turtle.drop() then
- break
- end
- counter = counter + 1
- if counter == 10 then
- local full = 1
- for i = 1, 16 do
- print ("Checking slot " .. i)
- if turtle.getItemCount(i) == 0 then
- print ("Room found for clogged item in slot " .. i)
- turtle.select(i)
- turtle.suck()
- print "Putting it into the chest above me."
- if turtle.dropUp() == true then
- full = 0
- end
- break
- end
- end
- if full == 1 then
- print "SHIT BE FULL, YO."
- return false
- else
- return true
- end
- end
- end
- return true
- end
- function drop()
- for i=1,16 do
- turtle.select(i)
- if turtle.getItemCount(i) > 0 then
- if turtle.drop() == false then
- if unclog() == false then
- return false
- end
- turtle.select(i)
- turtle.drop()
- end
- end
- end
- print "Slight rest."
- sleep(3)
- print "Checking router for clogged item before next cycle."
- if turtle.suck() then
- if turtle.dropUp() == false then
- print "There was an item in the router, but the chest is full. "
- return false
- end
- end
- return true
- end
- function router()
- local doStuff = true
- while doStuff do
- suck()
- spin()
- doStuff = drop()
- spin()
- end
- end
- router()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement