Author Topic: Way to display chat messages?  (Read 1770 times)

The script that I previously used for this stopped working suddenly, so I would like to know if there are any ways to display a chat message
any other way than messageall or commandtoserver or messageclient?

what code isn't working

what code isn't working
this code
Code: [Select]
//MagicalTrafficConeRobot
//20053

package rulebot
{
function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
    {
parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);

if(%msg $= ">Hello world!")
{
commandToServer('commandSent',"Rulebot: Hello, "@%name);
}
}
};
activatepackage(rulebot);
This normally does, and did do something.
Then I came on yesterday and it won't do anything when i say ">hello world!"
I actually made this from scratch after my old one broke yesterday

« Last Edit: November 30, 2013, 04:21:58 PM by Lugnut »

use trace(1) and explore

http://forum.blockland.us/index.php?topic=191941.0
I cant find whats wrong with it.
The thing is that it worked perfect before yesterday, and then when I started blockland that day it wouldnt do anything.
« Last Edit: November 30, 2013, 04:36:44 PM by Gsterman »

The issue lies in this line:

Code: [Select]
commandToServer('commandSent',"Rulebot: Hello, "@%name);
If your aim is to send a chat message to the server you're on, you should be passing the first parameter in commandToServer, 'messageSent', or, 'teamMessageSent' if you want to send the message to your team.

The issue lies in this line:

Code: [Select]
commandToServer('commandSent',"Rulebot: Hello, "@%name);
If your aim is to send a chat message to the server you're on, you should be passing the first parameter in commandToServer, 'messageSent', or, 'teamMessageSent' if you want to send the message to your team.
Thank you so much! The tutorial I used said to put commandsent, so I put that.

Okay, I have another question, how would I make the player randomly jump/move?

bump

EDIT: Would I do


if(%msg $= ":random")
   {
   getRandom(1,4);

        %1 = turnleft(1);
        %2 = turnleft(0);
        %3 = turnright(1);
        %4 = turnright(0);
   }
« Last Edit: November 30, 2013, 10:17:54 PM by Gsterman »

bump

EDIT: Would I do


if(%msg $= ":random")
   {
   getRandom(1,4);

        %1 = turnleft(1);
        %2 = turnleft(0);
        %3 = turnright(1);
        %4 = turnright(0);
   }
Step 1. Variables can't be numbers
Code: [Select]
if(%msg $= ":random")
{
getRandom(1,4);

        %a = turnleft(1);
        %b = turnleft(0);
        %c = turnright(1);
        %d = turnright(0);
}
Step 2. The name of the variable doesn't change
Code: [Select]
if(%msg $= ":random")
{
getRandom(1,4);

        %a = turnleft(1);
        %a = turnleft(0);
        %a = turnright(1);
        %a = turnright(0);
}
Step 3. Learn to use if statements
Code: [Select]
if(%msg $= ":random")
{
getRandom(1,4);

        if(%a ==1)
               turnleft(1);
        if(%a == 2)
               turnleft(0);
        if(%a == 3)
                turnright(1);
        if(%a == 4)
               turnright(0);
}
Step 4. Set the variable from the result of the getRandom function
Code: [Select]
if(%msg $= ":random")
{
%a = getRandom(1,4);

        if(%a ==1)
               turnleft(1);
        if(%a == 2)
               turnleft(0);
        if(%a == 3)
                turnright(1);
        if(%a == 4)
               turnright(0);
}
« Last Edit: November 30, 2013, 10:33:56 PM by DrenDran »

if(%msg $= ":random")
{
   %chCount = -1;
   %ch[%chCount++] = "left";
   %ch[%chCount++] = "right";
   
   %boolCount = -1;
   %bool[%boolCount++] = 1;
   %bool[%boolCount++] = 0;
   
   
   call("turn" @ %ch[getRandom(0,%chCount)], %bool[getRandom(0,%boolCount)]);
}


/shades
« Last Edit: November 30, 2013, 11:04:06 PM by elm »

if(%msg $= ":random")
{
   %chCount = -1;
   %ch[%chCount++] = "left";
   %ch[%chCount++] = "right";
   
   %boolCount = -1;
   %bool[%boolCount++] = 1;
   %bool[%boolCount++] = 0;
   
   
   call("turn" @ %ch[getRandom(0,%chCount)], getRandom(%bool[getRandom(0,%boolCount)]));
}


/shades
I want one where it loops, so basically it moves like a bot

if(%msg $= ":random")
{
   %a = getRandom(1,4);
   turnLeft(%a % 2);
}

I think that's a bit too advanced for you. You're going to have to utilize schedules and a bit of logic to pull that off. With your current knowledge in the programming world, this would prove quite difficult. You should start with something a little simpler.

If you do want to tackle this, then just keep asking questions here and maybe someone will take the time to teach you how to do the specifics on whatever you're trying to accomplish.

I think that's a bit too advanced for you. You're going to have to utilize schedules and a bit of logic to pull that off. With your current knowledge in the programming world, this would prove quite difficult. You should start with something a little simpler.

If you do want to tackle this, then just keep asking questions here and maybe someone will take the time to teach you how to do the specifics on whatever you're trying to accomplish.
I think that I will work on torque a bit more, learn how to be more advanced at it, then ill probably come back to this later.
But thank you for the help.