Author Topic: Delete By Brick Color [Event/Item]  (Read 1717 times)

An even or item that, when targeted towards a brick (or all bricks connected to it/all bricks of that color) will delete it, based on it's color. Like the fillcan, only it deletes bricks of same color, rather than re-painting them.

Makes sense.
If I'm not mistaken this already exists somehow though...

It's a / command made a couple months ago, but here's a better version - just do /removeBrickColor <COLORID> where COLORID is the number of your current color. To get that, just say /coloridPls. Also, it's Super Admin only, and you can only use it every 5 seconds.

//No, this is NOT tested. Please correct me if I am incorrect. Deletes a brick of the color you specify every 50 milliseconds to prevent lag.

$Pref::Server::RemoveBrickColors::Timeout = 5000;

function serverCmdRemoveBrickColor(%client, %colorid)
{
   if(%client.isSuperAdmin)
   {
      if(!%colorid == "" || !%colorid == " ")
      {
         if(!getSimTime() - %client.removeColorTimeout < $Pref::Server::RemoveBrickColors::Timeout)
         {
            %removeCount = 0;
            %sched = 0;
            for(%i = mainBrickGroup.getCount(); %i > 0; %i--)
            {
               for(%j = mainBrickGroup.getObject(%i); %j > 0; %j--)
               {
                  if(isObject(%brick = mainBrickGroup.getObject(%i).getObject(%j)));
                  {
                     if(%brick.getColorID() == %colorid)
                     {
                        %brick.schedule(%sched += 50, delete);
                        %removeCount++;
                     }
                  }
               }
            }
            if(%removeCount == 0)
               return messageClient(%client, '', "\c6No \c3" @ %colorid SPC "\c6bricks were found.");
            else
               messageAll('MsgClearBricks', "\c4" @ %client.getPlayerName() SPC "\c6removed all \c0" @ %colorid SPC "\c6colored bricks!");
         }
         else
         {
            %time = $Pref::Server::RemoveBrickColors::Timeout - (getSimTime() - %client.removeColorTimeout);
            %time = %time SPC %time > 1 ? "seconds" : "second";
            return messageClient(%client, '', "\c6You must wait another \c3" SPC %time SPC "to use the command again.");
         }
      else
         return messageClient(%client, '', "\c6Please enter a colorid to remove.");
      }
   }   
   else
      return messageClient(%client, '', "\c6You must be \c2Super Admin \c6to use this command.");
}

function serverCmdColorIDPls(%c)
{
   messageClient(%c, '', "\c6Please move your paint can around and then back to the color you want.");
   schedule(2000, 0, messageClient, %c, '', "\c6Your paint color is \c3" @ %c.currentColor);
}


Also, side note to coders - I can put an object calling a method in a schedule, correct? (eg %this.delete?)
« Last Edit: July 18, 2014, 08:08:20 AM by Cruxeis »

Also, side note to coders - I can put an object calling a method in a schedule, correct? (eg %this.delete?)
No. You can either do %this.schedule(%time, delete); or schedule(%time, %this, delete);

No. You can either do %this.schedule(%time, delete); or schedule(%time, %this, delete);
I'm pretty sure the second one doesn't work.

I'm pretty sure the second one doesn't work.
But... isn't that what the argument is for?

But... isn't that what the argument is for?
It's for nothing, I think