Blockland Forums > Modification Help
Referencing datablocks by number...
<< < (2/2)
Badspot:
The numbers can in fact change.  Saving by name is better. 

Be aware that %obj.datablock or %obj.getDataBlock().getName() will give you the datablock name, but it only works for the host. 
To get it to work client-side, you need to use the .uiname property of the datablocks (this is the name that is displayed in the brick selection dialog and in the hud)

So, to the name from a brick on the client you do

--- Code: ---%brickName = %brick.getDatablock().uiName;

--- End code ---

Then you save that uiname however you want.

Converting from the uiName back to a datablock id is a little trickier, but there is a built in table.

--- Code: ---//create the table if it hasn't been created yet
if($UiNameTableCreated == false)
   createUiNameTable();

//lookup the uiname in the table
%brickData = $uiNameTable[%brickName];

--- End code ---
Trader:
Excellent, thank you.
Navigation
Message Index
Previous page

Go to full version