Actually, theres a much easier way for this, I made a function for it, you might wanna remove all the bits about clients.
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.