Author Topic: Chat Bot Help  (Read 4772 times)

activatePackage is a regular Torque function and that includes all the rules of syntax which come with it. None of the rules of syntax say anything about white space after function names or lack thereof. lol(); works just as well as lol ( ) ; works just as well as lol     (     )     ;

The only difference is human readability.

activatepackage shouldn't have a space between the actual function called and the (). pretty sure that's your problem.

I can do this if I want to, it's completely valid.

activatePackage    (     
 getActivatePackage (
                                                     getRandom         (
    0   ,
 getNumActivePackages          ( )-    1
                                            )
);

...

I'm not asking for tips as to how to make this 'better'
I'm asking as to why it won't work
Still, it doesn't hurt.

activatepackage shouldn't have a space between the actual function called and the (). pretty sure that's your problem.

The engine does not mind whitespace. Infact, this is valid: $TestVar
          =    
4
;


Its crazy, but it works. This is also valid: $TestVar=4;. No whitespace is needed AT ALL exempt in strings.

The engine does not mind whitespace. Infact, this is valid: $TestVar
          =    
4
;


Its crazy, but it works. This is also valid: $TestVar=4;. No whitespace is needed AT ALL exempt in strings.

Strings are freeform except for newline characters. You don't NEED spaces and in fact in some cases you don't want spaces in your strings. echo("Testvar1"); is just as valid as echo("Test Variable One");, one just takes less time to type a thousand thousand times for when you're debugging.

EDIT: Obviously, I'm talking about the actual return character in the script itself - all the escape characters for it and NL are all fine.

Why doesn't this work?

Why doesn't this work?
You forgot a semicolon at the end of a parent.

There is no need for two packages and parents and all that.
Code: [Select]
package ChatBotYola
{
function clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg)
{
Parent::clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg);

if($ChatBotYolaActive)
{
switch$(%msg)
{
case "Hey":
commandToServer('messageSent', "ChatBot: Hey");
}
}

if(%name $= $Pref::Player::NetName)
{
switch$(%msg)
{
case "ChatBot On":
$ChatBotYolaActive = true;

case "ChatBot Off"
$ChatBotYolaActive = false;
}
}
}
};
activatePackage(ChatBotYola);

You forgot a semicolon at the end of a parent.

There is no need for two packages and parents and all that.
Code: [Select]
package ChatBotYola
{
function clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg)
{
Parent::clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg);

if($ChatBotYolaActive)
{
switch$(%msg)
{
case "Hey":
commandToServer('messageSent', "ChatBot: Hey");
}
}

if(%name $= $Pref::Player::NetName)
{
switch$(%msg)
{
case "ChatBot On":
$ChatBotYolaActive = true;

case "ChatBot Off"
$ChatBotYolaActive = false;
}
}
}
};
activatePackage(ChatBotYola);

Wow, Well thanks a very lot mate

Still not working :/

Still not working :/
Oops, forgot a syntax error.
Code: [Select]
package ChatBotYola
{
function clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg)
{
Parent::clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg);

if($ChatBotYolaActive)
{
switch$(%msg)
{
case "Hey":
commandToServer('messageSent', "ChatBot: Hey");
}
}

if(%name $= $Pref::Player::NetName)
{
switch$(%msg)
{
case "ChatBot On":
$ChatBotYolaActive = true;

case "ChatBot Off":
$ChatBotYolaActive = false;
}
}
}
};
activatePackage(ChatBotYola);

Still not working :/
Mind trying to be specific ever?
You've said some flavor of "It isn't working, why?" about 5 times in this topic. Say "it gave me a syntax error" or "it isn't doing ______ correctly, it only does _______"

Mind trying to be specific ever?
You've said some flavor of "It isn't working, why?" about 5 times in this topic. Say "it gave me a syntax error" or "it isn't doing ______ correctly, it only does _______"
Treynolds,
The problem is it doesn't not do something or whatever.

It just completely does nothing.

Treynolds,
The problem is it doesn't not do something or whatever.

It just completely does nothing.
That would be a syntax error
*sigh*

activatepackage shouldn't have a space between the actual function called and the (). pretty sure that's your problem.

torque doesn't give a flying stuff about spaces in any place.

Quote
package ChatBotGreet
{
   function newChatHud_addLine(%text)
   {
      
      Parent::newChatHud_addLine(%text);
      if(%text $="connected.")
      {
         if($ChatBot::On)
         {
            %num = getrandom(1,5);
            commandtoserver('messagesent', "ChatBot: @ %num); //Missing a closing ".
            commandtoserver('messagesent', "ChatBot:" @ %num);//fixed.
         }
      }
   }
};
activatepackage (ChatBotGreet);

Treynolds,
The problem is it doesn't not do something or whatever.

It just completely does nothing.
If it doesn't do anything, check if it executed in the first place or execute it yourself and see if any error comes up.