Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- modem = peripheral.find("modem")
- if not modem.isOpen(1298) then
- modem.open(1298)
- end
- function Sender()
- while true do
- Send(io.read(), 1297)
- end
- end
- function Send(msg, channel)
- modem.transmit(channel, 1298, string.char(12, 97) .. msg)
- end
- function Listen()
- while true do
- local _, _, _, replyChan, m, _ = os.pullEvent("modem_message")
- if string.find(m, string.char(12, 97)) then
- local formattedMessage = string.sub(m, 3)
- print(m .. " turned into " .. formattedMessage)
- else
- Reply("This is not the modem you are looking for!", replyChan)
- end
- end
- end
- function Reply(msg, replyChannel)
- print("Reply sent to " .. replyChannel .. " with message \"" .. msg .. "\"")
- modem.transmit(replyChannel, 1297, msg)
- end
- parallel.waitForAll(Sender, Listen)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement