Difference between revisions of "LlSetText"

From Second Life Wiki
Jump to navigation Jump to search
(Prim catagory)
(Add SplitLine function to section 'See Also')
Line 35: Line 35:
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).  


Example of how llSetText could be included in default code:
Example of how llSetText could be included in default code to show object's name in green text:


  default
  default
Line 42: Line 42:
     {
     {
           llSay(0, "Hello, Avatar!");
           llSay(0, "Hello, Avatar!");
           llSetText("Prize Box", <0.0, 1.0, 0.0>, 1.0);
           llSetText(llGetObjectName(), <0.0, 1.0, 0.0>, 1.0); // Display object's name in green
     }
     }
   
   
Line 51: Line 51:
  }
  }


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".
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 [[Examples|SplitLine]] in section 'See Also').


<pre>
<pre>
Line 58: Line 58:


|helpers
|helpers
|also
|also_functions
|also_functions
|also
|also_articles={{LSL DefineRow||[[Examples|SplitLine]]|Insert 'new line' escape codes at certain positions of a string}}
 
|cat1=Effects
|cat1=Effects
|cat2=Prim
|cat2=Prim

Revision as of 07:24, 5 October 2007

Summary

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

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

• string text text to display between the quotes
• vector color
• float alpha

Caveats

  • 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);
  • 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.
    • Bad: llSetText("Monkeys\n\n\n\n\n", <1.0, 1.0, 1.0>, 1.0);
    • Good: llSetText("Monkeys\n\n\n\n\n ", <1.0, 1.0, 1.0>, 1.0);

Examples

Example colors:

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>;
llSetText("I am on", <1.0, 1.0, 1.0>, 1.0);

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

llSetText("I am off", <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).

Example of how llSetText could be included in default code to show object's name in green text:

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.");
    }
}

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

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

See Also

Articles

•  SplitLine Insert 'new line' escape codes at certain positions of a string

Deep Notes

Signature

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