Blockland Forums > Modification Help

Bot

Pages: << < (4/4)

otto-san:

This is a simple bot script.


--- Code: ---package simpleBot
{
  function serverCmdMessageSent(%client, %text)
  {
     parent::serverCmdMessageSent(%client, %text);
     if(striPos(%text, "Hello world!") != -1) //makes it so that it isn't case sensitive
     {
        messageAll('',"\c3Bot\c6: Hello!");
     }
  }
};
activatePackage(simpleBot);
--- End code ---

VERY simple and only detects one phrase and has only one response and one name.

To add a name/message to answer simply replace some things and add some lines


--- Code: ---$botmessage = "Hello!";
$botname = "Bot";
--- End code ---

Would be BEFORE the package.

The messageAll would be replaced with this:

--- Code: ---messageAll('',"\c3"@$botname@"\c6: "@$botmessage);
--- End code ---

I would go more in-depth about working this with auto-learning, auto-speaking, etc.

But I don't feel that I need to help you, if you can code and have a logical and/or insightful brain.

Bauklotz:


--- Quote from: otto-san on March 03, 2011, 06:10:23 PM ---
--- Code: ---if(striPos(%text, "Hello world!") != -1) //makes it so that it isn't case sensitive
--- End code ---

--- End quote ---

What. TorqueScript is type-insensitive and case-insensitive (except for stuff like strReplace, striReplace, strPos, striPos, etc).

=> echo(("Hello, world" $= "Hello, world"));
1
=> echo(("hELLo, WoRlD" $= "Hello, world"));
1
=> echo(("Hello, worl" $= "Hello, world"));
0


Destiny/Zack0Wack0:


--- Quote from: Bauklotz on March 06, 2011, 03:27:51 AM ---(except for stuff like strPos, striPos)

--- End quote ---

--- Quote from: otto-san on March 03, 2011, 06:10:23 PM ---if(striPos(%text, "Hello world!") != -1) //makes it so that it isn't case sensitive

--- End quote ---


Bauklotz:


--- Quote from: Destiny/Zack0Wack0 on March 06, 2011, 03:35:31 AM ---
--- End quote ---

Why is he SEARCHING for the string? And secondly, he's saying that using the str?Pos function makes it case-insensitive.

otto-san:

OH, I see what you mean.

There's no need for the striPos there, you're right.

Pages: << < (4/4)

Go to full version