Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mg = peripheral.wrap("left")
- local numSerums = 0
- function checkFuel()
- local f = turtle.getFuelLevel()
- if (f < 10) then
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.forward()
- while (f < 10) do
- sleep(10)
- end
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.forward()
- end
- end
- function processSerums()
- local serum, state
- for serum=1,numSerums do
- print ("Processing serum #"..tostring(serum))
- turtle.select(serum)
- turtle.drop()
- repeat
- sleep(5)
- state = mg.get()
- until (state["Is Not Working"] and state["Energy Stored"] and state["Liquid in Tank"])
- turtle.suck()
- end
- end
- function getSerums()
- local serum, flag
- numSerums = 0
- turtle.select(1)
- while turtle.suck() do
- numSerums = numSerums + 1
- end
- end
- function doWork()
- local serum
- print ("Checking fuel level...")
- checkFuel()
- print ("Done")
- print ("Getting serums...")
- turtle.turnRight()
- getSerums()
- turtle.turnLeft()
- if (numSerums < 1) then
- print ("Nothing to do!")
- return
- end
- print ("Done")
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- print ("Refilling serums...")
- processSerums()
- print ("Done")
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- print ("Purifying serums...")
- processSerums()
- print ("Done")
- print ("Returning serums...")
- turtle.up()
- turtle.turnRight()
- turtle.forward()
- for serum=1,numSerums do
- turtle.select(serum)
- turtle.drop()
- end
- turtle.back()
- turtle.down()
- turtle.turnLeft()
- print ("All done!")
- end
- checkFuel()
- while true do
- os.pullEvent("redstone")
- print ("Redstone event!")
- local val = redstone.getBundledInput("bottom")
- if (colors.test(val, colors.red)) then
- print ("Start work")
- doWork()
- rs.setBundledOutput("bottom", colors.green)
- rs.setBundledOutput("bottom", 0)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment