Blockland Forums > Modification Help
Hydrobot v. 1.1
<< < (7/7)
lordician:
I must say this code looks pretty messy.
I can't work like that. :P
Tyler66:
Shouldn't it look like this?

--- Code: ---/////////////////////////////////
/////////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);

--- End code ---
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?
MegaScientifical:

--- Quote from: Tyler66 on November 12, 2010, 07:40:46 AM ---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?

--- End quote ---

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: ---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);
--- End code ---
FOX TAIL:
Thank you Mega.
I may expand this mod later on.
For now it needs a rest
Navigation
Message Index
Previous page

Go to full version