Advertisement
Wassaa

compressSieve

Nov 27th, 2016
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.65 KB | None | 0 0
  1. args = {...}
  2. turtle.select(16)
  3. quantity = 0
  4.  
  5. function needMats()
  6.     if sieve.getStackInSlot(1) == nil then
  7.         getStack()
  8.         print("Need more Mats")
  9.     else
  10.         if sieve.getStackInSlot(1).qty <= 57 then
  11.             getStack()
  12.             print("need more Mats")
  13.         else
  14.             print("waiting 10")
  15.             os.sleep(10)
  16.         end
  17.     end
  18. end
  19.    
  20. function getStack()
  21.     for i=1, p.getInventorySize() do
  22.         if p.getStackInSlot(i) ~= nil then
  23.             if p.getStackInSlot(i).display_name ~= "Compressed Cobblestone" then
  24.                 quantity = p.getStackInSlot(i).qty
  25.                 if quantity >=63 then
  26.                     doCrafting(i, quantity)
  27.                     quantity = 0
  28.                     break
  29.                 end
  30.             end
  31.         end
  32.     end
  33. end
  34. function settings()
  35.     if #args==3 then
  36.         p = peripheral.wrap(tostring(args[1]))
  37.         sieve = peripheral.wrap(tostring(args[2]))
  38.         turtleDir = tostring(args[3])
  39.     else
  40.         print("need 3 arguments USAGE *Compress <intput side> <output side> <input to turtle direction>*")
  41.     end
  42. end
  43.  
  44. function doCrafting(slot, n)
  45.     craftNr = math.floor(n / 9)
  46.     --craftNr = math.floor(n / 4)
  47.     p.pushItemIntoSlot(turtleDir,slot,craftNr, 1)
  48.     p.pushItemIntoSlot(turtleDir,slot,craftNr, 2)
  49.     p.pushItemIntoSlot(turtleDir,slot,craftNr, 5)
  50.     p.pushItemIntoSlot(turtleDir,slot,craftNr, 6)
  51.     p.pushItemIntoSlot(turtleDir,slot,craftNr, 3)
  52.     p.pushItemIntoSlot(turtleDir,slot,craftNr, 7)
  53.     p.pushItemIntoSlot(turtleDir,slot,craftNr, 9)
  54.     p.pushItemIntoSlot(turtleDir,slot,craftNr, 10)
  55.     p.pushItemIntoSlot(turtleDir,slot,craftNr, 11)
  56.     turtle.craft()
  57.     print("crafted")
  58.     turtle.drop()
  59. end
  60.  
  61. settings()
  62.  
  63. print(turtleDir)
  64. while true do
  65.     p.condenseItems()
  66.     needMats()
  67.  
  68.     --print("waiting 1")
  69.     --os.sleep(0)
  70. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement