Advertisement
MuChT007

Test Rednet

Jun 23rd, 2020
830
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.11 KB | None | 0 0
  1. --Variables
  2. local version ="V0.1a"
  3. local printer = peripheral.wrap("bottom")
  4. local modem = peripheral.wrap("left")
  5. local role = "sender"
  6. local tchannel = 100
  7. local rchannel = 999
  8.  
  9. --Body Code
  10. if role == "sender" then
  11.         while true do
  12.         write("message?:   ")
  13.         message = read()
  14.         local event, key = os.pullEvent("key")
  15.         if key == keys.enter then
  16.             modem.transmit(tchannel , rchannel , message )
  17.         end
  18.     end
  19. end
  20.  
  21. if role == "reciever" then
  22.     modem.open(tchannel )
  23.     while true do
  24.         event, side, frequency, replyFrequency, message, distance = os.pullEvent("modem_message")
  25.         print("Message received from the open modem on the "..side" side of this computer.")
  26.         print("Frequency: "..frequency)
  27.         print("Requested reply frequency: "..replyFrequency)
  28.         print("Distance: "..distance)
  29.         write("Message is as follows: "..message)
  30.     end
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement