Advertisement
Guest User

receiving

a guest
Sep 1st, 2014
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.03 KB | None | 0 0
  1. rednet.open("right")
  2. chest = peripheral.wrap("front")
  3. launcher = peripheral.wrap("top")
  4.  
  5. function receiveItem()
  6.   id, mes, dis = rednet.receive()
  7.   if mes ~= "report" and mes ~= "disarm" then
  8.     print("Got message")
  9.       sleep(5)
  10.     if id == 3 then
  11.       print("Taking actions")
  12.       for i = 1, chest.getInventorySize() do
  13.         curItem = chest.getStackInSlot(i)
  14.         if curItem ~= nil then
  15.           if curItem.name == mes then
  16.             chest.pushItem("west",i,1)
  17.             turtle.select(1)
  18.             if turtle.dropUp() then
  19.               return true
  20.             else
  21.               turtle.dropDown()
  22.               return false
  23.             end
  24.           end
  25.         end
  26.       end
  27.     end
  28.   else
  29.     if mes == "report" then
  30.       toSend = launcher.getStackInSlot(1)
  31.       if toSend ~= nil then
  32.         rednet.send(id, toSend.name)
  33.       else
  34.         rednet.send(id, "EMPTY")
  35.       end
  36.     else
  37.       turtle.suckUp()
  38.       turtle.dropDown()
  39.     end
  40.   end
  41. end
  42.  
  43. while true do
  44.   receiveItem()
  45. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement