Blockland Forums > Modification Help
How to make script find a brick by its name
Mold:
/title
Port:
Try invoking the dump() member function of a brick group and look at the output.
Headcrab Zombie:
I'm assuming that by name, you mean the name you can set with the wrench
_<brick name>
So if the brick's name is 'test'
_test.delete();
would delete it
Port:
--- Quote from: Headcrab Zombie on May 28, 2012, 11:34:00 AM ---I'm assuming that by name, you mean the name you can set with the wrench
_<brick name>
So if the brick's name is 'test'
_test.delete();
would delete it
--- End quote ---
The proper way is looking at the variables on a brick group in order to see all bricks named that (and also to see it for a specific person).
Axolotl:
This will work.
This is the easy way.
--- Code: ---function findBrickByName(%name)
{
eval("%currentbrick = \"_\" @ %name;");
if(isObject(%currentBrick) && %currentBrick.getClassName() $= "fxDTSBrick")
{
return %currentbrick.getID();
}
else
{
return 0;
}
}
--- End code ---
Keep in mind that this only looks for single named bricks so I'd appreciate it if somebody did it with Port's way.