Author Topic: Chatbot Help  (Read 2341 times)

Also, I was thinking about making a client-side RPG with my chatbot, and I thought I was obviously going to need another .cs for my list of arrays to include in the rpg. Is there a way I can import arrays from another .cs into the client.cs?

Also, I was thinking about making a client-side RPG with my chatbot, and I thought I was obviously going to need another .cs for my list of arrays to include in the rpg. Is there a way I can import arrays from another .cs into the client.cs?
Just use global variables.

Just use global variables.
Okay, but to make them, I'm going to need way for my Chatbot to check input sent from my chat, please help Luggy :c

arrays /are/ variables in torquescript

also, metro

suppose you build your rpg like this:
$AlchemyBot::RPG::(stuffhere)

just do export("$AlchemyBot::RPG::*", "config/alchemyrpg.cs");

then, to load the data, do exec("config/alchemyrpg.cs");

arrays /are/ variables in torquescript

also, metro

suppose you build your rpg like this:
$AlchemyBot::RPG::(stuffhere)

just do export("$AlchemyBot::RPG::*", "config/alchemyrpg.cs");

then, to load the data, do exec("config/alchemyrpg.cs");
thanks luggy c:
but still, how do I input data to my Chatbot script by chat using the case system you posted

thanks luggy c:
but still, how do I input data to my Chatbot script by chat using the case system you posted
You can't, you have to go back to if...else

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(%name !$= $Pref::Player::NetName)
return;
if(%msg $= "Alchbot, Test Active")
{
commandToServer('messageSent',"[AlchBot]: Activity Test Succeed!");
}
else if(getWords(%msg, 0, 5) $= "Alchbot, generate a random number between" && getWord(%msg, 0, 7) $= "and" && getWordCount(%msg) == 9)
{
%a = getWord(%msg,6);
%b = getWord(%msg,8)
%c = getRandom(%a,%b);
commandToServer('messageSent',"[Alchbot]: The number returned was " @ %c);
}
}
};
activatePackage(Chatbot);

You can't, you have to go back to if...else

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(%name !$= $Pref::Player::NetName)
return;
if(%msg $= "Alchbot, Test Active")
{
commandToServer('messageSent',"[AlchBot]: Activity Test Succeed!");
}
else if(getWords(%msg, 0, 5) $= "Alchbot, generate a random number between" && getWord(%msg, 0, 7) $= "and" && getWordCount(%msg) == 9)
{
%a = getWord(%msg,6);
%b = getWord(%msg,8)
%c = getRandom(%a,%b);
commandToServer('messageSent',"[Alchbot]: The number returned was " @ %c);
}
}
};
activatePackage(Chatbot);
Still wont work. If I use that way, none of the commands work. Only Lugnut's case command works. :(
« Last Edit: July 27, 2012, 05:12:13 PM by PurpleMetro »


Still wont work. If I use that way, none of the commands work. Only Lugnut's case command works. :(
At least try it, because you said IF you use it that way.

At least try it, because you said IF you use it that way.
Tried it, none of the commands work.

A small syntax error. Tip: when something doesn't work, look at the console. In this case, you would have seen a bunch of read text, and you would have at least had an idea why it didn't work


Code: [Select]
package Chatbot
{
function clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg)
{
echo("recived");
parent::clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg);
if(%name !$= $Pref::Player::NetName)
return;
echo("name right");
if(%msg $= "Alchbot, Test Active")
{
commandToServer('messageSent',"[AlchBot]: Activity Test Succeed!");
}
else if(getWords(%msg, 0, 5) $= "Alchbot, generate a random number between" && getWord(%msg, 7) $= "and" && getWordCount(%msg) == 9)
{
echo("right");
%a = getWord(%msg,6);
%b = getWord(%msg,8);
%c = getRandom(%a,%b);
commandToServer('messageSent',"[Alchbot]: The number returned was " @ %c);
}
}
};
activatePackage(Chatbot);

EDIT: Another fix. The condition for the random number gen that Ipquarx posted contained multiple errors
« Last Edit: July 27, 2012, 05:26:46 PM by Headcrab Zombie »

A small syntax error. Tip: when something doesn't work, look at the console. In this case, you would have seen a bunch of read text, and you would have at least had an idea why it didn't work


Code: [Select]
package Chatbot
{
function clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg)
{
echo("recived");
parent::clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg);
if(%name !$= $Pref::Player::NetName)
return;
echo("name right");
if(%msg $= "Alchbot, Test Active")
{
commandToServer('messageSent',"[AlchBot]: Activity Test Succeed!");
}
else if(getWords(%msg, 0, 5) $= "Alchbot, generate a random number between" && getWord(%msg, 7) $= "and" && getWordCount(%msg) == 9)
{
echo("right");
%a = getWord(%msg,6);
%b = getWord(%msg,8);
%c = getRandom(%a,%b);
commandToServer('messageSent',"[Alchbot]: The number returned was " @ %c);
}
}
};
activatePackage(Chatbot);

EDIT: Another fix. The condition for the random number gen that Ipquarx posted contained multiple errors
Thanks for fixing it, but the generate command doesn't work, and I don't see an error list when it was loading the add-on.

I edited the code a little bit after I posted, copy that, it works for me

I edited the code a little bit after I posted, copy that, it works for me
Oh my god Zombie, I love you from now on.

I edited Alchbot a little, I wanted to add in support for adding numbers
Code: [Select]
package Chatbot
{
function clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg)
{
echo("recived");
parent::clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg);
if(%name !$= $Pref::Player::NetName)
return;
echo("name right");
if(%msg $= "Alchbot, Test Active")
{
commandToServer('messageSent',"[AlchBot]: Activity Test Succeed!");
}
else if(getWords(%msg, 0, 5) $= "Alchbot, generate a random number between" && getWord(%msg, 7) $= "and" && getWordCount(%msg) == 9)
{
echo("right");
%a = getWord(%msg,6);
%b = getWord(%msg,8);
%c = getRandom(%a,%b);
commandToServer('messageSent',"[Alchbot]: The number returned was " @ %c);
}
else if(getWords(%msg, 0, 1) $= "Alchbot, subtract" && getWord(%msg, 3) $= "from" && getWordCount(%msg) == 4)
{
echo("right");
%a = getWord(%msg,2);
%b = getWord(%msg,5);
%c = %a - %b;
commandToServer('messageSent',"[Alchbot]: The number returned was " @ %c);
}
else if(%msg $="Alchbot, Update")
{
exec("Add-Ons/Client_AlchBot/client.cs");
commandToServer('messageSent',"[Alchbot]: Systems updated.
}
}
}
};
activatePackage(Chatbot);
Unfortunately, as always, it didn't work. It reports an error report in the console but I don't know what it means.

Post the error here so we can tell you what it means so you can learn.