Difference between revisions of "LlSetLinkText"

From Second Life Wiki
Jump to navigation Jump to search
m
(format +pointer to PRIM_TEXT)
Line 11: Line 11:
|func_footnote=See: {{Jira|SVC-2367}}
|func_footnote=See: {{Jira|SVC-2367}}
|return_text
|return_text
|spec=
|spec=Note that this feature was added under a different name, see [[PRIM_TEXT]].
<source lang="lsl2">
SetLinkText(integer linknumber, string text, vector color, float alpha)
{
    llSetLinkPrimitiveParamsFast(linknumber, [PRIM_TEXT, text, color, alpha]);
}
</source>
|caveats=
|caveats=
*'''text''' is limited to 254 bytes, if the string is longer it will be truncated to 254 bytes.
*'''text''' is limited to 254 bytes, if the string is longer it will be truncated to 254 bytes.
Line 20: Line 26:
**Floating text is a prim property and does not depend on the script which set it to continue to exist.
**Floating text is a prim property and does not depend on the script which set it to continue to exist.
*To remove floating text from the prim number '''linknumber''', use the following:
*To remove floating text from the prim number '''linknumber''', use the following:
<lsl>llSetLinkText(linknumber, "", <1.0, 1.0, 1.0>, 1.0);</lsl>
<source lang="lsl2">llSetLinkText(linknumber, "", <1.0, 1.0, 1.0>, 1.0);</source>
*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:
*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:
<lsl>llSetLinkText(LINK_THIS, "Doesn't work...\n", <1.0, 0.0, 0.0>, 1.0);
<source lang="lsl2">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);</lsl>
llSetLinkText(LINK_THIS, "It works!\n ", <0.0, 1.0, 0.0>, 1.0);</source>
|examples=
|examples=
Example of how llSetLinkText could be used to show prims names and link numbers in red text:
Example of how llSetLinkText could be used to show prims names and link numbers in red text:
<lsl>default
<source lang="lsl2">default
{
{
     state_entry()
     state_entry()
Line 36: Line 42:
         }
         }
     }
     }
}</lsl>
}</source>
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').
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').
<lsl>llSetLinkText(LINK_THIS, "First line\nSecond line", <1.0, 1.0, 1.0>, 1.0);</lsl>
<source lang="lsl2">llSetLinkText(LINK_THIS, "First line\nSecond line", <1.0, 1.0, 1.0>, 1.0);</source>
===Color & Alpha===
===Color & Alpha===
{{{!}} class="sortable" {{Prettytable|style=float:right; margin-top:0;}}
{{{!}} class="sortable" {{Prettytable|style=float:right; margin-top:0;}}
Line 64: Line 70:
{{!}}}
{{!}}}
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":
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":
<lsl>llSetLinkText(LINK_THIS,"White", <1.0, 1.0, 1.0>, 1.0);</lsl>
<source lang="lsl2">llSetLinkText(LINK_THIS,"White", <1.0, 1.0, 1.0>, 1.0);</source>
<lsl>llSetLinkText(LINK_THIS, "Black", <0.0, 0.0, 0.0>, 1.0);</lsl>
<source lang="lsl2">llSetLinkText(LINK_THIS, "Black", <0.0, 0.0, 0.0>, 1.0);</source>
The 1.0 is the alpha setting. 1.0 means fully opaque, and 0.0 would be completely transparent (invisible):
The 1.0 is the alpha setting. 1.0 means fully opaque, and 0.0 would be completely transparent (invisible):
<lsl>llSetLinkText(LINK_THIS, "Half transparent green", <0.0, 1.0, 0.0>, 0.5);</lsl>
<source lang="lsl2">llSetLinkText(LINK_THIS, "Half transparent green", <0.0, 1.0, 0.0>, 0.5);</source>
|helpers=
|helpers=
Create this script in inventory and drag it onto an object to erase all its set texts:
Create this script in inventory and drag it onto an object to erase all its set texts:
<lsl>// http://wiki.secondlife.com/wiki/llSetLinkText
<source lang="lsl2">// http://wiki.secondlife.com/wiki/llSetLinkText
default
default
{
{
Line 78: Line 84:
         llRemoveInventory(llGetScriptName());
         llRemoveInventory(llGetScriptName());
     }
     }
}</lsl>
}</source>
|notes=If you use [[LINK_THIS]] as '''linknumber''', this function will have the same effect than [[llSetText]]
|notes=If you use [[LINK_THIS]] as '''linknumber''', this function will have the same effect than [[llSetText]]
|also
|also

Revision as of 06:35, 11 April 2015

Emblem-important-yellow.png LSL Feature Request
The described function does not exist. This article is a feature request.

Summary

Function: llSetLinkText( integer linknumber, string text, vector color, float alpha );
REQUEST Function ID
0.0 Forced Delay
10.0 Energy

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

• 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]);
}
Flag Description
LINK_ROOT 1 refers to the root prim in a multi-prim linked set[1]
LINK_SET -1 refers to all prims
LINK_ALL_OTHERS -2 refers to all other prims
Flag Description
LINK_ALL_CHILDREN -3 refers to all children, (everything but the root)
LINK_THIS -4 refers to the prim the script is in

Caveats

  • text is limited to 254 bytes, if the string is longer it will be truncated to 254 bytes.
  • 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 prims current floating text or detect when it is changed.
  • Removing the script or deactivating it will not remove the prims floating text.
    • Floating text is a prim property and does not depend on the script which set it to continue to exist.
  • To remove floating text from the prim number linknumber, use the following:
llSetLinkText(linknumber, "", <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:
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);
All Issues ~ Search JIRA for related Bugs

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

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

  • If an object consists of only one prim, and there are no avatars seated upon it, the (root) prim's link number is zero.
  • However, if the object is made up of multiple prims or there is an avatar seated upon the object, the root prim's link number is one.

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

•  llGetLinkNumber Returns the link number of the prim the script is in.
•  llSetText

Articles

•  Color in LSL
•  Translucent Color
•  Examples: SplitLine Insert 'new line' escape codes at certain positions of a string

Deep Notes

Search JIRA for related Issues

Footnotes

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

Signature

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