This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ComputerCraftFan11's profile picture

NeXuS-Chat [A ingame IRC that can Talk, receive, send, and host all at the same time! (with no lag or servers!)]

Started by ComputerCraftFan11, 08 April 2012 - 03:38 AM
ComputerCraftFan11 #1
Posted 08 April 2012 - 05:38 AM
This is a real-time server free IRC for our server.

It lets you talk, receive, send, and host at the same time!

http://pastebin.com/jKvfqiTS



Check out http://randomccraft....rc-real-time#31 if you want the full version

(This won't be updated unless your in the server)

Legal:
Spoiler

		   DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
				   Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
		   DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
  TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.

Comments/Replies: http://www.computerc...dpost__p__10962

Everything above that post is just me spamming myself
ComputerCraftFan11 #2
Posted 08 April 2012 - 06:36 AM
Update!

Check out the forums for the newest version

(fixed chat going off screen and not reseting properly)
ComputerCraftFan11 #3
Posted 08 April 2012 - 06:40 AM
ComputerCraftFan11 #4
Posted 08 April 2012 - 08:32 PM

(Incase you didn't know, my username was bob saget and "user" was already in the server before so it didn't say he joined
ComputerCraftFan11 #5
Posted 08 April 2012 - 10:19 PM
Added OP, check the post
ComputerCraftFan11 #6
Posted 08 April 2012 - 11:24 PM
Added Menu, check the post
ComputerCraftFan11 #7
Posted 08 April 2012 - 11:53 PM
Added /ping, /help, /and other commands
ComputerCraftFan11 #8
Posted 11 April 2012 - 06:17 AM
Released 1.0 with /kick and /ls (lists users)
ComputerCraftFan11 #9
Posted 22 April 2012 - 01:40 AM

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 opmode = false;
local kkmode = false;
local isChatter = false;
local deopmode = false;
local oldUser = ""
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()
local sizeX, sizeY = term.getSize()
   term.clear()
   term.setCursorPos(1,1)
   status()
   print("[" ..channel.. "] "..user.." joined the server!")
   term.setCursorPos(1, sizeY)
   term.setCursorBlink( true )
   while true do
	  local e, pie, test = os.pullEvent()
	  if e == "rednet_message" then
		 if test == "pinged " ..channel then
		    rednet.send(pie, "hehehoohoohaha")
		 else
   if(test == "["..channel.."] /op " ..user)then
    oldUser = user
    user = "@" .. user
    isChatter = true
			    rednet.broadcast("*" ..user.. " is now OP!")
			    term.setCursorPos(1, messages)
			    messages = messages +1
			    print("You are now OP!")
   elseif(test == "["..channel.."] /deop " ..user)then
			    rednet.broadcast("*" ..user.. " is no longer OP!")
    user = oldUser
    isChatter = false
			    term.setCursorPos(1, messages)
			    messages = messages +1
			    print("You are no longer OP!")
   elseif(test == "["..channel.."] /kick " ..user)then
			    rednet.broadcast("*" ..user.. " left.")
    menu()
   elseif(test == "["..channel.."] /ls")then
			    rednet.send(pie, "[List:] " ..user)
   end
		    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 = 3
			   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 or pie == 14 then
   if pie == 14 then
	 chatHistory = string.sub( chatHistory, 1, 1 ) .. string.sub( chatHistory, 1 )
   else
		 if pie == 28 then
		    if chatHistory == "/exit" then
			   rednet.broadcast("*" ..user.. " left.")
			   chatHistory = ""
			   menu()
		    elseif chatHistory == "/ping" then
				  term.setCursorPos(1, messages)
				  messages = messages +1
				  print("[" ..channel.. "] Pong")
		    elseif chatHistory == "/help" then
				  term.setCursorPos(1, messages)
				  messages = messages +1
	  if isChatter == true then
	 print("[" ..channel.. "] Commands: /help, /ping, /exit, /op, /kick, /ls")
	  else
	    print("[" ..channel.. "] Commands: /help, /ping, /exit, /ls")
	  end
		    else
			   if isChatter == true then
		 if opmode == true then
	    rednet.broadcast("["..channel.."] " ..chatHistory)
				    term.setCursorPos(1, messages)
				    messages = messages +1
				    print("["..channel.."] " ..chatHistory)
	  elseif kkmode == true then
	    rednet.broadcast("["..channel.."] " ..chatHistory)
				    term.setCursorPos(1, messages)
				    messages = messages +1
				    print("["..channel.."] " ..chatHistory)
	  elseif deopmode == true then
	    rednet.broadcast("["..channel.."] " ..chatHistory)
				    term.setCursorPos(1, messages)
				    messages = messages +1
				    print("["..channel.."] " ..chatHistory)
	  else
	    rednet.broadcast("[" ..user.. "] " ..chatHistory)
				    term.setCursorPos(1, messages)
				    messages = messages +1
				    print("[" ..user.. "] " ..chatHistory)
	  end
			   else
				 rednet.broadcast("<" ..user.. "> " ..chatHistory)
				 term.setCursorPos(1, messages)
				 messages = messages +1
				 print("<" ..user.. "> " ..chatHistory)
			   end
		    end
   end
		 end
  
   if chatHistory == "/ls" then
				 term.setCursorPos(1, messages)
				 messages = messages +1
				 print("[List:] " ..user)
				 rednet.broadcast("["..channel.."] /ls")
   end
		 chatHistory = ""
		 local x,y = term.getSize()
		 term.setCursorPos(1, y)
		 term.clearLine()
   opmode = false
   kkmode = false
   deopmode = false
   elseif e == "key" and pie == 57 then
  if chatHistory == "/op" or chatHistory == "/op " then
   opmode = true
  elseif chatHistory == "/kick" or chatHistory == "/kick " then
   kkmode = true
  elseif chatHistory == "/deop" or chatHistory == "/deop " then
   deopmode = true
  end
	  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)
   if message == "hehehoohoohaha" then
	  print("Connected! Joining...")
	  rednet.broadcast("[" ..channel.. "] "..user.." joined the server!")
	  sleep(0.5)
	  channelID = id
	  chatbox()
   else
	  print("Server not existing... Hosting")
	  print("Connected! Joining...")
	  isChatter = true
	  user = "@" ..user
	  rednet.broadcast("[" ..channel.. "] "..user.." joined the server!")
	  sleep(0.5)
	  channelID = id
	  chatbox()
   end
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
function menu()
   term.clear()
   term.setCursorPos(1,1)
   cPrint("NeXuS IRC n n")
   cPrint("1:) Loginn")
   cPrint("2:) Exit n n")
   cPrint("Selection: ")
   input = read()
   if input == "1" then
	  login()
   elseif input == "2" then
   else
	  menu()
   end
end
menu()

Added a blinking cursor
ComputerCraftFan11 #10
Posted 28 April 2012 - 08:16 PM
does anyone like it? D:
ComputerCraftFan11 #11
Posted 28 April 2012 - 11:25 PM
Let me just tell you one thing… TOO MANY REPLIES FROM THE SAME PERSON~! lol. Don't reply to yourself so many times, and update the main post with edit. Good job with the script :)/>/> (I reviewed the code but haven't tested yet.)
I'll test it soon and give you a review.

K, its cuz nobody posts here :)/>/>

Heres a quick download of 1.1 (newest version)
Spoiler

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 opmode = false;
local kkmode = false;
local isChatter = false;
local deopmode = false;
local oldUser = ""
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 test == "pinged " ..channel then
            rednet.send(pie, "hehehoohoohaha")
         else
if(test == "["..channel.."] /op " ..user)then
oldUser = user
user = "@" .. user
isChatter = true
                rednet.broadcast("*" ..user.. " is now OP!")
                term.setCursorPos(1, messages)
                messages = messages +1
                print("You are now OP!")
elseif(test == "["..channel.."] /deop " ..user)then
                rednet.broadcast("*" ..user.. " is no longer OP!")
user = oldUser
isChatter = false
                term.setCursorPos(1, messages)
                messages = messages +1
                print("You are no longer OP!")
elseif(test == "["..channel.."] /kick " ..user)then
                rednet.broadcast("*" ..user.. " left.")
menu()
elseif(test == "["..channel.."] /ls")then
                rednet.send(pie, "[List:] " ..user)
end
            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 = 3
               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 or pie == 14 then
         if pie == 28 then
            if chatHistory == "/exit" then
               rednet.broadcast("*" ..user.. " left.")
               chatHistory = ""
               menu()
            elseif chatHistory == "/ping" then
                  term.setCursorPos(1, messages)
                  messages = messages +1
                  print("[" ..channel.. "] Pong")
            elseif chatHistory == "/help" then
                  term.setCursorPos(1, messages)
                  messages = messages +1
 if isChatter == true then
print("[" ..channel.. "] Commands: /help, /ping, /exit, /op, /kick, /ls")
 else
   print("[" ..channel.. "] Commands: /help, /ping, /exit, /ls")
 end
            else
               if isChatter == true then
     if opmode == true then
   rednet.broadcast("["..channel.."] " ..chatHistory)
                    term.setCursorPos(1, messages)
                    messages = messages +1
                    print("["..channel.."] " ..chatHistory)
 elseif kkmode == true then
   rednet.broadcast("["..channel.."] " ..chatHistory)
                    term.setCursorPos(1, messages)
                    messages = messages +1
                    print("["..channel.."] " ..chatHistory)
 elseif deopmode == true then
   rednet.broadcast("["..channel.."] " ..chatHistory)
                    term.setCursorPos(1, messages)
                    messages = messages +1
                    print("["..channel.."] " ..chatHistory)
 else
   rednet.broadcast("[" ..user.. "] " ..chatHistory)
                    term.setCursorPos(1, messages)
                    messages = messages +1
                    print("[" ..user.. "] " ..chatHistory)
 end
               else
                 rednet.broadcast("<" ..user.. "> " ..chatHistory)
                 term.setCursorPos(1, messages)
                 messages = messages +1
                 print("<" ..user.. "> " ..chatHistory)
               end
            end
         end

if chatHistory == "/ls" then
                 term.setCursorPos(1, messages)
                 messages = messages +1
                 print("[List:] " ..user)
                 rednet.broadcast("["..channel.."] /ls")
end
         chatHistory = ""
         local x,y = term.getSize()
         term.setCursorPos(1, y)
         term.clearLine()
opmode = false
kkmode = false
deopmode = false
 elseif e == "key" and pie == 57 then
if chatHistory == "/op" or chatHistory == "/op " then
opmode = true
elseif chatHistory == "/kick" or chatHistory == "/kick " then
kkmode = true
elseif chatHistory == "/deop" or chatHistory == "/deop " then
deopmode = true
end
      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)
   if message == "hehehoohoohaha" then
      print("Connected! Joining...")
      rednet.broadcast("[" ..channel.. "] "..user.." joined the server!")
      sleep(0.5)
      channelID = id
      chatbox()
   else
      print("Server not existing... Hosting")
      print("Connected! Joining...")
      isChatter = true
      user = "@" ..user
      rednet.broadcast("[" ..channel.. "] "..user.." joined the server!")
      sleep(0.5)
      channelID = id
      chatbox()
   end
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

function menu()
   term.clear()
   term.setCursorPos(1,1)
   cPrint("NeXuS IRC n n")
   cPrint("1:) Loginn")
   cPrint("2:) Exit n n")
   cPrint("Selection: ")
   input = read()
   if input == "1" then
      login()
   elseif input == "2" then
   else
      menu()
   end
end

menu()
ComputerCraftFan11 #12
Posted 29 April 2012 - 12:27 AM
Review: When pressing enter to submit the message, it adds an extra space after the inputted message:
"dotsonface: Hey"
"dotsonface: Hey"
Other than that, it's great :)/>/>

Thanks, do you mean it adds a extra space after "dotsonface:" or "Hey"
ComputerCraftFan11 #13
Posted 29 April 2012 - 12:47 AM
Okay, let me explain further.
When you send the message to the server, the server takes that message broadcasts it, however. You're slapped in the face with your own message repeating the what you had just put in. Therefore, if you type in "hey!" you will see the hey you just put in (because your io.read() isn't cleared) and then a duplicate message appears right under that. If you make the program to string.find(message, nickname..":") when reading the message and exclude the message if found, then that wouldn't occur.

(From my expirience) that only happens when your chat goes off the screen. If it does that, a ChatHandler will clear the screen, but that (the clear) doesn't happen when your the only person who's chatting
ComputerCraftFan11 #14
Posted 17 May 2012 - 06:17 AM
Okay, let me explain further.
When you send the message to the server, the server takes that message broadcasts it, however. You're slapped in the face with your own message repeating the what you had just put in. Therefore, if you type in "hey!" you will see the hey you just put in (because your io.read() isn't cleared) and then a duplicate message appears right under that. If you make the program to string.find(message, nickname..":") when reading the message and exclude the message if found, then that wouldn't occur.

Sorry about spamming myself, but I updated the program.
  • I added a "> "
  • I updated the post
  • I fixed a blinker
  • I fixed backspace deleting all your text
  • I fixed the chat going off the screen
  • I fixed the bugs you posted
  • I added channels (I know I had it before, but in the other version they didn't do anything but make you OP :P/>/>)
  • I fixed your chat going in a random position when you type /exit
  • I fixed it so if you get a random message, it won't print it unless its from this same IRC and channel.
  • I got a new Avatar! ;)/>/> ! :D/>/> ! (off topic :D/>/>)
Download:
http://pastebin.com/jKvfqiTS

When I made this, i didn't know anything about string.sub, or string.find, and stuff like that. I updated the backspace with that
ComputerCraftFan11 #15
Posted 23 May 2012 - 06:37 AM
Update!
  • Fixed the cursor going behind the "> "
  • Added /clear
  • Fixed /list only listing you
  • Added a limiter, so if the chat message is too long it will replace the last 3 letters on the screen with "…"
PixelToast #16
Posted 25 May 2012 - 06:29 AM
holy crap, im going to see if i can implement this into the internet im fixing
Pwrocks5648 #17
Posted 29 September 2012 - 03:02 AM
wait is the username of the owner of your server ericrandom or a username like that? (sorry that this is offtopic i just think i know that guy)
GeniusName3 #18
Posted 23 November 2012 - 02:24 PM
AMAZING chat program bro!
ComputerCraftFan11 #19
Posted 23 November 2012 - 02:29 PM
AMAZING chat program bro!

yay thanks ;)/>/>
gknova61 #20
Posted 23 November 2012 - 02:31 PM
Is this the same as your NeXus IRC 2.0?
ComputerCraftFan11 #21
Posted 23 November 2012 - 02:52 PM
it turns out i forgot to make the thread for version 2.0 ;)/>/>
http://pastebin.com/6QfbvrBW

link ^^
ComputerCraftFan11 #22
Posted 23 November 2012 - 02:58 PM
it says attempt to call nil on lien 1

You need a computercraft with rednet installed
Tiin57 #23
Posted 23 November 2012 - 09:24 PM
ComputercraftFan11, could you maybe downsize your signature? It's a bit excessive.