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

I've been doing some more testing, and I have found that in most servers, I can shorten my code to this:

Code: [Select]
for(%a=0; %a<serverconnection.getcount(); %a++)echo(serverconnection.getobject(%a).uiname TAB serverconnection.getobject(%a));
But in many servers with many add-ons, I am doing tests echoing the objects and datablocks, and they seem to skip whole ranges of values, and I am wondering what is making this so complicated.
« Last Edit: June 27, 2011, 04:30:30 PM by Nexus »

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.

well the first problem your going to run into is the /command requires a server-side addon -- unless you have a way around that.

but assuming you do...
just scanning all the object IDs is the wrong way to go about it.
the object IDs are assigned in the order things are created on the server (datablocks, clients, bricks, sounds, and such).

Since every server has a different set of addons, the sequence and order of the object IDs will be different for every server.

.... now im also wondering if there is a different or better way to accomplish what you are trying to do.

inside your script, and AFTER getting the brick datablock ID... what do you do?  Specifically with the argument... what are you supposed to type?  a name? a number? .. something else?

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.
Protip: The IDs of datablocks will be the same on the client and the server.

However, what people don't seem to notice is that he's trying to go from name to ID. Not get an ID from some mysterious number that comes from nowhere.

%brickName = "1x10F";
%id = $uiNameTable[%brickName];
commandToServer('instantUseBrick',%id);

that command is actually default.  you can use it by right clicking the icon.



chrono, the ids arent the same.  on the client side you will usually get a much higher value because you have been playing on other servers.

actually, the code i posted last is suddenly working, even though it was the first thing i tried.

chrono, the ids arent the same.  on the client side you will usually get a much higher value because you have been playing on other servers.
They are the same.
Datablocks will ALWAYS reserve the number range: 3-4099 on both the client and the server.

My method will work, but go ahead and not try.

They are the same.
Datablocks will ALWAYS reserve the number range: 3-4099 on both the client and the server.

My method will work, but go ahead and not try.

Wait, is $uiNameTable a default array?

Wait, is $uiNameTable a default array?
It's created just as you're spawning in a server based on the bricks the server has. (Yes it's client sided)

It's created just as you're spawning in a server based on the bricks the server has. (Yes it's client sided)

fasf you are correct.  I wish that was posted earlier before I created a dozen different methods, ten of them faulty, to accomplish this.

Also interesting: you can do
Code: [Select]
export("$*", "config/allvars.txt");
To see every global variable in the game.
Useful stuf.

Funny story, to find it, I did:
export("$*1x1*","config/bricks.txt",0);
after joining some random server.