Guest User

beeTest3

a guest
Jul 26th, 2013
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.62 KB | None | 0 0
  1. mg = peripheral.wrap("left")
  2. rednet.open("right")
  3.  
  4. function doBee(slot)
  5.    local state
  6.    
  7.    while true do
  8.       print ("Placing bee...")
  9.       turtle.select(slot)
  10.       turtle.drop()
  11.      
  12.       print ("Getting serum...")
  13.       turtle.select(16)
  14.       turtle.turnLeft()
  15.       gotOne = turtle.suck()
  16.       turtle.turnRight()
  17.       if (gotOne == false) then
  18.      print ("No more serums")
  19.      turtle.select(slot)
  20.      turtle.suck()
  21.      break
  22.       else
  23.      print ("Got one")
  24.       end
  25.  
  26.       print ("Inserting serum...")
  27.       x = turtle.drop()
  28.       print (tostring(x))
  29.       print ("Waiting for the machine to start...")
  30.       sleep(5)
  31.       repeat
  32.          sleep(5)
  33.          print ("Waiting for the machine to finish...")
  34.          state = mg.get()
  35.       until (state["Is Not Working"] and state["Energy Stored"])
  36.  
  37.       print ("Getting the bee back...")
  38.       turtle.select(slot)
  39.       turtle.suck()
  40.       print ("Removing the serum...")
  41.       turtle.select(16)
  42.       turtle.suck()
  43.       print ("Sending the serum back...")
  44.       turtle.turnRight()
  45.       turtle.drop()
  46.       turtle.turnLeft()
  47.       print ("End iteration")
  48.    end
  49. end
  50.  
  51. rs.setBundledOutput("top", colors.red)
  52.  
  53. for i=1,15 do
  54.    if (turtle.getItemCount(i) > 0) then
  55.       print ("Processing bee in slot #"..tostring(i))
  56.       doBee(i)
  57.       print ("Asking for a refill...")
  58.       rednet.broadcast("Refill")
  59.      
  60.       print ("Waiting for a refill...")
  61.       repeat
  62.          id, msg, dist = rednet.receive()
  63.       until (msg == "Inoculate")
  64.       print ("Done with this bee")
  65.    end
  66. end  
  67.  
  68. rs.setBundledOutput("top", colors.green)
Advertisement
Add Comment
Please, Sign In to add comment