Blockland Forums > Modification Help
Math Chatbot
<< < (3/4) > >>
jes00:

--- Quote from: Ipquarx on October 12, 2011, 05:27:10 PM ---BLID 1337 doesn't exist genius.

--- End quote ---
How was I supposed to know that? D:

--- Quote from: Ipquarx on October 12, 2011, 05:27:10 PM ---But anyways, on topic, you may want to check who's sending the chat, to make sure other people can't spam it.

--- End quote ---
I already know how :P
otto-san:

--- Quote from: Ipquarx on October 12, 2011, 05:27:10 PM ---BLID 1337 doesn't exist genius.

--- End quote ---
Name.
PurpleMetro:

--- Quote from: Ipquarx on October 12, 2011, 05:27:10 PM ---BLID 1337 doesn't exist genius.
 
But anyways, on topic, you may want to check who's sending the chat, to make sure other people can't spam it.

--- End quote ---
Idiot. He does exist. Hes just not online anymore :(
infiniteLoop:
Wrote this really quick and did minimal testing, edit it to your liking..

package mathBot
{
   function clientCmdChatMessage(%a,%b,%c,%d,%pref,%name,%suff,%msg)
   {
      parent::clientCmdChatMessage(%a,%b,%c,%d,%pref,%name,%suff,%msg);
      if($mathbot)
      {
         if(getWord(%msg,0) $= "-math")
         {
            if(isMathQuestion(%msg))
            {
               %answer = returnAnswer(%msg);
               if(%answer)
               {
                  commandToServer('messageSent',"The answer to "@%msg@" is "@%answer@".");
               }
            }
         }
      }
   }
};
activatePackage(mathBot);


function isMathQuestion(%msg)
{
   if(strStr(%msg,"*") <= 0 || strStr(%msg,"/") <= 0 || strStr(%msg,"+") <=0 || strStr(%msg,"-") <= 0)
   {
      return true;
   }

   return false;
}

function returnAnswer(%msg)
{
   %letter = "a b c d e f g h i j k l m n o p q r s t u v w x y z";

   for(%i=0;%i<getWordCount(%letter);%i++)
   {
      %let = getWord(%letter,%i);
      %msg = strReplace(%msg,%let,"");
   }


   eval("%answer = ("@%msg@");");

   return %answer;
}
Ipquarx:
I know I have a working math chatbot, that includes a .txt file that you can fill with names of people you want to be able to use it, and it will automatically read it and if the person's name is in the .txt, it lets them use it. It's a really efficiant system, but I dont have it with me right now, I can post a bit of it when I get home.
Navigation
Message Index
Next page
Previous page

Go to full version