Advertisement
cragrim

PackagerFactorization3x3

Jun 9th, 2014
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.33 KB | None | 0 0
  1. --Packages all your items in a 3x3 crafting pattern using a factorization packager
  2. --Lag friendly!
  3.  
  4. --input chest above turtle
  5. --overflow chest in front of turtle
  6. --factorization packager below turtle
  7.  
  8. fails = 0
  9.  
  10. while true do
  11.   turtle.select(1)
  12.  
  13.   if fails > 0 then
  14.     print("Nothing to package for "..fails.." cycle(s).")
  15.   end
  16.   fails = fails + 1
  17.  
  18.   --count number of fails to pause to reduce lag
  19.   if fails > 5 then
  20.     print("Nothing has happened for a while, waiting a minute before resuming..")
  21.     os.sleep(60)
  22.   end
  23.  
  24.   --nothing found in chest waiting
  25.   if turtle.suckUp() == false then
  26.     os.sleep(10)
  27.   end
  28.  
  29.   --suck as many items as possible
  30.   print("Sucking items from chest above..")
  31.   while turtle.suckUp() == true do end
  32.  
  33.   --go through each slot
  34.   print("Looking for items to package..")
  35.   for s=1,16 do
  36.     turtle.select(s)
  37.    
  38.     --check if we have at least 9 items then do
  39.     if turtle.getItemCount(s) > 8 then
  40.      
  41.       --reset fails count
  42.       fails = 0
  43.      
  44.       --then send em all down
  45.       print("Found! Sending to packager below..")
  46.       while turtle.getItemCount(s) > 8 do
  47.         turtle.dropDown(9)
  48.         --wait for the factorization packager
  49.         os.sleep(1)
  50.       end
  51.     end
  52.     --send remaining to overflow chest
  53.     turtle.drop()
  54.   end
  55. os.sleep(1)
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement