Advertisement
Wassaa

ferment

Jan 10th, 2014
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.75 KB | None | 0 0
  1. local chest = peripheral.wrap("left")
  2. local size = chest.getInventorySize()
  3. local fer = peripheral.wrap("fermenter_0")
  4. local pushDir = "south"
  5. local pullDir = "north"
  6. local signal = "back"
  7. local ferSignal = "front"
  8. local toPush = {}
  9. local dirt = {}
  10. --yeast process
  11.  
  12. function emptyFer() --empty up fermenter
  13.     for z = 1, 3 do
  14.         local varig = fer.getStackInSlot(z)
  15.         if varig ~= nil then
  16.             fer.pushItem(pullDir, z, 64)
  17.         end
  18.     end
  19.     print("machine emptied")
  20. end
  21.  
  22. function pushMats(firstID, dirtID)
  23.     dirt = {}
  24.     emptyFer()
  25.     --print("do I evven lift")
  26.     toPush = {}
  27.     chest.condenseItems()
  28.     for i=1,size do
  29.         --print("do I evven lift")
  30.         local id = chest.getStackInSlot(i)
  31.         if (id ~= nil) then
  32.             if id["id"] == firstID then
  33.                 local leng = table.getn(toPush) + 1
  34.                 toPush[leng] = i
  35.                 print("to push - "..chest.getStackInSlot(i)["name"])
  36.             elseif id["id"] == dirtID then
  37.                 local leng = table.getn(dirt) + 1
  38.                 dirt[leng] = i
  39.                 --chest.pushItemIntoSlot(pushDir, i, 64, 1)
  40.                 print("to push - "..chest.getStackInSlot(i)["name"])
  41.             end
  42.         end
  43.     end
  44.     print(toPush)
  45.     print(dirt)
  46.     print (getResult())
  47. end
  48.  
  49. function getResult()
  50.     --print("am I here?")
  51.     rs.setOutput(signal, false)
  52.  
  53.     if table.getn(toPush) > 0 and table.getn(dirt) > 0 then
  54.     local dirtLoc = 1
  55.         for k,v in pairs(toPush) do
  56.             while chest.getStackInSlot(v) ~= nil do
  57.                 print("looping")
  58.                 chest.pushItemIntoSlot(pushDir, v, 64, 1)
  59.                 fer.pushItem(pullDir, 3, 64)
  60.                 while fer.getStackInSlot(1) ~= nil do
  61.                     fer.pushItem(pullDir, 3, 64)
  62.                     print("slot1 not empty")
  63.                     rs.setOutput(signal, true)
  64.                     fer.pushItem(pullDir, 3, 64)
  65.                    
  66.                     if fer.getStackInSlot(2) == nil then
  67.                         print(table.getn(dirt))
  68.                         if table.getn(dirt) >= 1 then
  69.                             if chest.getStackInSlot(dirt[dirtLoc]) == nil then
  70.                                 dirtLoc = dirtLoc + 1
  71.                                 print (dirtLoc)
  72.                                 if dirtLoc > table.getn(dirt) then
  73.                                     toPush = {}
  74.                                     dirt = {}
  75.                                     return "out of dirt/plant matter"
  76.                                 end
  77.                             else
  78.                                 chest.pushItemIntoSlot(pushDir, dirt[dirtLoc], 64, 2)
  79.                             end
  80.                         else
  81.                             toPush = {}
  82.                             dirt = {}
  83.                             return "out of dirt/plant matter"
  84.                         end
  85.                     end
  86.                    
  87.                 end
  88.                    
  89.             end
  90.         end
  91.         toPush = {}
  92.         dirt = {}
  93.     end
  94.     return "All done!"
  95. end    
  96.            
  97.        
  98. function makeYeast()
  99. print ("getting somewhere?")
  100.     -- empty fermenter
  101.     rs.setOutput(ferSignal, false)
  102.     pushMats(353, 3)--set fermenter on yeast mode upslot and downslot IDs
  103.     rs.setOutput(signal, false)
  104.     emptyFer()
  105. end
  106.  
  107. function makeSludge()
  108.     rs.setOutput(ferSignal, true)
  109.     pushMats(30761, 2406)--set fermenter to sludge mode upslot and downslot IDs
  110.     rs.setOutput(signal, false)
  111.     rs.setOutput(ferSignal, false)
  112.     emptyFer()
  113. end
  114.  
  115. makeYeast()
  116. makeSludge()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement