Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local chest = peripheral.wrap("left")
- local size = chest.getInventorySize()
- local fer = peripheral.wrap("fermenter_0")
- local pushDir = "south"
- local pullDir = "north"
- local signal = "back"
- local ferSignal = "front"
- local toPush = {}
- local dirt = {}
- --yeast process
- function emptyFer() --empty up fermenter
- for z = 1, 3 do
- local varig = fer.getStackInSlot(z)
- if varig ~= nil then
- fer.pushItem(pullDir, z, 64)
- end
- end
- print("machine emptied")
- end
- function pushMats(firstID, dirtID)
- dirt = {}
- emptyFer()
- --print("do I evven lift")
- toPush = {}
- chest.condenseItems()
- for i=1,size do
- --print("do I evven lift")
- local id = chest.getStackInSlot(i)
- if (id ~= nil) then
- if id["id"] == firstID then
- local leng = table.getn(toPush) + 1
- toPush[leng] = i
- print("to push - "..chest.getStackInSlot(i)["name"])
- elseif id["id"] == dirtID then
- local leng = table.getn(dirt) + 1
- dirt[leng] = i
- --chest.pushItemIntoSlot(pushDir, i, 64, 1)
- print("to push - "..chest.getStackInSlot(i)["name"])
- end
- end
- end
- print(toPush)
- print(dirt)
- print (getResult())
- end
- function getResult()
- --print("am I here?")
- rs.setOutput(signal, false)
- if table.getn(toPush) > 0 and table.getn(dirt) > 0 then
- local dirtLoc = 1
- for k,v in pairs(toPush) do
- while chest.getStackInSlot(v) ~= nil do
- print("looping")
- chest.pushItemIntoSlot(pushDir, v, 64, 1)
- fer.pushItem(pullDir, 3, 64)
- while fer.getStackInSlot(1) ~= nil do
- fer.pushItem(pullDir, 3, 64)
- print("slot1 not empty")
- rs.setOutput(signal, true)
- fer.pushItem(pullDir, 3, 64)
- if fer.getStackInSlot(2) == nil then
- print(table.getn(dirt))
- if table.getn(dirt) >= 1 then
- if chest.getStackInSlot(dirt[dirtLoc]) == nil then
- dirtLoc = dirtLoc + 1
- print (dirtLoc)
- if dirtLoc > table.getn(dirt) then
- toPush = {}
- dirt = {}
- return "out of dirt/plant matter"
- end
- else
- chest.pushItemIntoSlot(pushDir, dirt[dirtLoc], 64, 2)
- end
- else
- toPush = {}
- dirt = {}
- return "out of dirt/plant matter"
- end
- end
- end
- end
- end
- toPush = {}
- dirt = {}
- end
- return "All done!"
- end
- function makeYeast()
- print ("getting somewhere?")
- -- empty fermenter
- rs.setOutput(ferSignal, false)
- pushMats(353, 3)--set fermenter on yeast mode upslot and downslot IDs
- rs.setOutput(signal, false)
- emptyFer()
- end
- function makeSludge()
- rs.setOutput(ferSignal, true)
- pushMats(30761, 2406)--set fermenter to sludge mode upslot and downslot IDs
- rs.setOutput(signal, false)
- rs.setOutput(ferSignal, false)
- emptyFer()
- end
- makeYeast()
- makeSludge()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement