Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Left/Right Justify SetText

Zodiakos Absolute
With a a dash of lemon.
Join date: 6 Jun 2005
Posts: 282
12-02-2005 20:13
Here's my little contribution... It's definitely not perfect, and it doesn't work perfect by any stretch, but it may be just what you need for your HUD for certain things. There's probably a prettier or better way to do this, but I wanted a quick fix. :D

CODE

// Left/Right Justify llSetText
// by Zodiakos Absolute

// Note: It works funky and is not correct. This is as close as *I* can get it without resorting to arcane lists lists of glyph dimensions and such. Works best on numbers, which seem fairly constant width.

// To use, just use LeftJustify or RightJustify, with the parameter as the text you want to use.
// The script works by padding each letter with two spaces on either the front or the end of the string. This isn't perfect, but might do the trick depending on what you use it for.

LeftJustify(string text)
{
integer i;
string dotext;
for(i=0;i<llStringLength(text);i++)
{
dotext+=" ";
}
dotext+=text;
llSetText(dotext, <1,1,1>, 1);
}

RightJustify(string text)
{
integer i;
for(i=0;i<llStringLength(text);i++)
{
text+=" ";
}
llSetText(text, <1,1,1>, 1);
}

default
{
state_entry()
{
llListen(0,"",NULL_KEY,"");
}

listen(integer channel, string name, key id, string message)
{
RightJustify(message);
}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
12-02-2005 20:18
/54/5c/75064/1.html
_____________________
i've got nothing. ;)