O.P. RE: artificial intelligence script(close window)
okay adding any two numbers(reasnoable numbers)..
like if they say 1 + 1 my program should say 2
if (Message.match(/(^|\s+)(\*)?add(d|s)?(\*)?($|\s+)/i)!=null)
{
//i was trying to find the frikken equal sign lol ..but
var plus =Message.indexOf("+");
var value1= Message.substring(0,plus)
var value2=Message.substring(plus+1,Message.length()-1)
}
okay how does the Message.match function work
because I have
if(Message.match(/(^|\s+)(\*)?1+1?(d|s)?(\*)?($|\s+)/i)!=null)
{
ChatWnd.SendMessage("duh its 2 u moron");
}
if(Message.match(/(^|\s+)(\*)?2+2?(d|s)?(\*)?($|\s+)/i)!=null)
{
ChatWnd.SendMessage("duh its 4 u moron");
}
if(Message.match(/(^|\s+)(\*)?2+5?(d|s)?(\*)?($|\s+)/i)!=null)
{
ChatWnd.SendMessage("duh its 7 u moron");
}
but when someone says add 2 + 2
it says:
"duh its 2 u moron
duh its 7 u moron"
in other words both if statements are triggered..how do i make it match exactly or properly..
and i fixed the adding thingy up a bit but still doens't add properly.
===================
if (Message.match(/(^|\s+)(\*)?add(d|s)?(\*)?($|\s+)/i)!=null)
{
var plus =Message.indexOf("+");
var value1= Message.substring(0,plus);
var value2=Message.substring(plus+1,Message.length()-1);
var final=value1+value2;
ChatWnd.SendMessage(""+final);
}
This post was edited on 09-20-2006 at 01:45 AM by xsouldeath.
|