Advertisement
xXm0dzXx

Untitled

Apr 8th, 2012
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
  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, test = os.pullEvent()
  37. if e == "rednet_message" then
  38. if pie == "pinged " ..channel then
  39. rednet.send(pie, "hehehoohoohaha")
  40. else
  41. local x,y = term.getSize()
  42. if messages < y then
  43. term.setCursorPos(1, messages)
  44. messages = messages +1
  45. print(test)
  46. else
  47. term.clear()
  48. term.setCursorPos(1,1)
  49. status()
  50. messages = 3
  51. term.setCursorPos(1, messages)
  52. messages = messages +1
  53. print(test)
  54. end
  55. end
  56. elseif e == "char" then
  57. local x,y = term.getSize()
  58. term.setCursorPos(1, y)
  59. chatHistory = chatHistory.. "" ..pie
  60. term.clearLine()
  61. write(chatHistory)
  62. elseif e == "key" and pie == 28 then
  63. rednet.broadcast("<" ..user.. "> " ..chatHistory)
  64. term.setCursorPos(1, messages)
  65. messages = messages +1
  66. print("<" ..user.. "> " ..chatHistory)
  67. chatHistory = ""
  68. local x,y = term.getSize()
  69. term.setCursorPos(1, y)
  70. term.clearLine()
  71. end
  72. end
  73. end
  74.  
  75. function connector()
  76. term.clear()
  77. term.setCursorPos(1,1)
  78. status()
  79. print("Logging in...")
  80. print(user.. " ["..ip.."] logged in to N-IRC!")
  81. print("Connecting to " ..channel.."...")
  82. rednet.broadcast("pinged " ..channel)
  83. id, message = rednet.receive(1)
  84. print("Connected! Joining...")
  85. rednet.broadcast("[" ..channel.. "] "..user.." joined the server!")
  86. sleep(0.5)
  87. channelID = id
  88. chatbox()
  89. end
  90.  
  91. function login()
  92. term.clear()
  93. term.setCursorPos(1,1)
  94. cPrint("NeXuS IRC \n")
  95. cPrint("Nickname: ")
  96. nick = read()
  97. cPrint("Channel: #")
  98. chan = read()
  99.  
  100. channel = "#" ..chan
  101. user = nick
  102. connector()
  103. end
  104.  
  105. login()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement