Difference between revisions of "LlSetText"

From Second Life Wiki
Jump to navigation Jump to search
m (Cover only LSL with LSL tags, not also the natural language that follows without the // prefix it needs inside of LSL tags)
m
Line 1: Line 1:
{{LSL Function/color|color}} {{LSL Function/alpha|alpha}}{{LSL_Function
{{multi-lang}}{{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 14: Line 14:
*A script calling llSetText cannot know if it is or is not changing the floating text, since there is no [[llGetText]] function.
*A script calling llSetText cannot know if it is or is not changing the floating text, since there is no [[llGetText]] function.
*The floating text is a property of the prim and not the script, thus the text will remain if the script is deactivated or removed.
*The floating text is a property of the prim and not the script, thus the text will remain if the script is deactivated or removed.
**To remove floating text, one must assign an empty string with llSetText("", <1.0, 1.0, 1.0>, 1.0);
**To remove floating text, one must assign an empty string with:
*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>
**Bad: llSetText("Monkeys\n\n\n\n\n", <1.0, 1.0, 1.0>, 1.0);
llSetText("", <1.0, 1.0, 1.0>, 1.0);
**Good: llSetText("Monkeys\n\n\n\n\n ", <1.0, 1.0, 1.0>, 1.0);
</lsl>
 
*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>
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
</lsl>
|examples=
|examples=
Example of how llSetText could be included in default code to show object's name in green text:
Example of how llSetText could be included in default code to show object's name in green text:
Line 45: Line 51:
vector black = <0.0, 0.0, 0.0>;
vector black = <0.0, 0.0, 0.0>;
</lsl>
</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":
<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>
<lsl>
llSetText("I am on", <1.0, 1.0, 1.0>, 1.0);
llSetText("I am on", <1.0, 1.0, 1.0>, 1.0);
Line 54: Line 61:
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>
<lsl>
    llSetText("alpha", <0.0, 1.0, 0.0>, 0.5);
llSetText("alpha", <0.0, 1.0, 0.0>, 0.5);
</lsl>
</lsl>
Multiple lines:
Multiple lines:
<lsl>
<lsl>
    llSetText("I am \n on two lines!", <0.0, 1.0, 0.0>, 1.0);
llSetText("I am \n on two lines!", <0.0, 1.0, 0.0>, 1.0);
</lsl>
</lsl>
|helpers=
|helpers=

Revision as of 22:54, 8 January 2008

Summary

Function: llSetText( string text, vector color, float alpha );

Displays text over a prim with specific color and transparency (specified with alpha).

• string text text to display between the quotes
• 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

  • A script calling llSetText cannot know if it is or is not changing the floating text, since there is no llGetText function.
  • The floating text is a property of the prim and not the script, thus the text will remain if the script is deactivated or removed.
    • To remove floating text, one must assign an empty string with:

<lsl> llSetText("", <1.0, 1.0, 1.0>, 1.0); </lsl>

  • 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> 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 </lsl>

All Issues ~ Search JIRA for related Bugs

Examples

Example of how llSetText could be included 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> 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'). Example colors: <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> The 1.0 is the alpha setting. 1.0 means fully opaque, and 0.0 would be completely transparent (invisible): <lsl> llSetText("alpha", <0.0, 1.0, 0.0>, 0.5); </lsl> Multiple lines: <lsl> llSetText("I am \n on two lines!", <0.0, 1.0, 0.0>, 1.0);

</lsl>

Useful Snippets

Drag this script out of inventory onto an object to erase its set text: <lsl> // http://wiki.secondlife.com/wiki/llSetText default {

   state_entry()
   {
       llSetText("", <0.0, 0.0, 0.0>, 0.0);
       llRemoveInventory(llGetScriptName());
   }

} </lsl>

See Also

Articles

•  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

Deep Notes

Search JIRA for related Issues

Signature

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