Advertisement
Guest User

chat

a guest
Aug 1st, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | None | 0 0
  1. local ip
  2. function startup()
  3. term.clear()
  4. term.setCursorPos(1,1)
  5. print("Please Type The ID Of The Computer That your Connecting To: ")
  6. ip = tonumber(read())
  7. print("Starting to Connect")
  8. sleep(1)
  9. print(".")
  10. sleep(1)
  11. print(".")
  12. sleep(1)
  13. print(".")
  14. sleep(2)
  15. term.clear()
  16. term.setCursorPos(1,1)
  17. print("Connected -------- Info: ID: ",ip)
  18. term.setCursorPos(1,17)
  19. print("----------------------------IanChatBeta0.2---------")
  20. end
  21.  
  22. function S()
  23. rednet.open("back")
  24. msg = io.read()
  25. term.setCursorPos(1,18)
  26. rednet.send(ip, msg)
  27. print("                                                   ")
  28. term.setCursorPos(1,18)
  29. end
  30.  
  31. function R()
  32. rednet.open("back")
  33. id, message, Distance = rednet.receive()
  34. term.setCursorPos(1,2)
  35. print("                                                  ")
  36. term.setCursorPos(1,3)
  37. print("                                                  ")
  38. term.setCursorPos(1,4)
  39. print("                                                  ")
  40. term.setCursorPos(1,5)
  41. print("                                                  ")
  42. term.setCursorPos(1,2)
  43. print ("Computer ",id," Distance ", Distance, ": ",message)
  44. term.setCursorPos(1,18)
  45. end
  46.  
  47. startup()
  48. while true do
  49. parallel.waitForAny(S, R)
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement