645 posts
Location
'Merica
Posted 19 March 2012 - 06:11 AM
Hello, A while ago I made Chatv not knowing how do even use rednet right, lol. But now I do, and updated it to work RIGHT!
There is a pastebin link
http://pastebin.com/0XyDRMVy also, and the code also, Enjoy :)/> !
function top()
term.clear()
term.setCursorPos(1,1)
term.setTextColor(colors.purple)
print("Welcome to Chatv")
term.setTextColor(colors.gray)
print("====================================================")
end
function detectDevice(DeviceName)
DeviceSide="none"
for k,v in pairs(redstone.getSides()) do
if peripheral.getType(v)==DeviceName then
DeviceSide = v
break
end
end
return(DeviceSide)
end
top()
ModemSide=detectDevice("modem")
rednet.open(ModemSide)
term.setTextColor(colors.green)
write("Username: ")
term.setTextColor(colors.white)
local user = read()
term.clear()
term.setCursorPos(1,1)
top()
while true do
term.setTextColor(colors.lime)
write("Message: ")
term.setTextColor(colors.white)
local a = read()
rednet.broadcast(user.. ": " ..a)
id, msg = rednet.receive()
print(id.. ": is sending a message")
print(msg)
end
645 posts
Location
'Merica
Posted 19 March 2012 - 06:12 AM
You can try the code it works but just not if you want to chat with others
411 posts
Posted 19 March 2012 - 06:31 AM
while true do
local a = read()
term.write(B)
print(a)
end
123 posts
Posted 23 March 2012 - 01:31 AM
Hmmm… I think you need to open a connection first?
As in before you send messages.
http://computercraft...ednet_%28API%29
10 posts
Posted 23 March 2012 - 04:09 AM
I wanted to type more to my friend but the program ended, it needs more reads.
1111 posts
Location
Portland OR
Posted 23 March 2012 - 05:26 AM
I wanted to type more to my friend but the program ended, it needs more reads.
You shouldn't have to have more then 1 read. All you need is a while true loop like what Casper posted above, its basically an infinite loop.
while true do
local a = read()
term.write(B)
print(a)
end
74 posts
Location
Australia
Posted 23 March 2012 - 05:35 AM
so if i use this it will let me talk to other people on my map connected to each other? and how do wireless modems work?
6 posts
Posted 03 April 2012 - 01:26 AM
I found the Source of Your Problem your print the variable
a which is from another computer the variable you should be printing is message
term.setCursorPos(1,1)
rednet.open("left")
while true do
id, message = rednet.receive()
print ("The Computer Number".. id .." Has Sent You A Message")
print (message)
sleep(1)
end
where the variable ID is the computer ID and the variable message is the actual message as written in the send code :)/>/> i know I've written a program Similar to this! Which will be released :D/>/>
645 posts
Location
'Merica
Posted 27 April 2012 - 10:54 PM
(To ALL) Thanks for the feed back, sorry that i couldn't get back sooner… i really haven't used this mod since 1.31 but when it first can out, and I'm very happy to c my code worked… Yes i will use what both xXNinjaMXx and Casper7526 and upgrade my code, But for now i hope to c more feed back after i finish the new code, or add on to it. I really like the fact that i got some feed back. Really Thank you!
645 posts
Location
'Merica
Posted 27 April 2012 - 11:04 PM
I found the Source of Your Problem your print the variable
a which is from another computer the variable you should be printing is message
term.setCursorPos(1,1)
rednet.open("left")
while true do
id, message = rednet.receive()
print ("The Computer Number".. id .." Has Sent You A Message")
print (message)
sleep(1)
end
where the variable ID is the computer ID and the variable message is the actual message as written in the send code :)/>/> i know I've written a program Similar to this! Which will be released :)/>/>
I found the Source of Your Problem your print the variable
a which is from another computer the variable you should be printing is message
term.setCursorPos(1,1)
rednet.open("left")
while true do
id, message = rednet.receive()
print ("The Computer Number".. id .." Has Sent You A Message")
print (message)
sleep(1)
end
where the variable ID is the computer ID and the variable message is the actual message as written in the send code ;)/>/> i know I've written a program Similar to this! Which will be released :)/>/>
I have to say… I really made this to allow people to chat with usernames that fact when it says
print ("The Computer Number".. id .." Has Sent You A Message")
it doesn't let you know WHO is talking to you, but i like that idea. But really , its not good if you want to know you sent you the message, you would have to memorize peoples computer IDs which I wouldst want to do at all. But thanks for the feed back!
645 posts
Location
'Merica
Posted 28 April 2012 - 06:03 PM
:Edit to the last thing i said: Nvm that code would be more for a mail type chat, i like that idea, i might add that later when i can make an options bar or system to it.
2 posts
Posted 28 April 2012 - 06:04 PM
you would have to memorize peoples computer IDs which I wouldst want to do at all.
And thus DNS was invented. =P Maybe create a database system for the users? Heh maybe it's just me but that sounds like fun, I think I might go try that. :)/>/>
645 posts
Location
'Merica
Posted 28 April 2012 - 06:11 PM
you would have to memorize peoples computer IDs which I wouldst want to do at all.
And thus DNS was invented. =P Maybe create a database system for the users? Heh maybe it's just me but that sounds like fun, I think I might go try that. :)/>/>
that is what the username part in my code is for, if i used his code upabove then i you all would have to memorize your friends or other peoples computer id, which i really dont like, but it would be great for a private msg type of thing.
2 posts
Posted 28 April 2012 - 06:18 PM
Hmm, well, I like complicated things. If I were to do this, which I think I might, I would have it send a request to a designated "server" for the service. If the server has your computer's ID in it's DB it would return your username. If it didn't then it would have your computer prompt you for a username. Then it would map your username to your comp's ID on the server. When you send a message to a username, it requests the ID from the server. The server could also have a password for security and even an online/offline feature, but I'm getting ahead of myself. =P I, personally, am a Java guru, not Lua, so I don't really know what the limitations of the language are, but from what I've heard it's very flexible and you could do something like that.
645 posts
Location
'Merica
Posted 28 April 2012 - 06:33 PM
I could add the data base thing in a future update… but right now im working on the allow others to see the message the person sent, because it isnt working atm. what its doing is after one Computer sends the message the one that sends it freeze and won't unfreeze untill the other computer sends a message, but you cant even see the message.
also that code i posted is already old cuz i already add more stuff.
645 posts
Location
'Merica
Posted 04 December 2012 - 04:50 PM
UPDATED IT, RE DID IT! sorry for the caps.