Blockland Forums > Modification Help
How to get a brick datablock name from its ui name?
(1/1)
Ipquarx:
How would i be able to get a bricks datablock name if i only know its UI name?
im trying to get it through a script.
Greek2me:
This will return the DB's ID:


--- Code: ---function DBNameToID(%name)
{
%cnt = datablockGroup.getCount();
for(%i=0; %i < %cnt; %i++)
{
%db = datablockGroup.getObject(%i);
if(%db.uiName $= %name)
{
%datablock = %db;
break;
}
}

return %datablock;
}
--- End code ---

If you need the datablock name for display purposes, replace return %datablock; with return %datablock.getName();
Destiny/Zack0Wack0:
Oh god no, just use this:

--- Code: ---%datablock = $uiNameTable[%brickUIName];
if(isObject(%datablock))
{
//do stuff
}

--- End code ---
Greek2me:
Really? Thanks!
Ipquarx:
allrighty. thanks.
Navigation
Message Index

Go to full version