Author Topic: How to find a brick with a name.  (Read 2202 times)

I want to find a brick, or more specifically, a group of bricks using code, and filtering it by inputting a name in the code. How would I do this.

And also, how would I set all bricks on the server to have a specific name that I inputted in the code? I want to know this so I can load, and clear a specific group of bricks for my project

Inside the brick group, there is a list of bricks with their names, as such:
Code: [Select]
NTObject_brickname_0 = brickID
NTObjectCount_brickname = 1
Code: [Select]
NTObject_brickname_0 = brickID
NTObject_brickname_1 = brickID
NTObject_brickname_2 = brickID
NTObjectCount_brickname = 3

This is how you do something to each brick:
Code: [Select]
%group = ;
%name  = "_brickname";
%count = %group.NTObjectCount[%name];
for(%a = 0; %i < %count; %a++)
{
    %brick = %group.NTObject[%name, %i];
}

blah blah
Code: [Select]
%group = BrickGroup_8448;
%name  = "test";
%count = %group.NTObjectCount[%name];
for(%a = 0; %i < %count; %a++)
{
    %brick = %group.NTObject[%name, %i];
}

Is this how I would do that? I'm not sure what this code performs though. I did a little test. My brickname is hi, so i put it in this code
Code: [Select]
echo(BrickGroup_8448.NTObject_hi_0);
It does nothing though. I was thinking the top code would change all the names of my bricks to the variable, but it didn't. What am I doing wrong?

It does nothing though. I was thinking the top code would change all the names of my bricks to the variable, but it didn't. What am I doing wrong?

If you mean this:

Code: [Select]
echo(BrickGroup_8448.NTObject_hi_0);

That's because it's NTObjecthi_0, not NTObject_hi_0.
If you mean this:

Code: [Select]
%group = BrickGroup_8448;
%name  = "test";
%count = %group.NTObjectCount[%name];
for(%a = 0; %i < %count; %a++)
{
    %brick = %group.NTObject[%name, %i];
}

This code doesn't actually do anything. You need to add code to do things with %brick after it's set in the loop.

None of the code above works. Please help.

Did you use a function?

Did you use a function?

Using it in a function doesn't change anything; but yes.
Seriously, I need working help now.

Using it in a function doesn't change anything; but yes.
Seriously, I need working help now.

Someone just gave you all the help you could possibly need, are you just copy pasting this code expecting it to work exactly the way you want it to?

Someone just gave you all the help you could possibly need, are you just copy pasting this code expecting it to work exactly the way you want it to?
No i was't copying pasting.

Also I figured out the problem. I had to put an underscore before the name of the brick in the code that Kalphiter gave me. Sorry, and thanks.