Don't click here unless you want to be banned.

LSL Wiki : llSetText

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are ia360925.us.archive.org
llSetText(string text, vector color, float alpha)

- string text
The Text displayed over the object. (Length Limit: 254 bytes (extended ASCII such as accented characters count as two bytes))

- vector color
The colorvector. Picks the color with which the text is displayed.
Format: <0, 0, 0>
To convert from RGB to the vector value, divide the RGB value with 255.
Example: 255, 0, 0 (Red) = 255/255, 0/255, 0/255 = <1, 0, 0>

- float alpha
Decides the transparency of the text from 0.1 (high transparency) to 1.0 (no transparency).


Detailed Information:
Sets the contents of text as floating text over the prim using the specified color and transparency (alpha).

"\n" can be used to start a new line. Empty lines must have at least one character (use a space: " \n"). text has a length limit of 254 characters. The Second Life viewer will wrap the text automatically so it doesn't exceed 1000 pixels width (as opposed to wrapping after a certain number of characters - this is because the default font is proportional so different characters have different width).

To remove text from a prim, leave text empty: ""
llSetText("",<0,0,0>,0)

The following code fixes the "\n" not being converted in literal cases. Chat input, variables, etc... -SiRiSAsturias
msg = llDumpList2String(llParseString2List(msg, ["\\n"], []), "\n");

Note: Floating text is a property of the prim, not the script. As such, it will remain until removed explicitly. Simply deleting the script that set the text will not remove the text.

The text will always be positioned to float straight up (parallel to the world's Z-axis) from the prim's center at a distance of half the prim's Z scale plus some fixed offset.
The float text uses the prims Z axis regardless of it?s rotation. This means that if you rotate a prim 90 degrees and flatten it, the text will float just above the center.

To actually display text on a prim (not hover text), see XyText.

As of Version 1.8.4, alpha is no longer ignored.

Examples:
// Set text to say "Hello." in bright red
llSetText("Hello.", <1,0,0>, 1.0);

// Remove text
llSetText("", <0,0,0>, 1.0);

// Set text to say "Hello" and "How are you?" on two different lines
llSetText("Hello.\nHow are you?", <1,0,0>, 1.0);

// Use a function to display the current region
llSetText("You're currently in " + llGetRegionName(), <0,1,0>, 1);

Q: If I llSetText in a linked Object, 70% of time its ok but there are random cases when the Text does not show to an avator even though others at the time can see ok! Any Suggestions as to why? I understand text is a property of the Prim and not the Script.
A: From what others have seen from similar situations, this is merely the asset server being buggy, sometimes people can see whole prims others cant


This article wasn't helpful for you? Maybe the related article at the LSL Portal is able to bring enlightenment.

Functions | Text
Comments [Hide comments/form]
Add this script to remove the floating text, because simply deleting the script that set the text will not remove the text.
default
{
    state_entry()
    {
        llSetText("", ZERO_VECTOR, 0);
        llRemoveInventory(llGetScriptName());
    }
}
-- NonnuxWhite (2005-07-03 05:15:30)
hey, how do you do llSetText or llDialog to show the names for a sensor?
-- ArgusStravinsky (2005-08-12 01:36:09)
im not to skilled with dialogs, but for the sensor i'd use:
sensor(integer detected)
{
    integer current = 0;
    string names;
    while(current < detected)
    {
        names += llDetectedName(0)+"
");
    }
    llSetText(names,<1,1,1>,1);
}
as an explination for llDetectedName(0)+"
");
thats the only way i know how to put returns into floating text, if anyone knows a better way plz post it
-- SchitsoMonkey (2005-08-12 17:06:05)
and what about names "longer than 24 characters"?
-- ArgusStravinsky (2005-08-12 17:07:15)
well, if part of the name is longer than 24 characters it would continue on the next line:
(22 characters...) a
ll
i suppose you could add some sort of word wrapping if you wanted, but you have to figure that out urself :)
-- SchitsoMonkey (2005-08-13 10:12:31)
sorry, i should have been more specific; i meant for dialog buttons, which was somethign i was also talking about at the time
-- ArgusStravinsky (2005-08-13 10:43:15)
oh, well, if the name is more than 24 characters long i suppose you would have to cut the end off... something like this is what i would do:
sensor(integer detected)
{
    integer current = 0;
    list names;
    while(current < detected)
    {
        string temp = llDetectedName(current);
        if(llStringLength(temp) > 24){ temp = llGetSubString(temp,0,23);}
        names += temp;
        if(current >= 12)
        {
            llDialog(target,"Message",people,1);
            return;
        }
        current += 1;
    }
    llDialog(target,"Message",people,1);
}
and the other script wouldn't work, i wasn't paying much attention :P Heres how it would look:
sensor(integer detected)
{
integer current = 0;
string names;
while(current < detected)
{
names += llDetectedName(current)+"
");
current += 1;
}
llSetText(names,<1,1,1>,1);
}
-- SchitsoMonkey (2005-08-13 13:23:43)
but it says on llDialog that anything too long will automatically be shortened and appended with "...", so you shouldn't need to do anything other than give it the names...
-- SchitsoMonkey (2005-08-13 13:25:05)
well, blatantly, that's bull*t. I tried a dialog and it said in a popup "llDialog: Button Labels cannot have more than 24 characters." and proceeded to NOT show the dialog box.
-- ArgusStravinsky (2005-08-13 23:13:38)
Ending bold. Argus, if you found an error in a page, you should change it. The Lindens are constantly adjusting the behavior of LSL. Don't get mad if the wiki isn't up to date, just fix it.
-- CatherineOmega (2005-08-14 03:39:37)
Oh, well i guess the page is wrong... So i spose you just have to chop off the end of the name for the button. You could also add "..." to the end if you wanted.
-- SchitsoMonkey (2005-08-14 08:08:28)
i didnt mean for that to be bold. I wasn't mad, just apparently using three asterisks makes the rest of the line bold, hehe. but it is complete crap. i will change the page, :D
-- ArgusStravinsky (2005-08-14 10:16:30)
Correct me if I'm wrong, but I don't believe HUD attachments can have hover text.
-- DolusNaumova (2005-10-26 15:03:00)
I'm having a problem with linebreaks in llSetText. Having a text with linebreaks works fine if I do something like this:

// llSetText("This text appears\n on two lines", <1,0,0>, 1.0);

However, if I get the text from a variable, it doesn't recognize the linebreak:

// 
string myvar = "This text is supposed\n to appear on two lines";
llSetText(myvar, <1,0,0>, 1.0);

Can anyone tell me what I'm doing wrong? Thanks in advance.
-- SeanHadlee (2005-11-10 16:31:57)
Ooops, that was my first posting. The two lines weren't supposed to be comments.
-- SeanHadlee (2005-11-10 16:33:15)
Dolus -- with 1.7.2 llSetText has been restored (added?) to HUD attachments. Yay Lindens!
-- BinoArbuckle (2005-11-12 17:04:11)
When the LSL compiler sees "\n" in a literal string, it substitutes a linebreak. This is not done by llSetText() itself! That means if your text comes from the user, from a listen event, or any other source outside of your script, the substitution never happens. You can use a function to perform the substitution yourself. Something like this:
string subst(string s1, string s2, string s3) {
    // s1 = string to do the substitutions in
    // s2 = string to change to
    // s3 = string to replace
    integer index = llSubStringIndex(s1,s3);
    if (index >= 0) {
        s1 = llDeleteSubString(s1,index,index + llStringLength(s3) - 1);
        s1 = llInsertString(s1,index,s2);
        s1 = subst(s1,s2,s3);   // recursive function call
    }
    return s1;
}

Then later in your script you can do something like. . .
argstring = subst(argstring,"\n","\\n");
            llSetText(argstring,textcolor,1.0);
-- ZobeidZuma (2005-11-26 11:50:30)
Ok. Alpha's not ignored anymore. But how can I use it? I try setting it to anything other than 1 (or higher) and it just hides the text.
-- NeardHarbinger (2006-03-07 20:10:48)
I've noticed when using llSetText() for radar HUDs that on sim entry, the sensor immediately detects new agents, but llSetText() lags for several seconds (up to 30s in some high-lag cases). I'm guessing this has to do with slow full object updates especially under continual use as llSetText() is. To combat this I set delays on llSetText() especially on sim entry to give the sim time to acquire the object and be ready to change it.
-- VeloxSeverine (2006-10-30 22:07:24)
Attach a comment to this page: