Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("right")
- rednet.open("left")
- rednet.open("bottom")
- rednet.open("top")
- rednet.open("back")
- rednet.open("front")
- local channel = "";
- local user = "";
- local ip = os.computerID()
- local x2,y2 = term.getCursorPos()
- local channelID = 0;
- local chatHistory = ""
- local messages = 4;
- local function cPrint(text)
- local x,y = term.getSize()
- x2,y2 = term.getCursorPos()
- term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
- write(text)
- end
- term.clear()
- term.setCursorPos(1,1)
- function status()
- print("Status: " ..channel)
- print("--------------------------------")
- end
- function chatbox()
- term.clear()
- term.setCursorPos(1,1)
- status()
- print("[" ..channel.. "] "..user.." joined the server!")
- while true do
- local e, pie, test = os.pullEvent()
- if e == "rednet_message" then
- if pie == "pinged " ..channel then
- rednet.send(pie, "hehehoohoohaha")
- else
- local x,y = term.getSize()
- if messages < y then
- term.setCursorPos(1, messages)
- messages = messages +1
- print(test)
- else
- term.clear()
- term.setCursorPos(1,1)
- status()
- messages = 2
- term.setCursorPos(1, messages)
- messages = messages +1
- print(test)
- end
- end
- elseif e == "char" then
- local x,y = term.getSize()
- term.setCursorPos(1, y)
- chatHistory = chatHistory.. "" ..pie
- term.clearLine()
- write(chatHistory)
- elseif e == "key" and pie == 28 then
- rednet.broadcast("<" ..user.. "> " ..chatHistory)
- term.setCursorPos(1, messages)
- messages = messages +1
- print("<" ..user.. "> " ..chatHistory)
- chatHistory = ""
- local x,y = term.getSize()
- term.setCursorPos(1, y)
- term.clearLine()
- end
- end
- end
- function connector()
- term.clear()
- term.setCursorPos(1,1)
- status()
- print("Logging in...")
- print(user.. " ["..ip.."] logged in to N-IRC!")
- print("Connecting to " ..channel.."...")
- rednet.broadcast("pinged " ..channel)
- id, message = rednet.receive(1)
- print("Connected! Joining...")
- rednet.broadcast("[" ..channel.. "] "..user.." joined the server!")
- sleep(0.5)
- channelID = id
- chatbox()
- end
- function login()
- term.clear()
- term.setCursorPos(1,1)
- cPrint("NeXuS IRC \n")
- cPrint("Nickname: ")
- nick = read()
- cPrint("Channel: #")
- chan = read()
- channel = "#" ..chan
- user = nick
- connector()
- end
- login()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement