feedmecookies

pocket rednet

Mar 15th, 2022 (edited)
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. os.loadAPI("button")
  2. rednet.open("back") -- side of the
  3. -- size of the text on screen
  4. msgAmount = 20 /1
  5.  
  6.  
  7. whitelist = {18} -- ids to listen for
  8. messages = {} -- list of messages that are going to be displayed.
  9.  
  10. function close()
  11. shell.run("startup")
  12. end
  13.  
  14.  
  15. button.CreateButton(1,26,26,1,1,1,close,colors.red,"none","x")
  16.  
  17.  
  18. while true do
  19.  
  20. event,y,u,b,o = os.pullEvent()
  21. button.DrawButton()
  22. button.CheckButtons(event,u,b)
  23.  
  24. if event == "rednet_message"then
  25. for i = 1, #whitelist do
  26. if tonumber(y) == whitelist[i] then
  27. table.insert(messages, u)
  28. end
  29.  
  30. if #messages > msgAmount then
  31.  
  32. table.remove(messages,1)
  33.  
  34. end
  35. for i = 1, #messages do
  36. term.setCursorPos(1,i)
  37. term.write(messages[i])
  38. end
  39. end
  40. end
  41. end
Add Comment
Please, Sign In to add comment