cadergator10

Wireless Sender/Receiver

Sep 28th, 2021 (edited)
111
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local modemPort = 199
  2. local component = require("component")
  3. local gpu = component.gpu
  4. local event = require("event")
  5. local ser = require("serialization")
  6. local term = require("term")
  7. local computer = component.computer
  8.  
  9. local modem = component.modem
  10. local link = component.tunnel
  11.  
  12. local localAddress = nil
  13. local remoteAddress = nil
  14.  
  15. while true do
  16.   if modem.isOpen(modemPort) == false then
  17.   modem.open(modemPort)
  18.   end
  19.   local _, _, from, port, _, command, msg, address = event.pull("modem_message")
  20.   print("Received message")
  21.   if port == 0 then
  22.         print("From Link Card. ReBroadcasting :D")
  23.         remoteAddress = address
  24.         modem.broadcast(modemPort, command, msg)
  25.   else
  26.         print("From Modem. Sending to other boost right now!")
  27.         localAddress = from
  28.         link.send(command, msg, localAddress)
  29.   end
  30. end
  31.  
RAW Paste Data