Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function send(ch,repch,msg,side)
- peripheral.call(side,"transmit",ch,repch,msg)
- end
- function receive(side,ch,timeout)
- local timeoutID = os.startTimer(timeout)
- for i,j in pairs(sides) do
- for k,v in pairs(ch) do
- peripheral.call(j,"open",v)
- end
- end
- local function close()
- for i,j in pairs(side) do
- for k,v in pairs(ch) do
- peripheral.call(j,"close",v)
- end
- end
- end
- while true do
- local evt,p1,p2,p3,p4,p5 = os.pullEvent()
- if(evt == "modem_message" and p2 == ch) then close() return p1,p2,p3,p4,p5 end
- if(evt == "timer" and p1 == timeoutID) then close() return nil end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement