Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mg = peripheral.wrap("left")
- rednet.open("right")
- local numSerums = 0
- local tArgs = {...}
- local role = tArgs[1]
- 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()
- 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 == role) then
- print ("Start work")
- sleep(1)
- doWork()
- if (role == "Refill") then
- rednet.broadcast("Purify")
- else
- rednet.broadcast("Inoculate")
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment