Author Topic: Hydrobot v. 1.1  (Read 2424 times)

I must say this code looks pretty messy.
I can't work like that. :P

Shouldn't it look like this?
Code: [Select]
/////////////////////////////////
/////////hydrobot v.1////////////
/////////////////////////////////
package EnterGame
{

      function gameConnection::onClientEnterGame(%this)
        {
                parent::onClientEnterGame(%this);
                messageClient(%this, '', "\c3Server is running Hydraulic's chatbot Mod Version 2.5");
         }

};

activatepackage(EnterGame);

package woot
{
function servercmdmessagesent(%client,%message)
{
                parent::serverCmdMessageSent(%client,%message);
if(strlwr(getSubStr(%message,0,2)) $= "hi")
{
messageall('',"\c3Hydrobot\c6: Hey there.");
}
//moved
}
};
activatepackage(woot);

package Hydrobot
{
function servercmdmessagesent(%client,%message)
{
                parent::serverCmdMessageSent(%client,%message);
if(strlwr(getSubStr(%message,0,2)) $= "I hate hyrobot")
{
messageall('',"\c3Hydrobot\c6: I hate you more.");
}
//moved
}
};
activatepackage(Hydrobot);
This is somewhat of what I used for ElegectBot's coding. Its all in a pattern. And if you where trying to do your own coding on the "Hydrobot package", why reinvent the wheel?

Shouldn't it look like this?

-snip-

This is somewhat of what I used for ElegectBot's coding. Its all in a pattern. And if you where trying to do your own coding on the "Hydrobot package", why reinvent the wheel?

There's many problems in that code. Varying, but I'll fix it. Not sure it's what he wants, though. I'll edit this post with my version and a short list of corrections.

Edit: The major problem is you tried working off his really badly made code on the topic post instead of using the code on the other pages. There's too many packages, and he was making separate packages for each part of his code. There's no real reason to announce the bot, especially when spawned, but I don't remember the right join command to package there. To reduce the chance of additions to the code looking inconsistent, I made a separate response command that has the name format already. The responses can be bypassed, but there's no way to prevent that.

Meh.

Code: [Select]
function findWord(%text, %word) {
for(%i = 0;%i <= getWordCount(%text); %i++)
if(getWord(%text, %i) $= %word)
return %i;
return -1;
}

function HydrobotRespond(%t) {
chatMessageAll("", "\c3Hydrobot\c6: %1", %t);
}

package Hydrobot {
function GameConnection::onClientEnterGame(%this) {
Parent::onClientEnterGame(%this);
chatMessageClient(%this, '', "\c3Server is running Hydraulic's chatbot Mod Version 2.5");
}

function serverCmdMessageSent(%client, %message) {
Parent::serverCmdMessageSent(%client, %message);
if(strStr(%message, "hydro") > -1) {
if(findWord(%message) $= "hi")
HydrobotRespond("Hey there.");
else if(findWord(%message, "hate") > -1 && findWord(%message, "hydrobot") > findWord(%message, "hate"))
HydrobotRespond("I hate you more" SPC %client.name @ ".");
}
}
};
activatepackage(Hydrobot);
« Last Edit: November 12, 2010, 01:21:23 PM by MegaScientifical »

Thank you Mega.
I may expand this mod later on.
For now it needs a rest