Advertisement
xXm0dzXx

Untitled

Apr 7th, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. rednet.open("right")
  2. rednet.open("left")
  3. rednet.open("bottom")
  4. rednet.open("top")
  5. rednet.open("back")
  6. rednet.open("front")
  7.  
  8. local channel = "";
  9. local user = "";
  10. local ip = os.computerID()
  11. local x2,y2 = term.getCursorPos()
  12. local channelID = 0;
  13. local chatHistory = ""
  14. local messages = 4;
  15. local function cPrint(text)
  16. local x,y = term.getSize()
  17. x2,y2 = term.getCursorPos()
  18. term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2+1)
  19. write(text)
  20. end
  21.  
  22. term.clear()
  23. term.setCursorPos(1,1)
  24.  
  25. function status()
  26. print("Status: " ..channel)
  27. print("--------------------------------")
  28. end
  29.  
  30. function chatbox()
  31. term.clear()
  32. term.setCursorPos(1,1)
  33. status()
  34. print("[" ..channel.. "] "..user.." joined the server!")
  35. while true do
  36. local e, pie = os.pullEvents()
  37. if e == "rednet_message" then
  38. if pie == channel then
  39. rednet.send(pie, "hehehoohoohaha")
  40. else
  41. term.setCursorPos(1, messages)
  42. messages = messages +1
  43. end
  44. elseif e == "char" then
  45. local x,y = term.getSize()
  46. term.setCursorPos(1, y)
  47. chatHistory = chatHistory.. "" ..pie
  48. write(chatHistory)
  49. elseif e == "key" and pie == 28 then
  50. rednet.send(channelID, "<" ..channel.. "> " ..chatHistory)
  51. chatHistory = ""
  52. end
  53. end
  54. end
  55.  
  56. function connector()
  57. term.clear()
  58. term.setCursorPos(1,1)
  59. status()
  60. print("Logging in...")
  61. print(user.. " ["..ip.."] logged in to N-IRC!")
  62. print("Connecting to " ..channel.."...")
  63. rednet.broadcast(channel)
  64. id, message = rednet.receive(1)
  65. print("Connected! Joining...")
  66. rednet.send(id, "[" ..channel.. "] "..user.." joined the server!")
  67. sleep(0.5)
  68. channelID = id
  69. chatbox()
  70. end
  71.  
  72. function login()
  73. term.clear()
  74. term.setCursorPos(1,1)
  75. cPrint("NeXuS IRC \n")
  76. cPrint("Nickname: ")
  77. nick = read()
  78. cPrint("Channel: #")
  79. chan = read()
  80.  
  81. channel = "#" ..chan
  82. user = nick
  83. connector()
  84. end
  85.  
  86. login()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement