Author Topic: Script not detecting chat {resolved}  (Read 3815 times)

Hi, I was coding myself a little script today. I got a peice of code off of this thread so my Chatbot could recognize chat. This is how it turned out: (merged with a tiny bit of my code)

Code: [Select]
package bootup
{
function NMH_Type::Send(%this)
{
%word = %this.getValue();
        %words = getWordCount(%word);
        for(%i=0;%i<%words;%i++)
        {
            %word = getWord(%message, %i);
              if(%word $= "Bootup, JSys" || %word $= "bootup, jsys" || %word $= "Bootup, jsys" || %word $= "Bootup, Jsys" || %word $= "Boot!")
              {
                  activatepackage("SystemMain");
commandToServer('messagesent',"JSys²: Booting up.");
schedule(2000, 0, "commandtoServer", 'messageSent', "Beware: This is for use only with Johnny Blockhead.");
              }
}
        }
Parent::Send(%this);
}
activatepackage("bootup");

I'd think everything would be fine, except on

Code: [Select]
Parent::Send(%this);
It said there where errors like so:
Code: [Select]
Parent:##:##Send(%this);
I know its syntax, but because it is not my code, I don't really know what is wrong with it.
Please help :/
« Last Edit: August 11, 2013, 07:42:47 PM by Johnny Blockhead »

Move the } immediately prior to the parent::send call to right after it. It closes the function before Parent::Send is called. Also, you need a semicolon after a package declaration.

Move the } immediately prior to the parent::send call to right after it. It closes the function before Parent::Send is called. Also, you need a semicolon after a package declaration.

I got syntax errors when I put the semicolon there, let me test without the semicolon

Packages must be declared with a semicolon.


Now I have ## error marks like so:

Code: [Select]
activatepackage(##"##Bootup");

Updated Code:

Code: [Select]
package bootup;
{
function NMH_Type::Send(%this)
{
%word = %this.getValue();
        %words = getWordCount(%word);
        for(%i=0;%i<%words;%i++)
        {
            %word = getWord(%message, %i);
              if(%word $= "Bootup, JSys" || %word $= "bootup, jsys" || %word $= "Bootup, jsys" || %word $= "Bootup, Jsys" || %word $= "Boot!")
              {
                  activatepackage("SystemMain");
commandToServer('messagesent',"JSys²: Booting up.");
schedule(2000, 0, "commandtoServer", 'messageSent', "Beware: This is for use only with Johnny Blockhead.");
              }
}
       
Parent::Send(%this);
}
}
activatepackage("bootup");

No, haha. The semicolon goes after the closing } for the package.

Here's a properly formatted, corrected version.

Code: [Select]
package bootup
{
    function NMH_Type::Send(%this)
    {
        %word = %this.getValue();
        %words = getWordCount(%word);
        for(%i=0;%i<%words;%i++)
        {
            %word = getWord(%message, %i);
            if(%word $= "Bootup, JSys" || %word $= "bootup, jsys" || %word $= "Bootup, jsys" || %word $= "Bootup, Jsys" || %word $= "Boot!")
            {
                activatepackage("SystemMain");
                commandToServer('messagesent',"JSys²: Booting up.");
                schedule(2000, 0, "commandtoServer", 'messageSent', "Beware: This is for use only with Johnny Blockhead.");
            }
        }
        Parent::Send(%this);
    }
};
activatepackage("bootup");
« Last Edit: August 10, 2013, 04:46:15 PM by $trinick »

Thanks, no syntax errors, but now when I say Bootup, JSys it doesn't respond with either of the said commands.


        %word = %this.getValue();

should be

        %message = %this.getValue();

        %word = %this.getValue();

should be

        %message = %this.getValue();

Still doesn't work :/

Is the code just borked?

Code: [Select]
%message = %this.getValue();
%words = getWordCount(%message);

%message doesn't appear to have been defined before getWord.

%message doesn't appear to have been defined before getWord.


Switching the two

Still doesn't work :/

Code: [Select]
package bootup
{
    function NMH_Type::Send(%this)
    {
%words = getWordCount(%word);
%message = %this.getValue();
       
        for(%i=0;%i<%words;%i++)
        {
            %word = getWord(%message, %i);
            if(%word $= "Bootup, JSys" || %word $= "bootup, jsys" || %word $= "Bootup, jsys" || %word $= "Bootup, Jsys" || %word $= "Boot!")
            {
                activatepackage("SystemMain");
                commandToServer('messagesent',"JSys²: Booting up.");
                schedule(2000, 0, "commandtoServer", 'messageSent', "Beware: This is for use only with Johnny Blockhead.");
            }
        }
        Parent::Send(%this);
    }
};
activatepackage("bootup");

No. You've mixed the order of the declaration of %message and %words.

Code: [Select]
package bootup
{
    function NMH_Type::Send(%this)
    {
        %message = %this.getValue();
        %words = getWordCount(%message);
        for(%i=0;%i<%words;%i++)
        {
            %word = getWord(%message, %i);
            if(%word $= "Bootup, JSys" || %word $= "bootup, jsys" || %word $= "Bootup, jsys" || %word $= "Bootup, Jsys" || %word $= "Boot!")
            {
                activatepackage("SystemMain");
                commandToServer('messagesent',"JSys²: Booting up.");
                schedule(2000, 0, "commandtoServer", 'messageSent', "Beware: This is for use only with Johnny Blockhead.");
            }
        }
        Parent::Send(%this);
    }
};
activatepackage("bootup");