Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local func = {}
- protocol="noProtocol"
- function func.enableNet()
- peripheral.find("modem", rednet.open)
- end
- function func.disableNet()
- peripheral.find("modem", rednet.close)
- end
- function func.setProtocol(newProt)
- protocol=newProt
- end
- function func.sendMessage(text)
- return rednet.broadcast(tostring(text),protocol)
- end
- --sendMessage("WOW")
- function func.sendMessageId(id,text)
- return rednet.send(tonumber(id),tostring(text),protocol)
- end
- --sendMessageId(1,"WOW")
- --timeout in seconds, returns nil if no message was send
- function func.receiveMessage(timeout)
- return rednet.receive(protocol,tonumber(timeout))
- end
- --local id,data=receiveMessage(10)
- return func
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement