Author Topic: Variable for block name..  (Read 2849 times)

Except that if there is more than one brick with the same name you have to use a function such as this
Code: [Select]
%brick = BrickGroupxxxxxx;
for(%i=0;%i<%brick.NTObjectCount_brickname;%i++)
{
%br = %brick.NTObject_brickname[%i];
do stuff to %br
}

Er, no, the previously posted code will work. That's doing the same thing, just for only one player's bricks instead of all the bricks in the server.

Er, no, the previously posted code will work. That's doing the same thing, just for only one player's bricks instead of all the bricks in the server.
Er, no, the previously posted code will not do anything, it's looping through the main group containing the brickgroups and checking whether the groups have the name _target

Code: [Select]
%groupcount = mainbrickgroup.getcount();
for(%i = 0; %i < %groupcount; %i++)
{
    %group = mainbrickgroup.getobject(%i);
    %count = %group.getcount();
    for(%j = 0; %j < %count; %j++)
    {
        %brick = %group.getobject(%j);
        if(%brick.getname() $= "_target")
        {
            blah();
        }
    }
}

You're right, it won't work because the guy who wrote it apparently doesn't think when he writes code. Sorry for assuming people here know what they're talking about.

It's hard to "think" straight when you've just got home from a 13 hour shift, I simply forgot.

Blocki was right, good for him.

It's hard to "think" straight when you've just got home from a 13 hour shift, I simply forgot.

Blocki was right, good for him.


If you can't think straight, then don't post lol. It's really quite simple.

Er, no, the previously posted code will not do anything, it's looping through the main group containing the brickgroups and checking whether the groups have the name _target

Code: [Select]
%groupcount = mainbrickgroup.getcount();
for(%i = 0; %i < %groupcount; %i++)
{
    %group = mainbrickgroup.getobject(%i);
    %count = %group.getcount();
    for(%j = 0; %j < %count; %j++)
    {
        %brick = %group.getobject(%j);
        if(%brick.getname() $= "_target")
        {
            blah();
        }
    }
}

Can this script create lag if I have over 100,000 bricks?

Can this script create lag if I have over 100,000 bricks?
Yes.

Can this script create lag if I have over 100,000 bricks?
Yes, quite a bit actually

Hmm, I see that can become problematic.

Hmm, I see that can become problematic.
Split bricks of specific importance into different brickgroups, then make separate loops for each. Then you have more control over what gets checked and how often.

Or alternatively, you could build a list of bricks like this:

Code: [Select]
package brickNameStuff
{
function fxDtsBrick::setNTObjectName(%this,%flag)
{
if(%flag $= "_myName")
$myList = setField($myList,getFieldCount($myList),%this);

return parent::setNTObjectName(%this,%flag);
}
};
activatePackage(brickNameStuff);