Difference between revisions of "LlSetText"

From Second Life Wiki
Jump to navigation Jump to search
(clarified the floating text uses UTF-8 encoding, and multibyte characters are just deleted if they cross the boundary instead of resulting in garbage)
 
(57 intermediate revisions by 21 users not shown)
Line 1: Line 1:
AKA "floating text" in the popular vernacular. This creates text that floats / hovers above the prim.
{{LSL_Function
 
|inject-2={{:PRIM_TEXT|set}}{{Issues/SVC-4539}}{{Issues/BUG-11077}}
To actually display text on a prim, see [[XyzzyText]], or consider using parcel prim [[:Category:LSL_Media]] options (useful only you have control over the land's media settings.)
 
 
{{LSL Function/color|color}} {{LSL Function/alpha|alpha}}{{LSL_Function
|func_id=152
|func_id=152
|func_sleep=0.0
|func_sleep=0.0
Line 10: Line 6:
|func=llSetText
|func=llSetText
|sort=SetText
|sort=SetText
|p1_type=string|p1_name=text|p1_desc=text to display between the quotes
|p1_type=string|p1_name=text
|p2_type=vector|p2_name=color
|p2_type=vector|p2_name=color
|p3_type=float|p3_name=alpha
|p3_type=float|p3_name=alpha
|func_desc=Displays '''text''' over a prim with specific '''color''' and transparency (specified with '''alpha''').
|func_desc=Displays {{LSLP|text}} that hovers over the prim with specific {{LSLP|color}} and translucency (specified with {{LSLP|alpha}}).
|return_text
|return_text
|spec=
|spec=
|caveats=
|caveats=
*A script calling llSetText cannot know if it is or is not changing the floating text, since there is no mirror [[llGetText]] function;
*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.
*Nor, for the same lack of the "missing" [[llGetText]] function, can a script know what text is hovering about a prim;
*{{LSLP|text}} is limited to 254 [[bytes]] (compare [[Limits#Building]]) in UTF-8 encoding. If the [[string]] is longer it will be truncated to 254 [[bytes]], and any multibyte characters getting split will be removed entirely.
*The limit on the character length of floating text is 255 characters;
*An unbroken line of text of a great length may be broken automatically into two lines (one above the other).
*Floating text will go right through walls or any other object. Be considerate of neighbours in malls and apartment buildings.
*{{LSLP|text}} can be seen through walls and other object. Be considerate of neighbors in malls and apartment buildings.
**Visibility distance increases with prim size.
*Removing the script or deactivating it '''will not remove''' a prim's {{LSLP|text}} property. Floating {{LSLP|text}} is not dependent on a script for its continued existence but only when wanting to change it.
*To remove a prim's {{LSLP|text}}, use the following:
{{{!}} class="sortable" width="100%" {{Prettytable}}
{{!}}- {{Hl2}}
! '''Preferred method to remove a prim's floating {{LSLP|text}}'''
! '''Second method does the same effect-wise.'''
{{!}}-
{{!!}}
<syntaxhighlight lang="lsl2">
//  empty string & black & transparent
    llSetText("", ZERO_VECTOR, 0);
</syntaxhighlight>
{{!!}}
<syntaxhighlight lang="lsl2">
//  empty string & black & transparent
    llSetText("", <0.0, 0.0, 0.0>, 0.0);
</syntaxhighlight>
{{!}}}
*Vertical whitespace is removed from the end of the {{LSLP|text}} string, so if you want vertical whitespace put any character (like a space) on the last line.
*Multiple linebreaks with empty lines are converted to a single linebreak, so add a whitespace character on every line you want to skip:
{{{!}} class="sortable" width="100%" {{Prettytable}}
{{!}}- {{Hl2}}
! '''Good'''
! '''Bad'''
{{!}}-
{{!!}}
<syntaxhighlight lang="lsl2">
    vector COLOR_WHITE = <1.0, 1.0, 1.0>;
    float  OPAQUE      = 1.0;


    llSetText("Monkeys\n \n \n \n \n ", COLOR_WHITE, OPAQUE);
</syntaxhighlight>
{{!!}}
<syntaxhighlight lang="lsl2">
    vector COLOR_WHITE = <1.0, 1.0, 1.0>;
    float  OPAQUE      = 1.0;


== Removing Floating Text ==
    llSetText("Monkeys\n\n\n\n\n", COLOR_WHITE, OPAQUE);
Floating text is a property of a prim and not a script. For that reason, the text will remain if the script is deactivated or even removed.
</syntaxhighlight>
 
{{!}}}
To remove floating text, you don't actually remove it, but rather swap in an empty string like this:
*'''Measurements showed a high impact of process time when doing numerous iterations in a while loop'''. For approx. 65 thousand iterations the process times are ca. 5 seconds without floating text, 24 seconds with [[llSetText]] and 96 seconds when using [[llSetPrimitiveParams#llSetLinkPrimitiveParamsFast]] in combination with [[PRIM_TEXT]]. Thats why you are '''not advised''' to make excessive use of changing a prim's {{LSLP|text}} within such iterations.
<lsl>
|examples=
llSetText("", <1.0, 1.0, 1.0>, 1.0);
Example of how [[llSetText]] could be used to show prim's name in green {{LSLP|text}}:
</lsl>
<syntaxhighlight lang="lsl2">
default
{
    state_entry()
    {
        vector COLOR_GREEN = <0.0, 1.0, 0.0>;
        float  OPAQUE      = 1.0;


Here is a complete script to erase the floating text of an object. You can just make the script in inventory, replace its contents with the script text below, and drag this script into the contents of the object:
//      prim's name (not necessarily object's)
        llSetText(llGetObjectName(), COLOR_GREEN, OPAQUE );


<lsl>
//      delete the script as we only needed it to change the floating text property
default {
    state_entry(){
        llSetText("", <0.0, 0.0, 0.0>, 0.0);
         llRemoveInventory(llGetScriptName());
         llRemoveInventory(llGetScriptName());
     }
     }
}
}
</lsl>
</syntaxhighlight>
By default the floating {{LSLP|text}} will appear on a single line. However, it can be spread over multiple lines by using a line break <code>"\n"</code> (read [[SplitLine]] in section 'See Also').


===String escape codes:===


LSL has four [[String#Escape Codes|string escape codes]]:
* <code>\n</code> for a new line
* <code>\\</code> for a backslash
* <code>\t</code> for a tab
* <code>\"</code> for a double-quote


== Font face and size ==
===Color & Alpha===


Apart from colour, we don't have a lot of control over how floating text will appear.
{{{!}} class="sortable" {{Prettytable}}
{{!}}- {{Hl2}}
! Color
! Code
{{!}}-
{{!}} style="color: white; background: #001f3f" {{!}}NAVY
{{!}}<code><0.000, 0.122, 0.247></code>
{{!}}-
{{!}} style="background: #0074d9" {{!}}BLUE
{{!}}<code><0.000, 0.455, 0.851></code>
{{!}}-
{{!}} style="background: #7fdbff" {{!}}AQUA
{{!}}<code><0.498, 0.859, 1.000></code>
{{!}}-
{{!}} style="background: #39cccc" {{!}}TEAL
{{!}}<code><0.224, 0.800, 0.800></code>
{{!}}-
{{!}} style="background: #3d9970" {{!}}OLIVE
{{!}}<code><0.239, 0.600, 0.439></code>
{{!}}-
{{!}} style="background: #2ecc40" {{!}}GREEN
{{!}}<code><0.180, 0.800, 0.251></code>
{{!}}-
{{!}} style="background: #01ff70" {{!}}LIME
{{!}}<code><0.004, 1.000, 0.439></code>
{{!}}-
{{!}} style="background: #ffdc00" {{!}}YELLOW
{{!}}<code><1.000, 0.863, 0.000></code>
{{!}}-
{{!}} style="background: #ff851b" {{!}}ORANGE
{{!}}<code><1.000, 0.522, 0.106></code>
{{!}}-
{{!}} style="background: #ff4136" {{!}}RED
{{!}}<code><1.000, 0.255, 0.212></code>
{{!}}-
{{!}} style="color: white; background: #85144b" {{!}}MAROON
{{!}}<code><0.522, 0.078, 0.294></code>
{{!}}-
{{!}} style="background: #f012be" {{!}}FUCHSIA
{{!}}<code><0.941, 0.071, 0.745></code>
{{!}}-
{{!}} style="color: white; background: #b10dc9" {{!}}PURPLE
{{!}}<code><0.694, 0.051, 0.788></code>
{{!}}-
{{!}} style="background: #ffffff" {{!}}WHITE
{{!}}<code><1.000, 1.000, 1.000></code>
{{!}}-
{{!}} style="background: #dddddd" {{!}}SILVER
{{!}}<code><0.867, 0.867, 0.867></code>
{{!}}-
{{!}} style="background: #aaaaaa" {{!}}GRAY
{{!}}<code><0.667, 0.667, 0.667></code>
{{!}}-
{{!}} style="color: white; background: #111111" {{!}}BLACK
{{!}}<code><0.000, 0.000, 0.000></code>
{{!}}}


You cannot, for instance, change the font, or the size of the font.
The x, y & z [[Vector#Components|components of the vector]] are used to represent red, green, and blue respectively. The range is <span style="background-color: yellow">different from traditional RGB</span>, instead of being 0 -> 255, LSL uses 0 -> 1. <code><1.0, 1.0, 1.0></code> represents "white" and <code><0.0, 0.0, 0.0></code> represents "black":
<syntaxhighlight lang="lsl2">
//  white & opaque
    llSetText("I am white", <1.0, 1.0, 1.0>, 1.0);
</syntaxhighlight>
<syntaxhighlight lang="lsl2">
    vector myColor;// defaults to ZERO_VECTOR or <0.0, 0.0, 0.0> which is black


Nor can you align it to right or left. It will always be centred horizontally above the prim.
    llSetText("I am black and 30% transparent.", myColor, 0.7);


    llSleep(7.5);  // before: <0.0, 0.0, 0.0> black
    myColor.x = 1.0;// now:    <1.0, 0.0, 0.0> red


== Height ==
    llSetText("I am now red and 10% transparent.", myColor, 0.9);
</syntaxhighlight>
If {{LSLP|alpha}} is 1.0 it means the {{LSLP|text}} is fully opaque (alpha), 0.0 would make it completely transparent (invisible):
<syntaxhighlight lang="lsl2">
    llSetText("green text with alpha 0.7", <0.0, 1.0, 0.0>, 0.7);


Floating text floats straight up on the Z-axis (the world's, not the prim's) from the centre of the prim (that contained the script that called it) to be above the prim at a height equivalent to half the prim's Z scale (plus a bit more.)
    llSetText("white text with alpha 0.4\n60% transparent", <1.0, 1.0, 1.0>, 0.4);
    llSetText("white text with alpha 1.0\nfully opaque", <1.0, 1.0, 1.0>, 1.0);


You can push floating text up higher above the prim by doing something like this:
//  next to lines have the same effect
    llSetText("invisible black text with alpha 0.0\nfully transparent", ZERO_VECTOR, 0);
    llSetText("invisible black text with alpha 0.0\nfully transparent", <0.0, 0.0, 0.0>, 0.0);
</syntaxhighlight>
===Multiple lines===
<syntaxhighlight lang="lsl2">
//  two lines of orange text


llSetText("Monkeys\n\n\n\n\n ", <1.0, 1.0, 1.0>, 1.0);
    llSetText("I am\non two lines!", <1.0, 0.4, 0.0>, 1.0);
</syntaxhighlight>
|helpers=
Drag this script out of inventory onto an object to erase its set text:
<syntaxhighlight lang="lsl2">
// http://wiki.secondlife.com/wiki/llSetText


The \n 's stand for newlines, so in the above example, the floating text will be 5 lines higher than normal above the prim.
default
{
    state_entry()
    {
//      remove floating text (empty string & black & 100% transparent)
        llSetText("", ZERO_VECTOR, 0.0);


Note the space after the last \n : pure vertical space is auto-trimmed from the end of a floating text string. You trick the system into leaving it alone by adding that one space.
//      delete the script as we only needed it to change the floating text property
        llRemoveInventory(llGetScriptName());
    }
}
</syntaxhighlight>
Code to easily specify appearance of hovertext:
<syntaxhighlight lang="lsl2">
vector NAVY    = <0,    0.122, 0.247>;
vector BLUE    = <0,    0.455, 0.851>;
vector AQUA    = <0.498, 0.859, 1    >;
vector TEAL    = <0.224, 0.8,  0.8  >;
vector OLIVE  = <0.239, 0.6,  0.439>;
vector GREEN  = <0.18,  0.8,  0.251>;
vector LIME    = <0.004, 1    , 0.439>;
vector YELLOW  = <1    , 0.863, 0    >;
vector ORANGE  = <1    , 0.522, 0.106>;
vector RED    = <1    , 0.255, 0.212>;
vector MAROON  = <0.522, 0.078, 0.294>;
vector FUCHSIA = <0.941, 0.071, 0.745>;
vector PURPLE  = <0.694, 0.051, 0.788>;
vector WHITE  = <1    , 1    , 1    >;
vector SILVER  = <0.867, 0.867, 0.867>;
vector GRAY    = <0.667, 0.667, 0.667>;
vector BLACK  = <0.000, 0.000, 0.000>;


string  hoverText  = "TEXT GOES HERE";
vector  hoverColor  = LIME;//  set predefined color or any RGB color vector in float form
float  hoverAlpha  = 1.0; // Sets the text's transparency, 1.0 being opaque, while 0.0 would be transparent


== Wrapping ==
default
By default, any floating text will appear on a single line. Sometimes these single lines of floating text can be absurdly long.
{
 
    state_entry()
However, the floating text can be spread over multiple lines by inserting line breaks ("\n").
    {
 
        llSetText(hoverText, hoverColor, hoverAlpha);
You can do this manually, or by using functions such as [[SplitLine]] (which requires separators to be in the text), or [[WrapText]] (which does not require separators in the text and allows you to specify the line-length you feel best.)
    }
 
}
 
</syntaxhighlight>
|examples=
To make hovertext when using linked prims you can use this simple function:
 
<syntaxhighlight lang="lsl2">
'''Example: Manual multiple line'''
mySetLinkText(integer linknum, string text, vector color, float alpha) {
<lsl>
    llSetLinkPrimitiveParamsFast(linknum, [PRIM_TEXT, text, color, alpha]);
llSetText("I am \n on two lines!", <0.0, 1.0, 0.0>, 1.0);
}
</lsl>
 
 
'''Example: Including llSetText in default code''' to show object's name in green text:
<lsl>
default{
    state_entry() {
          llSay(0, "Hello, Avatar!");
          llSetText(llGetObjectName(), <0.0, 1.0, 0.0>, 1.0); // Display object's name in green
    }
    touch_start(integer total_number){
          llSay(0, "Touched.");
    }
}
</lsl>
 
 
'''Example: Use prim name as the text, wrapped to display on several lines'''


<lsl>
// For example:


string WrapText(string pcText, integer piWidth) {
default
     list    laLines  = [];
{
    integer  liIndex;
     touch_start(integer total_number)
    integer  liKeep;  // Specifies if we keep the char pointed at or not
     {
    integer liLen    = llStringLength(pcText);
         mySetLinkText(LINK_SET, "TEST", <0, 1, 0>, 0.5);
     list    llSearch = [" ", "\n"];
   
    while (liLen > 0) {
         liIndex = piWidth;
        if (!(liKeep = (liLen <= piWidth))) {
            while ((liIndex >= 0) && (-1 == llListFindList(llSearch, (list)llGetSubString(pcText, liIndex, liIndex))))
                --liIndex;
            if (liIndex <= 0) {
                liIndex = piWidth;
                liKeep = 1;
            }
        }
        laLines += llGetSubString(pcText, 0, liIndex - 1);
        pcText = llDeleteSubString(pcText, 0, liIndex - liKeep);
        liLen -= (1 + liIndex - liKeep);
     }
     }
    return llDumpList2String(laLines,"\n");
}
}
 
</syntaxhighlight>
 
default {
    state_entry() {
          string tmp = WrapText(llGetObjectName(),25);
          llSetText(tmp, <1.0, 1.0, 1.0>, 1.0); // Display object's name in solid white
    }
}
</lsl>
 
 
'''Example: Colours'''
 
<lsl>
vector white = <1.0, 1.0, 1.0>;
vector red = <1.0, 0.0, 0.0>;
vector green = <0.0, 1.0, 0.0>;
vector blue = <0.0, 0.0, 1.0>;
vector grey = <0.5, 0.5, 0.5>;
vector black = <0.0, 0.0, 0.0>;
</lsl>
<1.0, 1.0, 1.0> represents the values for red, green, and blue.
<1.0, 1.0, 1.0>, means "white" and <0.0, 0.0, 0.0> means "black":
<lsl>
llSetText("I am on", <1.0, 1.0, 1.0>, 1.0);
</lsl>
<lsl>
llSetText("I am off", <0.0, 0.0, 0.0>, 1.0);
</lsl>
 
'''Example: Alpha (transparency)'''
 
The 1.0 is the alpha setting. 1.0 means fully opaque (aka solid), and 0.0 would be completely transparent (invisible):
<lsl>
llSetText("alpha", <0.0, 1.0, 0.0>, 0.5);
</lsl>
 
|also
|also
|also_functions
|also_functions
|also_constants=
{{LSL DefineRow||[[PRIM_TEXT]]}}
|also_articles=
|also_articles=
{{LSL DefineRow||[[:Category:LSL Examples|Examples]]: [[SplitLine]]|Insert 'new line' escape codes at certain positions of a string}}
{{LSL DefineRow||[[:Category:LSL Examples|Examples]]: [[SplitLine]]|Insert 'new line' escape codes at certain positions of a string}}
{{LSL DefineRow||Useful snippet: [[llGetObjectPermMask]]|Label an object with text and newlines to give away or sell}}
{{LSL DefineRow||Useful snippet: [[llGetObjectPermMask]]|Label an object with text and newlines to give away or sell}}
{{LSL DefineRow||[[escape codes]]|for details on how and when they work}}
|notes=To actually display text on a prim, see [[XyzzyText]], or consider using parcel prim [[:Category:LSL_Media|Media]] options (useful only if you have control over the land's media settings.)
----
The function displays {{LSLP|text}} that hover over the prim's center, the prim position. The height over the center is proportional to the prim's Z-dimension exclusively
* It doesn't matter how the prim is rotated, so if Z is smaller than X and Y the {{LSLP|text}} may be seen {{LSLP|on}} the prim
|cat1=Effects
|cat1=Effects
|cat2=Prim
|cat2=Prim
|cat3
|cat3=Stop
|cat4
|cat4=Floating Text
}}
}}

Latest revision as of 13:19, 26 May 2024

Summary

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

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

• string text floating 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

  • Do not rely on Floating Text as a storage medium; it is neither secure nor finalized.
    • Floating text has been altered in past server updates, breaking existing content; future changes may occur.
    • Even "invisible"[1] floating text is transmitted to the client.
      • It can be viewed by anyone with a client that is capable of rendering text that is supposed to be invisible.
      • The network packets that contain the text can be sniffed and the text read.
  • 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 (compare Limits#Building) in UTF-8 encoding. If the string is longer it will be truncated to 254 bytes, and any multibyte characters getting split will be removed entirely.
  • An unbroken line of text of a great length may be broken automatically into two lines (one above the other).
  • text can be seen through walls and other object. Be considerate of neighbors in malls and apartment buildings.
    • Visibility distance increases with prim size.
  • Removing the script or deactivating it will not remove a prim's text property. Floating text is not dependent on a script for its continued existence but only when wanting to change it.
  • To remove a prim's text, use the following:
Preferred method to remove a prim's floating text Second method does the same effect-wise.
//  empty string & black & transparent
    llSetText("", ZERO_VECTOR, 0);
//  empty string & black & transparent
    llSetText("", <0.0, 0.0, 0.0>, 0.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.
  • Multiple linebreaks with empty lines are converted to a single linebreak, so add a whitespace character on every line you want to skip:
Good Bad
    vector COLOR_WHITE = <1.0, 1.0, 1.0>;
    float  OPAQUE      = 1.0;

    llSetText("Monkeys\n \n \n \n \n ", COLOR_WHITE, OPAQUE);
    vector COLOR_WHITE = <1.0, 1.0, 1.0>;
    float  OPAQUE      = 1.0;

    llSetText("Monkeys\n\n\n\n\n", COLOR_WHITE, OPAQUE);
  • Measurements showed a high impact of process time when doing numerous iterations in a while loop. For approx. 65 thousand iterations the process times are ca. 5 seconds without floating text, 24 seconds with llSetText and 96 seconds when using llSetPrimitiveParams#llSetLinkPrimitiveParamsFast in combination with PRIM_TEXT. Thats why you are not advised to make excessive use of changing a prim's text within such iterations.

Examples

Example of how llSetText could be used to show prim's name in green text:

default
{
    state_entry()
    {
        vector COLOR_GREEN = <0.0, 1.0, 0.0>;
        float  OPAQUE      = 1.0;

//      prim's name (not necessarily object's)
        llSetText(llGetObjectName(), COLOR_GREEN, OPAQUE );

//      delete the script as we only needed it to change the floating text property
        llRemoveInventory(llGetScriptName());
    }
}

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

String escape codes:

LSL has four string escape codes:

  • \n for a new line
  • \\ for a backslash
  • \t for a tab
  • \" for a double-quote

Color & Alpha

Color Code
NAVY <0.000, 0.122, 0.247>
BLUE <0.000, 0.455, 0.851>
AQUA <0.498, 0.859, 1.000>
TEAL <0.224, 0.800, 0.800>
OLIVE <0.239, 0.600, 0.439>
GREEN <0.180, 0.800, 0.251>
LIME <0.004, 1.000, 0.439>
YELLOW <1.000, 0.863, 0.000>
ORANGE <1.000, 0.522, 0.106>
RED <1.000, 0.255, 0.212>
MAROON <0.522, 0.078, 0.294>
FUCHSIA <0.941, 0.071, 0.745>
PURPLE <0.694, 0.051, 0.788>
WHITE <1.000, 1.000, 1.000>
SILVER <0.867, 0.867, 0.867>
GRAY <0.667, 0.667, 0.667>
BLACK <0.000, 0.000, 0.000>

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

//  white & opaque
    llSetText("I am white", <1.0, 1.0, 1.0>, 1.0);
    vector myColor;// defaults to ZERO_VECTOR or <0.0, 0.0, 0.0> which is black

    llSetText("I am black and 30% transparent.", myColor, 0.7);

    llSleep(7.5);   // before: <0.0, 0.0, 0.0> black
    myColor.x = 1.0;// now:    <1.0, 0.0, 0.0> red

    llSetText("I am now red and 10% transparent.", myColor, 0.9);

If alpha is 1.0 it means the text is fully opaque (alpha), 0.0 would make it completely transparent (invisible):

    llSetText("green text with alpha 0.7", <0.0, 1.0, 0.0>, 0.7);

    llSetText("white text with alpha 0.4\n60% transparent", <1.0, 1.0, 1.0>, 0.4);
    llSetText("white text with alpha 1.0\nfully opaque", <1.0, 1.0, 1.0>, 1.0);

//  next to lines have the same effect
    llSetText("invisible black text with alpha 0.0\nfully transparent", ZERO_VECTOR, 0);
    llSetText("invisible black text with alpha 0.0\nfully transparent", <0.0, 0.0, 0.0>, 0.0);

Multiple lines

//  two lines of orange text

    llSetText("I am\non two lines!", <1.0, 0.4, 0.0>, 1.0);

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()
    {
//      remove floating text (empty string & black & 100% transparent)
        llSetText("", ZERO_VECTOR, 0.0);

//      delete the script as we only needed it to change the floating text property
        llRemoveInventory(llGetScriptName());
    }
}

Code to easily specify appearance of hovertext:

vector NAVY    = <0,     0.122, 0.247>;
vector BLUE    = <0,     0.455, 0.851>;
vector AQUA    = <0.498, 0.859, 1    >;
vector TEAL    = <0.224, 0.8,   0.8  >;
vector OLIVE   = <0.239, 0.6,   0.439>;
vector GREEN   = <0.18,  0.8,   0.251>;
vector LIME    = <0.004, 1    , 0.439>;
vector YELLOW  = <1    , 0.863, 0    >;
vector ORANGE  = <1    , 0.522, 0.106>;
vector RED     = <1    , 0.255, 0.212>;
vector MAROON  = <0.522, 0.078, 0.294>;
vector FUCHSIA = <0.941, 0.071, 0.745>;
vector PURPLE  = <0.694, 0.051, 0.788>;
vector WHITE   = <1    , 1    , 1    >;
vector SILVER  = <0.867, 0.867, 0.867>;
vector GRAY    = <0.667, 0.667, 0.667>;
vector BLACK   = <0.000, 0.000, 0.000>;

string  hoverText   = "TEXT GOES HERE";
vector  hoverColor  = LIME;//  set predefined color or any RGB color vector in float form
float   hoverAlpha  = 1.0; // Sets the text's transparency, 1.0 being opaque, while 0.0 would be transparent

default
{
    state_entry()
    {
        llSetText(hoverText, hoverColor, hoverAlpha);
    }
}

To make hovertext when using linked prims you can use this simple function:

mySetLinkText(integer linknum, string text, vector color, float alpha) {
    llSetLinkPrimitiveParamsFast(linknum, [PRIM_TEXT, text, color, alpha]);
}

// For example:

default
{
    touch_start(integer total_number)
    {
        mySetLinkText(LINK_SET, "TEST", <0, 1, 0>, 0.5);
    }
}

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.)


The function displays text that hover over the prim's center, the prim position. The height over the center is proportional to the prim's Z-dimension exclusively

  • It doesn't matter how the prim is rotated, so if Z is smaller than X and Y the text may be seen on the prim

See Also

Constants

•  PRIM_TEXT

Articles

•  Limits SL limits and constrictions
•  Color in LSL
•  Translucent Color
•  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
•  escape codes for details on how and when they work

Deep Notes

Footnotes

  1. ^ Floating text with an alpha set to 0.0 is rendered "invisible"

Signature

function void llSetText( string text, vector color, float alpha );