Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mg = peripheral.wrap("left")
- rednet.open("right")
- function myPrint(...)
- f = fs.open("inoc.log", "a")
- f.writeLine(...)
- print(...)
- f.close()
- end
- function checkDone()
- state = mg.get()
- printState(state)
- return ((state["Is Not Working"] and state["Energy Stored"]) and state["Cannot Work"])
- end
- function printState(state)
- for k,v in pairs(state) do
- if (v) then myPrint(k) end
- end
- end
- function removeSerum()
- serumSlot = findSerumSlot()
- redstone.setOutput("top", true)
- repeat
- sleep(1)
- until (turtle.getItemCount(serumSlot) > 0)
- redstone.setOutput("top", false)
- turtle.turnRight()
- turtle.select(serumSlot)
- turtle.drop()
- turtle.turnLeft()
- end
- function findSerumSlot()
- local slot
- local _serumSlot = 0
- for slot=1,16 do
- if turtle.getItemCount(slot) == 0 then
- if _serumSlot == 0 then _serumSlot = slot end
- end
- end
- myPrint ("Serums should land in slot "..tostring(_serumSlot))
- return _serumSlot
- end
- function removeBees(slot)
- for ii = 0,5 do
- if (slot + ii < 16) then
- turtle.select(slot+ii)
- res = turtle.suck()
- --myPrint("To slot "..tostring(slot+ii)..": "..tostring(res))
- end
- end
- end
- function refillSerums()
- myPrint ("Waiting for a refill...")
- rednet.broadcast("Refill")
- repeat
- id,msg,dist = rednet.receive()
- until (msg == "Done") and (dist == 2)
- end
- function doBee(slot)
- local state
- local serumSlot
- while true do
- myPrint ("Getting serum...")
- turtle.select(16)
- turtle.turnLeft()
- gotOne = turtle.suck()
- turtle.turnRight()
- if (gotOne == false) then
- myPrint ("No more serums!")
- break
- end
- myPrint ("Inserting bees from slots #"..tostring(slot).." - "..tostring(slot+5))
- for ii = 0,5 do
- if (slot + ii < 16) then
- turtle.select(slot+ii)
- res = turtle.drop()
- -- myPrint ("From slot "..tostring(slot+ii).." "..tostring(res))
- end
- end
- myPrint ("Inserting serum...")
- turtle.select(16)
- turtle.drop()
- myPrint ("Waiting for the machine to finish...")
- repeat
- sleep(100)
- until (checkDone())
- myPrint ("Removing the bees...")
- removeBees(slot)
- myPrint ("Serum done")
- removeSerum()
- -- turtle.drop()
- end
- refillSerums()
- end
- -- rs.setBundledOutput("back", colors.red)
- serumSlot = findSerumSlot()
- local hasItems = false
- for i=1,15,5 do
- hasItems = false
- for ii = 0,5 do
- if (i+ii < 16) then
- if (turtle.getItemCount(i+ii) > 0) then
- hasItems = true
- end
- end
- end
- if (hasItems == true) then
- doBee(i)
- end
- end
- -- rs.setBundledOutput("back", colors.green)
Advertisement
Add Comment
Please, Sign In to add comment