Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function receive()
- print( "Receiving on channel: "..channel )
- modem.open( channel )
- local e, s, c, r, message, dist = os.pullEvent("modem_message")
- print(">"..message)
- print(" ("..dist.." m away)")
- end
- function getInput()
- --global channel
- print( "Ready to transmit on channel: "..channel)
- nextline=""
- while nextline ~= "/quit" do
- io.write("\n:")
- nextline = io.read()
- -- todo - break long messages
- modem.transmit(channel,channel, nextline)
- end
- print("Exiting.")
- end
- print("What channel are you connecting to?")
- txtchannel = io.read()
- channel = tonumber(txtchannel)
- -- todo - input validation
- print("Where is the modem?")
- print(" (right, left, top, bottom, front, back)")
- side = io.read()
- -- todo - input validation
- modem = peripheral.wrap(side)
- parallel.waitForAny(receive,getInput)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement