Author Topic: Demoing Colored Bricks  (Read 3050 times)

Would this works?

I'm not 100% sure because I've never scripted anything before.

Code: [Select]
function serverCmdClearColorBricks(%client, %color)
{
   if(!%client.isAdmin)
      return;
   
   if($Server::BrickCount > 0)
messageAll('MsgClearBricks', "\c3" @ %client.getPlayerName() @ "\c0 cleared (color name hurr) bricks.");

   //loop through all bricks
   %groupCount = MainBrickGroup.getCount();
   for(%i = 0; %i < %groupCount; %i++)
   {
      %group = MainBrickGroup.getObject(%i);
      %count = %group.getCount();
      for(%j = 0; %j < %count; %j++)
      {
         %brick = %group.getObject(%j);

         //we're only interested in bricks...
         if(!(%brick.getType() & $TypeMasks::FxBrickAlwaysObjectType))
            continue;

         //and planted...
         if(!%brick.isPlanted)
            continue;
         
         //and not dead...
         if(%brick.isDead)
            continue;

         %brickData = %brick.getDataBlock().getID();
         if(%brickData.category $= "Bricks")
         {
            if(%brick.getColorID() == %color)
            {
               %brick.killBrick();
            }
         }
      }
   }
}
« Last Edit: March 03, 2010, 04:40:32 PM by Deathwishez »

         //that are on the ground...
         if(%brick.getDistanceFromGround() != 0)
            continue;

So only for bricks on the ground?

         //that are on the ground...
         if(%brick.getDistanceFromGround() != 0)
            continue;

         //and planted...
         if(!%brick.isPlanted)
            continue;
         
         //and not dead...
         if(%brick.isDead)
            continue;

You have an issue here.

How? That's part of the default Clear Spam Bricks function thing.

         //that are on the ground...
         if(%brick.getDistanceFromGround() != 0)
            continue;

So only for bricks on the ground?

I guess I have no preference. I can remove it if it makes more sense.

Oops, just saw that it's still set to say "White bricks"

Anyone know how to get a color's name by the color's number?

Oops, just saw that it's still set to say "White bricks"

Anyone know how to get a color's name by the color's number?
getColorIDTable(int index)
Have fun assigning a name to every color.

getColorIDTable(int index)
Have fun assigning a name to every color.

Can you stupify it for me? This is my first script, and 90% of it is default.

Oh, I thought you were someone else and expected you to know.
No, you can't get a color's name from its ID. Even with RGB there are still 16,777,216 different combinations of RGB values.

I wouldn't mind giving names to the colors. I could make it a default colorset only.

0 = red
1 = color below red.
Start naming
%count = -1;
%color[%count++] = "Red";
%color[%count++] = "color below red";

0 = red
1 = color below red.
Start naming
%count = -1;
%color[%count++] = "Red";
%color[%count++] = "color below red";

Mmkay, so how would I use the name in the center print above?

Code: [Select]
%count = -1;
%color[%count++] = "Red";
%color[%count++] = "color below red";

%db = getColorIDTable(%color);
%finalColor = %color
if(%color[%db])
    %finalColor = %color[%db];

if($Server::BrickCount > 0)
    messageAll('MsgClearBricks', "\c3" @ %client.getPlayerName() @ "\c0 cleared "@ %finalColor @" bricks.");
It will print the color name if there is no name for it

Code: [Select]
%count = -1;
%color[%count++] = "Red";
%color[%count++] = "color below red";

%db = getColorIDTable(%color);
%finalColor = %color
if(%color[%db])
    %finalColor = %color[%db];

if($Server::BrickCount > 0)
    messageAll('MsgClearBricks', "\c3" @ %client.getPlayerName() @ "\c0 cleared "@ %finalColor @" bricks.");
It will print the color name if there is no name for it

Cool, thanks. I'll try that and post pack if I have any trouble.

There appears to be a syntax error.

%db = getColorIDTable(%color);
%finalColor = %color
If(##%##color[%db])
   %finalColor = %color[%db];