LlSetText

From Second Life Wiki

Jump to: navigation, search

Template:Needs Translation/LSL/de Template:Needs Translation/LSL/es Template:Needs Translation/LSL/el Template:Needs Translation/LSL/he Template:Needs Translation/LSL/it Template:Needs Translation/LSL/ko Template:Needs Translation/LSL/nl Template:Needs Translation/LSL/hu Template:Needs Translation/LSL/no Template:Needs Translation/LSL/da Template:Needs Translation/LSL/sv Template:Needs Translation/LSL/tr Template:Needs Translation/LSL/pl Template:Needs Translation/LSL/pt Template:Needs Translation/LSL/ru Template:Needs Translation/LSL/uk Template:Needs Translation/LSL/zh-Hans Template:Needs Translation/LSL/zh-Hant

Contents

Summary

Function: llSetText( string text, vector color, float alpha );
152 Function ID
0.0 Delay
10.0 Energy

Displays text that hovers over the prim with specific color and translucency (specified with alpha).

• string text text to display
• vector color color in RGB <R, G, B> (<0.0, 0.0, 0.0> = black, <1.0, 1.0, 1.0> = white)
• float alpha from 0.0 (clear) to 1.0 (solid) (0.0 <= alpha <= 1.0)

Caveats

  • If more than one llSetText is called (By reset,interaction or script state) within a prim the latest call will take priority over the previous.
  • text is limited to 254 bytes, if the string is longer it will be truncated to 254 bytes, even if that means the truncation will chop a character in half.
  • An unbroken line of text of a great length may be broken automatically into two lines (one above the other).
  • Floating text can be seen through walls and other object. Be considerate of neighbors in malls and apartment buildings.
  • There is no way for a script to determine the prim's current floating text or detect when it is changed.
  • Removing the script or deactivating it will not remove the prim's floating text.
    • Floating text is a prim property and not dependent on a script for its continued existence.
  • To remove floating text, use the following:

llSetText("", <1.0, 1.0, 1.0>, 1.0);
  • Vertical whitespace is removed from the end of the text string, so if you want vertical whitespace put any character (like a space) on the last line.
  • Be careful trying to use special symbols (e.g. heart ♥ ) in your floating text as it can cause objects to fail to rez. SVC-4539[c]
  • Multiple linebreaks with empty lines are converted to a single linebreak, so add a whitespace character on every line you want to skip:

llSetText("Monkeys\n\n\n\n\n", <1.0, 1.0, 1.0>, 1.0);//Bad
llSetText("Monkeys\n \n \n \n \n ", <1.0, 1.0, 1.0>, 1.0);//Good

Search JIRA for related Bugs

Examples

Example of how llSetText could be included in default code to show object's name in green text:

default
{
    state_entry()
    {
         llSay(0, "Hello, Avatar!");
         llSetText(llGetObjectName(), <0.0, 1.0, 0.0>, 1.0); // Display the object's current name in green
    }
 
    touch_start(integer total_number)
    {
         llSay(0, "Touched.");
    }
}

By default the floating text will appear on a single line. However, the floating text can be spread over multiple lines by using a line break "\n" (read SplitLine in section 'See Also').

Color & Alpha

Color Code
White <1.0, 1.0, 1.0>
Grey <0.5, 0.5, 0.5>
Black <0.0, 0.0, 0.0>
Red <1.0, 0.0, 0.0>
Green <0.0, 1.0, 0.0>
Blue <0.0, 0.0, 1.0>

The x, y & z components of the vector are used to represent red, green, and blue respectively. The range is different than traditional RGB, instead of being 0 -> 255, LSL uses 0 -> 1. <1.0, 1.0, 1.0>, means "white" and <0.0, 0.0, 0.0> means "black":

llSetText("I am white", <1.0, 1.0, 1.0>, 1.0);//white text

llSetText("I am black", <0.0, 0.0, 0.0>, 1.0);//black text

The 1.0 is the alpha setting. 1.0 means fully opaque, and 0.0 would be completely transparent (invisible):

llSetText("alpha", <0.0, 1.0, 0.0>, 0.5);//50% translucent green text

Multiple lines

llSetText("I am \n on two lines!", <0.0, 1.0, 0.0>, 1.0);//two lines of green text

Useful Snippets

Drag this script out of inventory onto an object to erase its set text:

// http://wiki.secondlife.com/wiki/llSetText
default
{
    state_entry()
    {
        llSetText("", <1.0, 1.0, 1.0>, 1.0);
        llRemoveInventory(llGetScriptName());
    }
}

Notes

To actually display text on a prim, see XyzzyText, or consider using parcel prim Media options (useful only if you have control over the land's media settings.)

See Also

Articles

•  Color in LSL
•  Translucent Color
•  Limits SL limits and constrictions
•  Examples: SplitLine Insert 'new line' escape codes at certain positions of a string
•  Useful snippet: llGetObjectPermMask Label an object with text and newlines to give away or sell

Deep Notes

Issues

~ Search JIRA for related Issues
Bug - A problem which impairs or prevents the functions of the product. Resolved - A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.    llSetText is not working with special characters.
This article wasn't helpful for you? Maybe the related article at the LSL Wiki is able to bring enlightenment.
Personal tools
In other languages