Blockland Forums > Modification Help

Take off the _ from a name?

Pages: (1/6) > >>

Pew446:

I need to remove the _ off the front of a bricks name when calling getName();

For example echo(%brick.getName()); for a brick named John would result in _John

How can I make it echo just John?

herb:

%name=%brick.getName();

%name=strReplace(%name,"_","");

this will change all _ in the string, into nothing and will return John.

u can change it into different things, for ex:

%name=strReplace(%name,"_","*");

that will return *John

Pew446:

Thanks big time! :D

Tom:

Using strReplace won't work for a brick named something like this: John_House
Use getSubStr(%brickName, 1, strlen(brickName) - 1); instead.

Chrono:


--- Quote from: Tom on August 04, 2010, 07:58:40 PM ---getSubStr(%brickName, 1, strlen(%brickName) - 1);

--- End quote ---
Fiks'd. :3

Pages: (1/6) > >>

Go to full version