Sivarias

CC_Compy_!MissionControl

Oct 9th, 2013
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. --!MissionControl
  2. --This is a program that effectively just receives and reports messages and displays them on a big screen
  3. monitor.clear()
  4. monitor.setCursorPos(1,1)
  5. monitor.write("This is the minion monitoring center,")
  6. monitor.setCursorPos(1,2)
  7. monitor.write("where we receive messages from minions and bases")
  8. i=4
  9. local w, h=monitor.getSize()
  10. while true do
  11. local event, modemSide, senderChannel,
  12. replyChannel, message, senderDistance = os.pullEvent("modem_message")
  13. if i>=h then
  14. monitor.clear()
  15. i=1
  16. end
  17. local l=string.len(message)
  18. local wi=w-22
  19. local wf=wi+1
  20. if senderChannel==128 then
  21. monitor.setCursorPos(1,i)
  22. if l>=wi then
  23. monitor.write("Message from Minion: "..string.sub(message,1,w))
  24. i=i+1
  25. monitor.setCursorPos(1,i)
  26. monitor.write(string.sub(message,wf))
  27. i=i+1
  28. else
  29. monitor.write("Message from Minion: "..message)
  30. i=i+1
  31. end
  32. elseif senderChannel==100 then
  33. monitor.setCursorPos(1,i)
  34. if l>=wi then
  35. monitor.write("Message from Base: "..string.sub(message,1,wi))
  36. i=i+1
  37. monitor.setCursorPos(1,i)
  38. monitor.write(string.sub(message,wf))
  39. i=i+1
  40. else
  41. monitor.write("Message from Base: "..message)
  42. i=i+1
  43. end
  44. else
  45. monitor.setCursorPos(1,i)
  46. if l>=wi then
  47. monitor.write("Message from Unknown: "..string.sub(message,1,wi))
  48. i=i+1
  49. monitor.setCursorPos(1,i)
  50. monitor.write(string.sub(message,wf))
  51. i=i+1
  52. else
  53. monitor.write("Message from Unknown: "..message)
  54. i=i+1
  55. end
  56. end
  57. end
Advertisement
Add Comment
Please, Sign In to add comment