Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mg = peripheral.wrap("left")
- rednet.open("right")
- local numSerums = 0
- function processSerums()
- local serum, state
- for serum=1,numSerums do
- print ("Processing serum #"..tostring(serum))
- turtle.select(serum)
- turtle.drop()
- sleep(1)
- state = mg.get()
- if (state["Pure Serum"] == false) then
- repeat
- sleep(15)
- state = mg.get()
- until (state["Pure Serum"])
- end
- 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()
- print ("Getting serums...")
- turtle.turnLeft()
- getSerums()
- turtle.turnRight()
- if (numSerums < 1) then
- print ("Nothing to do!")
- return
- end
- print ("Done")
- print ("Processing serums...")
- processSerums()
- print ("Done")
- print ("Returning serums...")
- turtle.turnRight()
- for serum=1,numSerums do
- turtle.select(serum)
- turtle.drop()
- end
- turtle.turnLeft()
- print ("All done!")
- end
- while true do
- id, msg, dist = rednet.receive()
- if (msg == "Purify") and (dist == 2) then
- print ("Start work")
- sleep(1)
- doWork()
- rednet.broadcast("Done")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment