Blockland Forums > Modification Help
Any Short Tutorials for Making a Chatbot?
<< < (2/2)
Slicksilver:

--- Code: ---package derp {
function clientCmdChatMessage(%c,%a,%b,%fmsg,%cp,%name,%cs,%msg)
{
parent::clientCmdChatMessage(%c, %a, %b, %fmsg, %cp, %name, %cs, %msg);
if(getWord(%msg,0) $= "DerpBot")
derpBotParse(%name, getWords(%msg,1));
}
};
activatePackage(derp);
function derpBotParse(%name, %msg)
{
if(getWord(%msg, 0) $= "say")
commandToServer('messageSent',"DerpBot:" SPC getWords(%msg,1));
if(getWord(%msg,0) $= "help")
commandToServer('messageSent',"DerpBot: I'm a stupid, basic chatbot script. Tell me to say stuff!!");
}

--- End code ---
You're welcome
Axolotl:

--- Quote from: Slicksilver on February 16, 2012, 03:42:08 AM ---
--- Code: ---package derp {
function clientCmdChatMessage(%c,%a,%b,%fmsg,%cp,%name,%cs,%msg)
{
parent::clientCmdChatMessage(%c, %a, %b, %fmsg, %cp, %name, %cs, %msg);
if(getWord(%msg,0) $= "DerpBot")
derpBotParse(%name, getWords(%msg,1));
}
};
activatePackage(derp);
function derpBotParse(%name, %msg)
{
if(getWord(%msg, 0) $= "say")
commandToServer('messageSent',"DerpBot:" SPC getWords(%msg,1));
if(getWord(%msg,0) $= "help")
commandToServer('messageSent',"DerpBot: I'm a stupid, basic chatbot script. Tell me to say stuff!!");
}

--- End code ---
You're welcome

--- End quote ---
That is an inefficient way of doing it.

--- Code: ---package AxoBot_Client
{
function clientcmdChatMessage(%client,%b,%c,%all,%PreTag,%name,%postTag,%msg)
{
parent::clientcmdChatMessage(%client,%b,%c,%all,%PreTag,%name,%postTag,%msg);
AxoBot_Check(%name,%msg);
}
};
activatePackage(AxoBot_Client);

function AxoBot_Check(%name,%msg)
{
if(firstword(%msg) $= "^axobot")
{
%name = stripMLControlChars(%name);
%msge = restwords(%msg);
%cmd = firstWord(%msge);
%arg = restWords(%msge);
if(isFunction(%func = "axoBotCmd" @ %cmd))
call(%func, %name, %arg);
else
commandtoserver('MessageSent',"AxoBot: Command not found.");
}
}

function AxoBotCmdExample(%name,%args)
{
commandtoserver('MessageSent',"AxoBot: This is an example function, it'll kick in when somebody says ^axobot example.");
}

--- End code ---
Port:

--- Quote from: Axolotl on March 27, 2012, 10:18:03 AM ---
--- Code: ---package AxoBot_Client
{
function clientcmdChatMessage(%client,%b,%c,%all,%PreTag,%name,%postTag,%msg)
{
parent::clientcmdChatMessage(%client,%b,%c,%all,%PreTag,%name,%postTag,%msg);
AxoBot_Check(%name,%msg);
}
};
activatePackage(AxoBot_Client);

function AxoBot_Check(%name,%msg)
{
if(firstword(%msg) $= "^axobot")
{
%name = stripMLControlChars(%name);
%msge = restwords(%msg);
%cmd = firstWord(%msge);
%arg = restWords(%msge);
if(isFunction(%func = "axoBotCmd" @ %cmd))
call(%func, %name, %arg);
else
commandtoserver('MessageSent',"AxoBot: Command not found.");
}
}

function AxoBotCmdExample(%name,%args)
{
commandtoserver('MessageSent',"AxoBot: This is an example function, it'll kick in when somebody says ^axobot example.");
}

--- End code ---

--- End quote ---


--- Quote from: Axolotl on March 27, 2012, 10:18:03 AM ---That is an inefficient way of doing it.

--- End quote ---
Navigation
Message Index
Previous page

Go to full version