Blockland Forums > Modification Help
Finding a brick by name
(1/2) > >>
Snaily:
Allo.

I haven't done much scripting for Blockland, and I had no luck with search.

I know how to iterate through objects and see if an object is a brick, but is it possible to figure out what the brick's name is (the name a player gives the brick)?



--- Code: ---for(%i = serverConnection.getCount()-1; %i > 0; %i--) {

%object = serverConnection.getObject(%i);

if(%object.getClassName() $= "fxDTSBrick") {

//Now what?
         
}
}

--- End code ---
Chrono:
The brick's name is getSubStr(%object.getName(),1,strLen(%object.getName())-1);
Snaily:
%object.getName() returns an empty string.

:C



Would I have to cast the object into a fxDTSBrick?
Eh, I duno if Torque can even do that, but I'll search for it and give it a shot.


Edit: Recasting the brick object didn't work, at least doing it the way it's done in C++. It returns 0.

Hmm...
Snaily:
getBrickName(), getName(), and getPrintName() all return an empty string.

Through the console, I can change the same brick's attributes, so the brick does exist and it does have a name.



Oh, and if this is the wrong section, I'm sorry.
Kalphiter:
Do NOT search through every brick. You can search every BL_ID's brickgroup for this. The brickgroup contains all bricks that the player has named.

This loops through every named brick in the server:

--- Code: ---for(%a = 0; %a < MainBrickGroup.getCount(); %a++)
{
    %brickgroup = MainBrickGroup.getObject(%a);
    for(%b = 0; %b < %brickgroup.NTNamecount; %b++)
    {
%name = %brickgroup.NTName[%b];
%obj = %brickgroup.NTObject_[%name];
if(%name $= "brickname")
{
   
}
    }

}
--- End code ---
Navigation
Message Index
Next page

Go to full version