Blockland Forums > Modification Help
Deleting bricks of a certain color
otto-san:
I mean the whole having to know all the color IDs for whatever colorset you're using.
Except all you have to know is how to count to know what the IDs are so nevermind. :o
Treynolds416:
--- Quote from: Iban on May 25, 2011, 07:57:57 PM ---not really.
--- Code: ---function descriminateBricks(%findColor, %replaceColor)
{
%killList = "";
// Loop through all brickgroups.
for(%a = 0; %a < MainBrickGroup.getCount(); %a++)
{
%bg = MainBrickGroup.getObject(%a);
// Loop through every brick in this brickgroup.
for(%b = 0; %b < %bg.getCount(); %b++)
{
%brick = %bg.getObject(%b);
// Test if the bricktype of the selected brick
if(%brick.getColorID() == %findColor)
{
%killList = setField(%str, getFieldCount(%killList), %brick.getID());
}
}
}
for(%a = 0; %a < getFieldCount(%killList); %a++)
{
%brick = getField(%killList, %a);
if(isObject(%brick))
{
if(%replaceColor $= "")
{
%brick.killBrick();
}
else
{
%brick.setColor(%replaceColor);
}
}
}
echo("Acted upon" SPC getFieldCount(%killList) SPC "Brick(s).");
}
--- End code ---
"And you're done."
--- End quote ---
What is the purpose of %replacecolor in that code?
otto-san:
--- Quote from: Treynolds416 on May 25, 2011, 08:07:43 PM ---What is the purpose of %replacecolor in that code?
--- End quote ---
If replacecolor is set to an ID, it apparently sets the brick to that color.
Iban:
--- Quote from: otto-san on May 25, 2011, 07:59:42 PM ---I mean the whole having to know all the color IDs for whatever colorset you're using.
Except all you have to know is how to count to know what the IDs are so nevermind. :o
--- End quote ---
--- Code: ---function serverCmdforgetThisColor(%client)
{
if(%client.isAdmin)
{
%player = %client.player;
if(isObject(%player))
{
%colorID = %player.getMountedImage(0).projectile.colorID;
if(%color !$= "")
{
descriminateBricks(%colorID);
%client.chatMessage("\c2That's the power of Oxyclean, baby.");
}
else
{
%client.chatMessage("\c5Take out your paint can and scroll to the color you want to annihilate.");
}
}
else
{
%client.chatMessage("\c5You must spawn first.");
}
}
else
{
%client.chatMessage("\c5You must be an admin to use this command.");
}
}
--- End code ---
And you're done.
--- Quote from: otto-san on May 25, 2011, 08:08:54 PM ---If replacecolor is set to an ID, it apparently sets the brick to that color.
--- End quote ---
That field is optional.
Thanks for quoting that entire code-block, by the way.
Treynolds416:
The script is not working correctly
Looks like you made a tiny mistake Iban, line 11 should be if(%colorID !$= "")
It also seems that the script only destroys a single brick each time you use the command.