Advertisement
goldfiction

CC Glass watch all rednet communication

Sep 28th, 2023
1,128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.76 KB | None | 0 0
  1. function findAndWrap(devType)
  2.   local devices = peripheral.getNames()
  3.   for id, devName in pairs(devices) do
  4.     if peripheral.getType(devName) == devType then
  5.       return peripheral.wrap(devName)
  6.     end
  7.   end
  8. end
  9.  
  10. glass = findAndWrap("openperipheral_bridge")
  11. rednet.open("right")
  12.  
  13. function addBox()
  14.   glass.addBox(1,1,200,100,0xFFFFFF,0.2)
  15. end
  16.  
  17. function timeDis(message)
  18.   -- time = textutils.formatTime(os.time(), false)
  19.   local msg=table.concat(split(message, ","),"\n")
  20.   glass.addText(5,100, msg, 0xFF0000)
  21. end
  22.  
  23. function start()
  24.  print("watching rednet messages")
  25.  while true do
  26.     local senderId, message, protocal = rednet.receive()
  27.     glass.clear()
  28.     -- addBox()
  29.     timeDis(message)
  30.     glass.sync()
  31.     sleep(0.1)
  32.   end
  33. end
  34.  
  35. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement