Author Topic: Whats wrong with this script?  (Read 4472 times)


uhh
Tried it and it didnt work.
Just used the last function. Most likely because there were globabl variables involved.

Bump, really need help with this.

Thank you, but I have one last question.
How do I get seperate answers? Like If I say help it gives me a help list or if I say hi it says hi?

You have to make another if %msg and edit the call-out and answer there.
For instance:

if(%msg $= "hi"){
commandToServer('messageSent',"Chatbot: Hi, "@%name);
}


And on the second new line you can type the exact thing, but changing the hi, and hi %name

if(%msg $= "(\"){
commandToServer('messageSent',"Chatbot: /)");
}

ALSO: I edited the post on my web page, it should have no errors now hopefully

Duplicate the function and edit it.
That's the worst idea I've heard in a while.

You have to make another if %msg and edit the call-out and answer there.
For instance:

if(%msg $= "hi"){
commandToServer('messageSent',"Chatbot: Hi, "@%name);
}


And on the second new line you can type the exact thing, but changing the hi, and hi %name

if(%msg $= "(\"){
commandToServer('messageSent',"Chatbot: /)");
}

ALSO: I edited the post on my web page, it should have no errors now hopefully
Thank you!
And yeah your tutorial was really helpful.

EDIT: Nothing happens now.
« Last Edit: August 16, 2013, 12:33:31 PM by Gsterman »

I get this error if I do two If(%msg things
Code: [Select]
Client checking Add-On: Client_Chatbot
Loading Add-On: Client_Chatbot
Add-Ons/Client_Chatbot/client.cs Line: 12 - Syntax error.
>>> Some error context, with ## on sides of error halt:
function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)

^{

^^parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);

^if(%msg $= "hi" || %msg $= "hello"){

^commandToServer('messageSent',"Chatbot: Hi, "@%name);

^^^^^}

^

^if(%msg $= "(\"){
##
##^commandToServer('messageSent',"Chatbot: /)");

^^^^^}

^}

};

activatepackage(chatbot);


>>> Error report complete.

ADD-ON "Client_Chatbot" CONTAINS SYNTAX ERRORS

\" doesn't close a string - it's an escaped character that adds a " to a string.
You, sir, have a problem with closing pairs. :(

EDIT 1: If you wanted '(\', you'd have to use "(\\".
EDIT 2: Also, the full list of escaped characters are as follows:

\' = '
\" = "
\\ = \
\0 = Null (A zero byte; unused in Torquescript because that's the string terminator.)
\a = Alert (BIOS beep; unused in Torquescript.)
\b = Backspace (Unused in Torquescript.)
\f = Form feed (Unused in Torquescript.)
\n = Newline (On a console, moves the cursor down one, but NOT to the start of the line.)
\r = Carriage return (On a console, moves the cursor to the start of the line, but NOT down one.)
\t = Horizontal tab
\v = Vertical quote (Unused in Torquescript.)
\u = Unicode escape sequence (Unused in Torquescript.)
\U = Exact same thing, but not (Unused in Torquescript.)
\x = ASCII character escape sequence.

So the comprehensive list of characters Torquescript allows escaping is this:
\' \" \\ \n \r \t \xHH (Two hexadecimal characters.)
Any character which TS doesn't allow escaping is unchanged, EXCEPT c, which causes a syntax error. This does NOT happen with C - because you have to remember that C and c are not a slightly changed version of the same symbol to a computer. They are COMPLETELY different symbols. To a computer, b and d are closer to c than c is to C.
« Last Edit: August 16, 2013, 01:41:58 PM by Xalos »

\" doesn't close a string - it's an escaped character that adds a " to a string.
You, sir, have a problem with closing pairs. :(

EDIT 1: If you wanted '(\', you'd have to use "(\\".
EDIT 2: Also, the full list of escaped characters are as follows:

\' = '
\" = "
\\ = \
\0 = Null (A zero byte; unused in Torquescript because that's the string terminator.)
\a = Alert (BIOS beep; unused in Torquescript.)
\b = Backspace (Unused in Torquescript.)
\f = Form feed (Unused in Torquescript.)
\n = Newline (On a console, moves the cursor down one, but NOT to the start of the line.)
\r = Carriage return (On a console, moves the cursor to the start of the line, but NOT down one.)
\t = Horizontal tab
\v = Vertical quote (Unused in Torquescript.)
\u = Unicode escape sequence (Unused in Torquescript.)
\U = Exact same thing, but not (Unused in Torquescript.)
\x = ASCII character escape sequence.

So the comprehensive list of characters Torquescript allows escaping is this:
\' \" \\ \n \r \t \xHH (Two hexadecimal characters.)
Any character which TS doesn't allow escaping is unchanged, EXCEPT c, which causes a syntax error. This does NOT happen with C - because you have to remember that C and c are not a slightly changed version of the same symbol to a computer. They are COMPLETELY different symbols. To a computer, b and d are closer to c than c is to C.
Got another error
Code: [Select]
Client checking Add-On: Client_Chatbot
Loading Add-On: Client_Chatbot
Add-Ons/Client_Chatbot/client.cs Line: 17 - Syntax error.
>>> Some error context, with ## on sides of error halt:
function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)

^{

^if(%msg $= "hi"){

^commandToServer('messageSent',"MagicBot: Hi,"@%name);

^^^^^}

^^^^^

^^^^^

^if(%msg $= "(\\"){

^commandToServer('messageSent',"MagicBot: (\\");

^^^^^}

^}

}

activatepackage(##c##hatbot);
>>> Error report complete.

ADD-ON "Client_Chatbot" CONTAINS SYNTAX ERRORS

Got another error
Code: [Select]
Client checking Add-On: Client_Chatbot
Loading Add-On: Client_Chatbot
Add-Ons/Client_Chatbot/client.cs Line: 17 - Syntax error.
>>> Some error context, with ## on sides of error halt:
function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)

^{

^if(%msg $= "hi"){

^commandToServer('messageSent',"MagicBot: Hi,"@%name);

^^^^^}

^^^^^

^^^^^

^if(%msg $= "(\\"){

^commandToServer('messageSent',"MagicBot: (\\");

^^^^^}

^}

}

activatepackage(##c##hatbot);
>>> Error report complete.

ADD-ON "Client_Chatbot" CONTAINS SYNTAX ERRORS
Close the package with };

Close the package with };
Now I cant chat :/
Whenever I chat nothing shows up.

Got another error
Code: [Select]
Client checking Add-On: Client_Chatbot
Loading Add-On: Client_Chatbot
Add-Ons/Client_Chatbot/client.cs Line: 17 - Syntax error.
>>> Some error context, with ## on sides of error halt:
function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)

^{

^if(%msg $= "hi"){

^commandToServer('messageSent',"MagicBot: Hi,"@%name);

^^^^^}

^^^^^

^^^^^

^if(%msg $= "(\\"){

^commandToServer('messageSent',"MagicBot: (\\");

^^^^^}

^}

}

activatepackage(##c##hatbot);
>>> Error report complete.

ADD-ON "Client_Chatbot" CONTAINS SYNTAX ERRORS

Close the package with a ;
Also if %msg dont put two \\s because you'll have to say (\\ instead of (\ (that's how input string works, \ is used in output only)

EDIT: Warning - while you were reading a new reply has been posted. You may wish to review your post.
fml

DOUBLEPOST: You really forgeted up the code, try this one
Also, try to format your code when you can
Code: [Select]
package chatbot
{
function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
{
   parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);

   if(%msg $= "hi"){
      commandToServer('messageSent',"MagicBot: Hi,"@%name);
   }
   if(%msg $= "(\"){
      commandToServer('messageSent',"MagicBot: (\\");
   }
}

};

activatepackage(chatbot);
« Last Edit: August 16, 2013, 02:11:23 PM by pefu19 »

Also if %msg dont put two \\s because you'll have to say (\\ instead of (\ (that's how input string works, \ is used in output only)

I think you made it MORE confusing than just leaving it at "these are the control characters, this is what changes X into Y."



DOUBLEPOST: You really forgeted up the code, try this one
if(%msg $= "(\")

You shouldn't be helping people with code if you yourself both A.) don't KNOW how to code properly yet and B.) are too lazy to CHECK it first.

I think you made it MORE confusing than just leaving it at "these are the control characters, this is what changes X into Y."



You shouldn't be helping people with code if you yourself both A.) don't KNOW how to code properly yet and B.) are too lazy to CHECK it first.

Sorry, it's late, I'm tired.