xXm0dzXx

Untitled

May 29th, 2012
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. rednet.open("top")
  2. term.clear()
  3. term.setCursorPos(1,1)
  4.  
  5. channel = "-"
  6.  
  7. function readMsg()
  8. while true do
  9. id, msg = rednet.receive()
  10. if string.sub(msg, 1, string.len("[".. channel .."]")) == "[".. channel .."]" then
  11. print(msg)
  12. end
  13. end
  14. end
  15.  
  16.  
  17. function writeMsg()
  18. while true do
  19. term.setCursorPos(1,18)
  20. write("")
  21. input = read()
  22. term.setCursorPos(1,17)
  23. term.clearLine()
  24. write("["..channel.."] " ..input)
  25. if input == "/quit" then
  26. shell.run("clear")
  27. break
  28. elseif input == "/clear" then
  29. shell.run("clear")
  30. else
  31. rednet.broadcast("[".. channel .."] ".. input)
  32. end
  33. end
  34. end
  35.  
  36. while true do
  37. parallel.waitForAny(readMsg, writeMsg)
  38. end
Advertisement
Add Comment
Please, Sign In to add comment