LSL feature request. The described function does not exist. This article is a feature request.

If a prim exists in the link chain at linknumber, displays text that hovers over the prim with specific color and translucency (specified with alpha).

Syntax

void llSetLinkText( integer linknumber, string text, vector color, float alpha );

Forced delay: 0.0 seconds. Energy: 10.0.

Parameters

integer linknumber
Link number (0: unlinked, 1: root prim, >1: child prims and seated avatars) or a LINK_* flag
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)

See: SVC-2367

Specification

Note that this feature was added under a different name, see PRIM_TEXT.

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

Constants

FlagDescription
LINK_ROOT1refers to the root prim in a multi-prim linked set[1]
LINK_SET-1refers to all prims
LINK_ALL_OTHERS-2refers to all other prims
FlagDescription
LINK_ALL_CHILDREN-3refers to all children, (everything but the root)
LINK_THIS-4refers to the prim the script is in

Caveats

llSetLinkText(linknumber, "", <1.0, 1.0, 1.0>, 1.0);
llSetLinkText(LINK_THIS, "Doesn't work...\n", <1.0, 0.0, 0.0>, 1.0);
llSetLinkText(LINK_THIS, "It works!\n ", <0.0, 1.0, 0.0>, 1.0);

Examples

Example of how llSetLinkText could be used to show prims names and link numbers in red text:

default
{
    state_entry()
    {
         integer link = llGetNumberOfPrims();
	 for (; link >= 0; --link)
	 {
             llSetLinkText(link, (string)link + ": " + llGetLinkName(link), <1.0, 0.0, 0.0>, 1.0);
         }
    }
}

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

llSetLinkText(LINK_THIS, "First line\nSecond line", <1.0, 1.0, 1.0>, 1.0);

Color & Alpha

ColorCode
White<1.0, 1.0, 1.0>
Gray<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 then 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":

llSetLinkText(LINK_THIS,"White", <1.0, 1.0, 1.0>, 1.0);
llSetLinkText(LINK_THIS, "Black", <0.0, 0.0, 0.0>, 1.0);

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

llSetLinkText(LINK_THIS, "Half transparent green", <0.0, 1.0, 0.0>, 0.5);

Useful snippets

Create this script in inventory and drag it onto an object to erase all its set texts:

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

Notes

Link Numbers

Each prim that makes up an object has an address, a link number. To access a specific prim in the object, the prim's link number must be known. In addition to prims having link numbers, avatars seated upon the object do as well.

When an avatar sits on an object, it is added to the end of the link set and will have the largest link number. In addition to this, while an avatar is seated upon an object, the object is unable to link or unlink prims without unseating all avatars first.

Counting Prims & Avatars

There are two functions of interest when trying to find the number of prims and avatars on an object.

integer GetPrimCount() { //always returns only the number of prims
    if(llGetAttached())//Is it attached?
        return llGetNumberOfPrims();//returns avatars and prims but attachments can't be sat on.
    return llGetObjectPrimCount(llGetKey());//returns only prims but won't work on attachments.
}

See llGetNumberOfPrims for more about counting prims and avatars.

Errata

If a script located in a child prim erroneously attempts to access link 0, it will get or set the property of the linkset's root prim. This bug (BUG-5049) is preserved for broken legacy scripts.

If you use LINK_THIS as linknumber, this function will have the same effect than llSetText

See also

Functions

Articles

Footnotes

  1. LINK_ROOT does not work on single prim objects. Unless there is an avatar sitting on the object.