Advertisement
ccraftersanonmoose

rednet receive test

Feb 17th, 2023 (edited)
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.77 KB | Gaming | 0 0
  1. -- Test script to recieve a message over rednet
  2. -- written by craftersanonmosse
  3.  
  4. --------------------------------------------
  5.  
  6. mon = peripheral.find("monitor")
  7. monX, monY = mon.getSize()
  8. --wmod = peripheral.wrap("right")
  9. mon.clear()
  10.  
  11. rednet.open("right")
  12. id, message = rednet.receive()
  13.  
  14. function receiveMessage()
  15.     mon.setTextScale(1)
  16.     mon.setCursorPos(1,1)
  17.    -- mon.write(message)
  18.    centerT(message, 1, colors.lightGray, colors.blue)
  19. end
  20.  
  21. function centerT(text, line, backColor, txtColor)
  22.     mon.setBackgroundColor(backColor)
  23.     mon.setTextColor(txtColor)
  24.     length = (string.len(text))
  25.     dif = math.floor(monX - length)
  26.     x = math.floor(dif / 2)
  27.     mon.setCursorPos(x + 1, line)
  28.     mon.write(text)
  29. end
  30.  
  31.  
  32. while true do
  33.     receiveMessage()
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement