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

Does anyone know the variable for block name?
Please also note that I am talking about all the blocks on the server with the name target.. (when you wrench the block and set a name..)

Example:
Code: [Select]
if(%brick.name("target"))
{
     blah();
}

Code: [Select]
if(%brick.getShapeName() $= "target")
{
    blah();
}
This I think

if(getsubstr(%n=%brick.getname(),1,strlen(%n)-1) $= BlahBrickName)

if(getsubstr(%n=%brick.getname(),1,strlen(%n)-1) $= BlahBrickName)

That worked, now how do I get all the bricks and then run it through the if(getsubstr(%n=%brick.getname(),1,strlen(%n)-1) $= BlahBrickName) function? To get the amount of bricks on a server with the name "target"?

if(getsubstr(%n=%brick.getname(),1,strlen(%n)-1) $= BlahBrickName)

If the brick doesn't have a name, this'll throw errors.

If the brick doesn't have a name, this'll throw errors.
I know, I expect the brick to have a name when he wants to get it?

Alternatively, you can shorten the crap
if(%brick.getname() $= "_target")

if(getSubStr(%n=%brick.getName(),1,(strLen(%n)||1)-1) $= %brickname)

or

if(%brick.getName() $= "_" @ %brickname)
« Last Edit: November 16, 2012, 06:39:44 PM by Trinick »


strLen(%n) or 1

if strLen(%n) is 0, it'll use 1, otherwise it'll use the value strLen gives.


Oop, ^ is right. I meant to use ||. Didn't even see that.

Is anyone going to respond to my second question? How do I search every block in the server, and check if it's name is "target"?

Is anyone going to respond to my second question? How do I search every block in the server, and check if it's name is "target"?
loop

Code: [Select]
%groupCount = MainBrickGroup.getCount();

for(%i = 0; %i < %groupCount; %i++)
{
   %brick = MainBrickGroup.getObject(%i);
   if(%brick.getName() $= "_target")
   {
      //do stuff
   }
}