Advertisement
Guest User

receiving

a guest
Sep 1st, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.19 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" and mes ~= "launch" then
  8.     print("Got message")
  9.       sleep(5)
  10.     if id == 23 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.       if mes == "disarm" then
  38.         turtle.suckUp()
  39.         turtle.dropDown()
  40.       else
  41.         rs.setOutput("back",true)
  42.         sleep(5)
  43.         rs.setOutput("back",false)
  44.       end
  45.     end
  46.   end
  47. end
  48.  
  49. while true do
  50.   receiveItem()
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement