Difference between revisions of "LlSetLinkText"
Kaluura Boa (talk | contribs) m |
(Undo revision 1196102 by Cerise Sorbet (talk)) |
||
(10 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{LSL_Function | {{LSL_Function | ||
|inject-2={{LSL Function/link|linknumber|nc=*}}{{LSL Function/color|color|nc=*}}{{LSL Function/alpha|alpha|nc=*}} | |||
|func=llSetLinkText | |func=llSetLinkText | ||
|sort=SetLinkText | |sort=SetLinkText | ||
Line 9: | Line 9: | ||
|p4_type=float|p4_name=alpha | |p4_type=float|p4_name=alpha | ||
|func_desc=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'''). | |func_desc=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'''). | ||
|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 19: | 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: | ||
< | <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: | ||
< | <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);</ | 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: | ||
< | <source lang="lsl2">default | ||
{ | { | ||
state_entry() | state_entry() | ||
Line 35: | Line 42: | ||
} | } | ||
} | } | ||
}</ | }</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'). | ||
<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 62: | 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": | ||
< | <source lang="lsl2">llSetLinkText(LINK_THIS,"White", <1.0, 1.0, 1.0>, 1.0);</source> | ||
< | <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): | ||
< | <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: | ||
< | <source lang="lsl2">// http://wiki.secondlife.com/wiki/llSetLinkText | ||
default | default | ||
{ | { | ||
Line 78: | Line 84: | ||
llRemoveInventory(llGetScriptName()); | llRemoveInventory(llGetScriptName()); | ||
} | } | ||
}</ | }</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 | ||
Line 85: | Line 91: | ||
|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}} | ||
|cat1 | |cat1 | ||
|cat2 | |cat2 | ||
|cat3 | |cat3 | ||
|cat4 | |cat4 | ||
}} | }} |
Latest revision as of 08:51, 11 April 2015
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
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 );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]);
}
|
|
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.
- There is no llGetText function or CHANGED_TEXT changed event flag.
- 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);
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.
llGetNumberOfPrims()
- Returns the number of prims and seated avatars.llGetObjectPrimCount(llGetKey())
- Returns only the number of prims in the object but will return zero for attachments.
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.
}
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 |