Page 1 of 1

how do make a text bar that you can talk with?

PostPosted: Sun Feb 04, 2007 1:32 am
by Kooldudese
how do you make a text bar that you can type in and then when you press enter the text comes spelling itself out?

PostPosted: Tue Feb 13, 2007 4:03 am
by Sgt. Sparky
when enter (return) is pressed. all you need to do is have this script
Code: Select all
if(strncmp(text, "Hey there", 10) < .3)
{
    strcpy(Reply.text, "hey,\nhow are you?");
}
you can use that for many, MANY phrases, but you may need to change it ALOT for complex phrases. :D I hope that helps

PostPosted: Tue Feb 13, 2007 4:05 am
by Sgt. Sparky
let me make you a better demo, I made a Base for a chatting program I will post it tomarrow. :D

PostPosted: Tue Feb 13, 2007 3:53 pm
by Fuzzy
your best bet would be to parse the words. Divide the input into words and have the program figure them out one by one. Group them into types, and build a generic sentence, or better, segments of a sentence.

For example, "hi" "hello" "hey there" "how are you" are all the same, so you reduce it to "hi" or "greet" internally. from there, you formulate a response. this way, you will not need so many ifs and cases. internally, it might look like...

"<greet> <me>" and from that, you build an response "<greet> <player> <mood>" building the stuff in <> from variables.

So you start with
"Hi there robot how are you?" and respond with "hi Fuzzy, I am fine".

This way, if i say "hi there robot" you respond "hi Fuzzy" and its the exact same code that handles it.