PackagerFactorization3x3

Mirror of http://pastebin.com/zzAurEPk

--Packages all your items in a 3x3 crafting pattern using a factorization packager
--Lag friendly!

--input chest above turtle
--overflow chest in front of turtle
--factorization packager below turtle

fails = 0
 
while true do
  turtle.select(1)
 
  if fails > 0 then
    print("Nothing to package for "..fails.." cycle(s).")
  end
  fails = fails + 1
 
  --count number of fails to pause to reduce lag
  if fails > 5 then
    print("Nothing has happened for a while, waiting a minute before resuming..")
    os.sleep(60)
  end
 
  --nothing found in chest waiting
  if turtle.suckUp() == false then
    os.sleep(10)
  end
 
  --suck as many items as possible
  print("Sucking items from chest above..")
  while turtle.suckUp() == true do end
 
  --go through each slot
  print("Looking for items to package..")
  for s=1,16 do
    turtle.select(s)
   
    --check if we have at least 9 items then do
    if turtle.getItemCount(s) > 8 then
     
      --reset fails count
      fails = 0
     
      --then send em all down
      print("Found! Sending to packager below..")
      while turtle.getItemCount(s) > 8 do
        turtle.dropDown(9)
        --wait for the factorization packager
        os.sleep(1)
      end
    end
    --send remaining to overflow chest
    turtle.drop()
  end
os.sleep(1)
end
Advertisements