MoleDirect
Technical User
have a chat window much like MSN Messenger I made in flash, and I am trying to get it to be able to carry on a conversation with the user... Keep in mind that this script is attached to a button, user field is where the user types, and reply is where they see their reply.
this chat is suposed to be able to keep a small conversation with a child, and I use 1 and 2 letter variables to help control the bot to tell it where it should be in the conversation. If you read over the source, it should give you some idea on where I am trying to go with it...
The problem it, the variable Q is not progressing to 1, it is staying on 0.
Here is the source...
this chat is suposed to be able to keep a small conversation with a child, and I use 1 and 2 letter variables to help control the bot to tell it where it should be in the conversation. If you read over the source, it should give you some idea on where I am trying to go with it...
The problem it, the variable Q is not progressing to 1, it is staying on 0.
Here is the source...
Code:
on (release, keyPress "<Enter>") {
_root.reply.htmltext = _root.reply.htmltext+"<b>"+kname.text+": </b>"+_root.user.text;
_root.user.saveText = _root.user.text.toLowerCase();
function respond() {
/*************************************************************************************************/
/*
Q = main question database
x = Has santa asked user what they would like for christmas
1 = Yes
0 = no
xa = Has the previous question been answered?
1 = Yes
0 = no
z = Has Santa asks for users fav reindeer
1 = Yes
0 = no
za = Has the previous question been answered?
1 = Yes
0 = no
gb = Has Santa asked is user was good
1 = Yes
0 = no
gba = Has the previous question been answered?
1 = Yes
0 = no
*/
trace("Q is "+Q);
if (Q == 0) {
if (bg = 0){
//_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> Have you been good this year?";
_root.status.text = "";
gb == 1;
}
else
if (_root.user.saveText.indexOf("yes") != -1 || _root.user.saveText.indexOf("yeah") != -1 || _root.user.saveText.indexOf("yup") != -1 || _root.user.saveText.indexOf("yea") != -1 || _root.user.saveText.indexOf("sure") != -1 || _root.user.saveText.indexOf("yah") != -1) {
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> Great, that’s what my list tells me! Let’s make up your Christmas list! :)";
_root.status.text = "";
Q = 1;
gba == 1;
gotoAndPlay(11);
} else
if (_root.user.saveText.indexOf("no") != -1 || _root.user.saveText.indexOf("nah") != -1 || _root.user.saveText.indexOf("not") != -1 || _root.user.saveText.indexOf("nope") != -1 || _root.user.saveText.indexOf("na") != -1) {
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> I'm sorry to hear that but, according to my list, I think you have been very nice this year and I would still like to give you something special. Lets make a Christmas list! :)";
_root.status.text = "";
Q = 1;
gba == 1;
gotoAndPlay(11);
} else
trace("Q currently equals "+Q);
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> Im sorry, I did'nt understand what you said, have you been good this year?";
Q = 0;
gb == 1;
gba == 0;
gotoAndPlay(11);
}
else
if (Q == 1) {
if (x=0){
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> What would you like for Christmas this year?";
_root.status.text = "";
x=1;
}
var randNum=Math.round(Math.random()*10)
if (randNum==0) {
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> Got it! What else would you like?";
_root.status.text = ""; }
if (randNum==1) {
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> That is popular this year, what else would you like?";
_root.status.text = ""; }
if (randNum==2) {
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> Wonderful, what else would you like?";
_root.status.text = ""; }
if (randNum==3) {
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> Jotted on my list, what else would you like?";
_root.status.text = ""; }
if (randNum==4) {
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> Very nice, what else would you like?";
_root.status.text = ""; }
if (randNum==5) {
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> Great, what else would you like?";
_root.status.text = ""; }
if (randNum==6) {
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> That is a popular request this year! What else would you like?";
_root.status.text = ""; }
if (randNum==7) {
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> Good choice! What else would you like?";
_root.status.text = ""; }
if (randNum==8) {
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> Very nice, what else would you like?";
_root.status.text = ""; }
if (randNum==9) {
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> Wonderful idea, what else would you like?";
_root.status.text = ""; }
// Q 1 EXIT CODE START
if (_root.user.saveText.indexOf("quit") != -1 || _root.user.saveText.indexOf("exit") != -1 || _root.user.saveText.indexOf("imdone") != -1 || _root.user.saveText.indexOf("nomore") != -1 || _root.user.saveText.indexOf("nothing") != -1 || _root.user.saveText.indexOf("done") != -1 || _root.user.saveText.indexOf("finished") != -1 || _root.user.saveText.indexOf("complete") != -1 || _root.user.saveText.indexOf("all") != -1) {
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> • We have quite a list! Before I close my book, is there anything else you would like me to add?";
y=1;
}
if ( y = 1 && _root.user.saveText.indexOf("no") != -1 || _root.user.saveText.indexOf("nah") != -1 || _root.user.saveText.indexOf("not") != -1 || _root.user.saveText.indexOf("nope") != -1 || _root.user.saveText.indexOf("na") != -1 || _root.user.saveText.indexOf("done") != -1 || _root.user.saveText.indexOf("finished") != -1 || _root.user.saveText.indexOf("complete") != -1 || _root.user.saveText.indexOf("all") != -1) {
_root.status.text = "";
Q = 3;
X = 1;
gotoAndPlay(11);
}
else if ( y = 1 && _root.user.saveText.indexOf("yes") != -1 || _root.user.saveText.indexOf("yeah") != -1 || _root.user.saveText.indexOf("yup") != -1 || _root.user.saveText.indexOf("yea") != -1 || _root.user.saveText.indexOf("sure") != -1 || _root.user.saveText.indexOf("yah") != -1) {
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> What would you like for Christmas this year?";
Q = 1;
x = 1;
}
// Q 1 EXIT CODE START
}else
if (Q == 3) {
if ( z = 0 ) {
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> Tell me who your favorite reindeer is and I will tell you a little about them.";
z = 1;
} else if ( z = 1 ) {
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> What other reindeer would you like to know about?.";
z = 1;
}
if (_root.user.saveText.indexOf("Dasher") != -1)
{
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> Did you know Dasher was the first reindeer and the right-hand leader of the sleigh before Rudolph was included? He is the speediest reindeer.";
_root.status.text = ""; } else
if (_root.user.saveText.indexOf("Dancer") != -1)
{
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> Did you know Dasher was the second reindeer and the left leader before Rudolph was included? She is the graceful reindeer.";
_root.status.text = ""; } else
if (_root.user.saveText.indexOf("Prancer") != -1)
{
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> Did you know Prancer was the third reindeer and on the right in the second row. He is the most powerful reindeer.";
_root.status.text = ""; } else
if (_root.user.saveText.indexOf("Vixen") != -1)
{
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> Did you know Vixen was the fourth reindeer and on the left-hand side in the second row? She is beautiful and also powerful like her companion Prancer.";
_root.status.text = ""; } else
if (_root.user.saveText.indexOf("Comet") != -1)
{
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> Did you know Comet was the fifth reindeer and on the right-hand side in the third row. He brings wonder and happiness to children when we fly over everyone's houses.";
_root.status.text = ""; } else
if (_root.user.saveText.indexOf("Cupid") != -1)
{
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> Did you know Cupid was the sixth reindeer and on the left-hand side in the third row. She brings love and joy to children when we fly over everyone's houses.";
_root.status.text = ""; } else
if (_root.user.saveText.indexOf("Donner") != -1)
{
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> Did you know Donner was the seventh reindeer and on the right-hand side in the fourth row. His original name was Dunder, a variant of donder, meaning 'thunder' in Dutch.";
_root.status.text = ""; } else
if (_root.user.saveText.indexOf("Blitzen") != -1)
{
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> Did you know Blitzen was the eighth reindeer and on the left-hand side in the fourth row. Though female, she is frequently thought to be male. Her original name is Blixem. She is known as the lightning reindeer because the word 'Blitz' is German for lightning, as is 'Bliksem', her original name, in Dutch.";
_root.status.text = ""; } else
if (_root.user.saveText.indexOf("Rudolph") != -1)
{
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> Did you know Rudolph was the son of Donner, and was born with a glowing red nose, which made him an outcast among the other reindeer? I remember one Christmas eve it was too foggy for me to make my flight around the world. I suddenly noticed Rudolph's nose, and decided it could be a guide for my sleigh. Since then Rudolph has been a permanent member of my team, and leads us on our way.";
_root.status.text = ""; } else
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> I don't remember that reindeer. My reindeer are Dasher, Dancer, Prancer, Vixen, Comet, Cupid, Donner, Blitzen and Rudolph. ";
}else {
trace(" SCRIPT PROBLEM, Q IS OUT OF RANGE. Q CURRENTLY IS "+Q);
trace(" CLOSE PROGRAM!");
}
/* Repository Stuff
if (_root.user.saveText.indexOf("hi") != -1 || _root.user.saveText.indexOf("hello") != -1) {
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> Hi! How are ya?";
_root.status.text = "";
} else if (_root.user.saveText.indexOf("bye") != -1 || _root.user.saveText.indexOf("later") != -1) {
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b>Good chatting with you!";
_root.status.text = "";
} else {
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> I do not understand";
_root.status.text = "";
}
*/
/*************************************************************************************************/
clearInterval(myTimer);
}
var i = 5000;
_root.status.text = "Santa Claus is typing...";
myTimer = setInterval(respond, i);
gotoAndPlay(11);
_root.reply.scroll = _root.reply.scroll*2;
}
/* ORIGINAL SCRIPT:
if (_root.user.saveText.indexOf("hi") != -1 || _root.user.saveText.indexOf("hello") != -1) {
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> Hi! How are ya?";
_root.status.text = "";
} else if (_root.user.saveText.indexOf("bye") != -1 || _root.user.saveText.indexOf("later") != -1) {
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b>Good chatting with you!";
_root.status.text = "";
} else {
_root.reply.htmltext = _root.reply.htmltext+"<b>Santa Claus: </b> I do not understand";
_root.status.text = "";
}
*/