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

LeoChat - Crappy IRC-like chat program

Started by Leo Verto, 28 April 2012 - 07:29 PM
Leo Verto #1
Posted 28 April 2012 - 09:29 PM
I just wanted to share this little program I wrote for someone else on a tekkit server.
I didn't have much time and I didn't really care about making it clean and good to read. :)/>/>

Functions:
  • Multi-user support
  • Uses computer ID; so you can't disguise as someone else
  • 100% client side program, no servers required
  • Lightweight and easy to use
  • Filters incoming messages to prevent chat spam by other programs
This is actually a rewritten version of it with some modifications.
The original didn't have a channel system.

One last warning, I didn't know term.scroll() when I wrote this, so exspect it to be crappy and buggy.

term.clear()
term.setCursorPos(1,1)
while true do
write("Please enter the site of your computer the modem is attached on: ")
uModemSide = read()
term.clear()
term.setCursorPos(1,1)
if uModemSide == "left" or uModemSide == "back" or uModemSide == "right" or uModemSide == "top" then
break
else
end
end
rednet.open(uModemSide)
parallel.waitForAll(
function()
while true do
term.setCursorPos(1,18)
term.clearLine()
write("You: ")
term.setCursorPos(6,18)
uMessage = read()
rednet.broadcast("#IM"..uMessage)
end
end
,
function()
while true do
id, message = rednet.receive()
if string.find(message, "#IM") then
message = string.sub(message, 4)
term.setCursorPos(1,18)
print("You should not see this!")
term.clearLine()
write("You: ")
term.setCursorPos(1,17)
term.clearLine()
print(id..": "..message)
else
end
end
end
)
I'll probably rewrite big parts of the code, because hate my temporary solution with the "You should not see this!".

Please post feedback and suggestions on how to make it better.

License:
Edited on 14 May 2012 - 07:21 PM
Spongy141 #2
Posted 29 April 2012 - 01:02 AM
your code doesnt look like you can actually type something to someone… I see nowhere that you can type a message, i have my own chat system program, and it looks NOTHING like this , yes if you look at my topic you will see that its not done, but this doesnt look like you can type a message in the computer at all, maybe im wrong and just cant see it, but also i would like to know , what is uMessage and uModem? i never heard of it in this mod.
MysticT #3
Posted 29 April 2012 - 01:40 AM
your code doesnt look like you can actually type something to someone… I see nowhere that you can type a message, i have my own chat system program, and it looks NOTHING like this , yes if you look at my topic you will see that its not done, but this doesnt look like you can type a message in the computer at all, maybe im wrong and just cant see it, but also i would like to know , what is uMessage and uModem? i never heard of it in this mod.
You can type messages:

uMessage = read()
That part reads user input, wich then broadcast with:

rednet.broadcast("#IM"..uMessage)
uMessage and uModem are just some variables he uses.
Leo Verto #4
Posted 29 April 2012 - 03:18 AM
Thanks for commenting on my code. :)/>/>
I'll rewrite the receiving and use os.pullEvent() to make it faster and have less lag because of it checking other events.
Spongy141 #5
Posted 29 April 2012 - 05:24 PM
your code doesnt look like you can actually type something to someone… I see nowhere that you can type a message, i have my own chat system program, and it looks NOTHING like this , yes if you look at my topic you will see that its not done, but this doesnt look like you can type a message in the computer at all, maybe im wrong and just cant see it, but also i would like to know , what is uMessage and uModem? i never heard of it in this mod.
You can type messages:

uMessage = read()
That part reads user input, wich then broadcast with:

rednet.broadcast("#IM"..uMessage)
uMessage and uModem are just some variables he uses.
Oh
… well im kinda of a beginner, but i wrote a lot of programs, but mostly just password stuff and redstone type, and i never seen the uMessage and uModem before. but anyways looks like a cool program