jgonzales394

wireless receive

Jan 5th, 2023
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.00 KB | None | 0 0
  1. local function openRednet()
  2.     local listOfSides = rs.getSides()
  3.     for i = 1,6 do
  4.             if peripheral.isPresent(listOfSides[i]) and peripheral.getType(listOfSides[i]) == "modem" then
  5.                     rednet.open(listOfSides[i])
  6.                     return listOfSides[i]
  7.             end
  8.     end
  9. end
  10. modemOn = openRednet()
  11. if not modemOn then
  12.     print("No WIFI ModemnPress any key to return to exit")
  13.     os.pullEvent("key")
  14.     return
  15. else
  16.     print("Opened wifi on "..modemOn.." side")
  17. end
  18. local iSendingComp = 144 -- this is the ID of the sending PC
  19. local sSide = "left"
  20. local monitor = peripheral.wrap(sSide)
  21. term.redirect(monitor)
  22. term.clear()
  23. term.setCursorPos(1,1)
  24. while true do
  25.     local e,e1,e2,e3,e4,e5 = os.pullEvent()
  26.     if e == "rednet_message" and e1 == iSendingComp then
  27.             print(e2)
  28.     elseif e == "key" and e1 == 14 then --  when you press backSpace it ends the program
  29.             break
  30.     end
  31. end
  32. term.clear()
  33. term.setCursorPos(1,1)
  34. term.restore()
Add Comment
Please, Sign In to add comment