Author Topic: Get all bricks of a similar name  (Read 1779 times)

i want to be able to affect all bricks of a similar name at once. Is there any way to do this?

You'd loop through the MainBrickGroup and then each individual BrickGroup and check their NTName list (i'm not 100% sure of the variables) and create a list according to your idea of "similar".

You can also package fxDtsBrick::onPlant() and check the name of the brick for the name you're looking for if you know what name it should be in advance (say something in the script versus something input by the player). You can add all those bricks to a SimSet and then call whatever you want on them by looping through them
« Last Edit: August 16, 2013, 06:48:06 PM by DYLANzzz »

You'd loop through the MainBrickGroup and then each individual BrickGroup and check their NTName list (i'm not 100% sure of the variables) and create a list according to your idea of "similar".
How would I get those individual brickgroups though? Is there one per person or something?

How would I get those individual brickgroups though? Is there one per person or something?
MainBrickGroup includes all bricks. If you want to partition the loop checks by individual user, you have to look in the brickgroup for that user

Actually, theres a much easier way for this, I made a function for it, you might wanna remove all the bits about clients.
Code: [Select]
function brickNameToIDOwnership(%name, %client) //Find the brick called %name that %client owns, returns a list of all bricks found
{
if(!strLen(%name) || !isObject(%client))
return -1;
while((%brick = nameToID("_" @ %name)) != -1)
{
if(getBrickGroupFromObject(%brick) == getBrickGroupFromObject(%client))
%list = %list SPC %brick; //Add each brick to a list

%brickList[%brickListCount++] = %brick;
%realName[%brick] = %brick.getName(); //Remember the bricks real name
%brick.setName(""); //Set it to nothing so nameToID doesn't find it again
}
for(%i=1; %i <= %brickListCount; %i++)
%brickList[%i].setName(%realName[%brickList[%i]]); //For every brick name we changed, set it back to its real name
return trim(%list); //Trim removes the space at the beginning
}

I think theres an easier way to do this, each client has variables for each namedbrick, so you could probably use that. I'd have to look into it a little.

so it turns out mainBrickGroup just has a stuff tonne of other brickGroups in it. :I

Search, I posted something for this.. exactly...

%name = %object.getName(); // Name of brick (Will be null/"" if there is no name), each name starts with an Underscore ( _ )  _thisDASH_is_a_name
%group = %obj.getGroup(); // Brick group of brick, can also use %player.brickGroup
for(%i=0;%i<%group.NTObjectCount[%name];%i++) //For loop cycling through each brick in the brick group with it's original name
   %brick = %group.NTObject[%name,%i]; //Each brick object with the same name as %name

godspeed

Search, I posted something for this.. exactly...

%name = %object.getName(); // Name of brick (Will be null/"" if there is no name), each name starts with an Underscore ( _ )  _thisDASH_is_a_name
%group = %obj.getGroup(); // Brick group of brick, can also use %player.brickGroup
for(%i=0;%i<%group.NTObjectCount[%name];%i++) //For loop cycling through each brick in the brick group with it's original name
   %brick = %group.NTObject[%name,%i]; //Each brick object with the same name as %name

godspeed
ty