Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Text

Jenn Yoshikawa
Registered User
Join date: 14 Nov 2007
Posts: 91
11-14-2008 01:43
say some one had 12 block prims and that wanted to place letters on them. But wanted the word in the center no matter how long the word is. How would I go about doing it. I have asked in the past but some said use xy text. Mmmm the way I have to work with the prims on my items xy text would not work. I have to use single cell prims for this.
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
11-14-2008 03:19
Hope I got you right...

You're placing one letter on each block, so the words that you display can have max 12 characters.

To «center» the word, you have to check how many characters the word has and then do some math to determine how many spaces you have to put in front and to the end of the word (to make it appear «centered»).

string myString = "myword";
integer wordLength = llStringLength(myString);

integer spaces = (12 - wordLength) / 2; // equals 3

Now, you add a blank texture to the first 3 blocks and then the letters for myString to the following blocks...

Hope that was what you wanted... :)
Jenn Yoshikawa
Registered User
Join date: 14 Nov 2007
Posts: 91
nods
11-14-2008 03:31
Seems it would work for what I would need the only deal is once I linked the word to the prims how would I mark the script to know what letter to place on the prim
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
11-14-2008 03:41
one possibility would be to link them in order (1-2-3-4)... then you just have to get each character of the word and put that on the according prim.

CODE


// I assume, you have a texture for each character, where a space is named «space» and all the other characters are named after their representation (a => a, b => b, ...)

integer blocks = 12;
integer i;
integer link; // We assume the first block has linknumber 1
string myWord = " myword ";

string character;
string space = "space";

for(i=0;i<blocks;i++){
link = i + 1;
character = llGetSubString(myWord, i, i);

if(character == " "){ // empty character -> add a space
llSetLinkTexture(link, 0, space);
}else{
llSetLinkTexture(link, 0, character);
}

}



You could as well use linked-messages and do the placement in the linked blocks...

CODE

// Root Prim

llMessageLinked(LINK_SET, 0, "TextToDisplay", NULL_KEY);


CODE

// Linked Prim // Put the «linknumber» (a.k.a. the position of the block) into the objects description. Then you don't have to worry about linking them in order. Start count at 0!

inter linknum;

default{
state_entry(){
linknum = llGetObjectDescription();
}

link_messages(integer sender, integer num, string str, key id){
// extract the character from the passed string that has to be put on the block's surface

string char = llGetSubString(str, linknum, linknum);

llSetTexture(char, 0); // Places the texture «char» onto face 0
}

}



In the second example, you'd have to put a copy of all character-textures into each displaying prim. Easier would be to make a list of the uuids of the character-textures and then get the uuid of the character from this list...
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
11-14-2008 23:04
if this is on your own land and you have a web server you could use that, as an alternative to xytext

i love being able to do that now, its soo.... well its so should be built in but its better than nothing if you have the resources