Author Topic: Getting the brick number from the brick name  (Read 2062 times)

I am in the need of a system that can figure out what a brick's number is given the name of the brick.  For example, I have found that the first brick, 1x1, is always number 201, and it increases sequentially from there.  If I only wanted default bricks to work, I could just have a giant switch to change each brick name into the appropriate number, but addons are not always enabled, and the numbers of non-default bricks can change from server to server.  I am stumped as to how to find the brick number, since this number does not appear to exist on the client side outsode of the brick selector dialogue.

example of what I'm talking about:
type "/instantusebrick 201" and click the ground
a 1x1 ghost brick will appear
now type "/instantusebrick 202"
the ghost brick will turn into a 1x2 brick

what do you mean by "brick number" ?

what do you mean by "brick number" ?

I tried to explain that, and it was actually something I was unaware of until recently.  The brick number is how the client tells the server what brick it is trying to use.  If you join a server, spawn, and then go into the GUI editor and open the brickselectordialogue, you will see that every brick icon has a unique number in the command.  The command "\instantusebrick ###" is the fastest way to translate that number into a ghost brick, but I do not know how to find the number of the brick that I need within a script.

... I still dont get it.

you can look at a brick and say /getid
it will give you a number in chat.  but thats only good for your current session of blockland.

You say you need this brick number for your script.  what are you trying to do in your script?
it almost sounds like you want a /command to change your ghost brick.

... I still dont get it.

you can look at a brick and say /getid
it will give you a number in chat.  but thats only good for your current session of blockland.

You say you need this brick number for your script.  what are you trying to do in your script?
it almost sounds like you want a /command to change your ghost brick.

That is the brick's ID
what I need is the number that the server gives to each type of brick.  Really, the best way to explain this is that for each brickdata, there is a number that identifys what that is, so the client can tell the server that it wants to use the brick with the number 201, and the server translates that into the 1x1 brick.  If you still don't understand it, then play around with "/instantusebrick ###" and you will see what I am talking about.

it almost sounds like you want a /command to change your ghost brick.
that couldnt be more exactly what I am asking for, except i have the /command, i just need a way to determine the argument
« Last Edit: June 22, 2011, 08:38:23 PM by Nexus »

okay.. so you want the ID of the brick's datablock

try something like this:
echo( brick1x1Data.getID() );
echo( brick4xCubeData.getID() );

okay.. so you want the ID of the brick's datablock

try something like this:
echo( brick1x1Data.getID() );
echo( brick4xCubeData.getID() );

This doesn't work on the client side.

I am trying to figure out how to get this number, but the closest I can get to is finding the ID if the client sided brickdata using the following code.

Code: [Select]
for(%a=0; %a<serverconnection.getcount(); %a++)
{
%b = serverconnection.getobject(%a);
if(%b.uiname $="1x6x3")
{
echo(%b);
break;
}
}

I am not entirely up to snuff with parented script objects and how to get ids local to the script object.

so, I was playing around with things and stuffs, and I came up with this:
Code: [Select]
function buildbrickdataidlist()
{
if(isObject(serverconnection))
{
for(%a=0; %a<serverconnection.getcount(); %a++)
{
if((%b = serverconnection.getobject(%a)).uiname $= "1x1" && !%found)
{
%found = true;
%c = 200;
}
%c++;
if(%b.category !$= "" && %b.uiname !$= "" && %found)
$brickdatalist[%b.uiname] = %c;
}
}
}

I'll let you guys know how it works.

The 'brick number' is the ID of the datablock. To get the 'brick number' or ID of the brick's datablock on the client side you use .getID(). Most of the important server-side functions work on the client-side too.

ie. Red_Guy had the right idea.

The 'brick number' is the ID of the datablock. To get the 'brick number' or ID of the brick's datablock on the client side you use .getID(). Most of the important server-side functions work on the client-side too.

ie. Red_Guy had the right idea.

Yes.  At the time I did not know that the 'brick number' I was talking about had actual significance outside of the brick selector.  However, on the client side, serverconnection.getid() gets an id that is different from the one on the server, so you need to find the offset.

serverconnection.getObject(%i).getID();
I thought that was obvious.

serverconnection.getObject(%i).getID();
I thought that was obvious.

Ok, not only do I already know that, but it only gets a useless ID on the client side.  I really don't want to have to read this same answer over and over.  I already posted my solution, Destiny.

unlocking because it seems my issue is not solved.

I would like to remind any posters that any use of .getid();  will almost definetly result in a useless client side variable that does no good in finding the id of the datablock in the server.

I have been using that code, but I have found it to no longer work.  There does not seem to be any pattern to how the datablocks are set up in ServerConnection.  I have been able to identify the datablocks of placed bricks by typing this right after placing the brick:

Code: [Select]
echo(serverconnection.getobject(serverconnection.getcount()-1).getdatablock());
But this method is not practical in a script.

How do I go from the ui name of a brick, to the server sided id of the datablock?

But this method is not practical in a script.

How do I go from the ui name of a brick, to the server sided id of the datablock?
And just to make sure I understand -- you want this to be CLIENT ONLY? ... right?

And just to make sure I understand -- you want this to be CLIENT ONLY? ... right?


/instantusebrick

This requires the Server Sided ID of the datablock.  Server cannot tell the server that it is instantly using a brick.  It is client sided.