Difference between revisions of "User:Toady Nakamura/Random Color"

From Second Life Wiki
Jump to navigation Jump to search
m (put up this simple randomizing script for beginning student's of LSL reference)
 
m (pretty page)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
In SL, color is composed of three elements (Red, Green, Blue) in values from zero to 1.0;
In SL, color is composed of three elements (Red, Green, Blue) in values from zero to 1.0;
thus randomizing using llFrand(1.0) works well because the values to randomize within are from zero to 1.0


White is <1.0,1.0,1.0> and Black is <0.0,0.0,0.0> although you may see it as Black is <FALSE,FALSE,FALSE>
<small>White is <1.0,1.0,1.0> ( or <TRUE, TRUE, TRUE>)  ~~ Black is <0.0,0.0,0.0> or <FALSE,FALSE,FALSE>   ... because TRUE is 1 and FALSE is 0.  </small>
because TRUE is 1 and FALSE is 0.  LSL automatically accepts float numbers (with decimals) for integers and
 
LSL automatically accepts float numbers (with decimals) for integers and
opposite.  It's called "implicit typecasting."
opposite.  It's called "implicit typecasting."


Independent randomizing of red, green and blue is done by the use of LSL function llFrand(value).
Included is how to change prim color for both a single prim and a linked set.


Use the "//" comment slashes to activate the line you wish to use, and be sure to deactivate the line you don't want!




<lsl>
<source lang = "lsl2">
default  
default  
{
{
Line 19: Line 23:
     timer()  
     timer()  
     {
     {
    // To only change the prim this script is in - use this line
         llSetColor(<llFrand(1.0),llFrand(1.0),llFrand(1.0)>, ALL_SIDES);
         llSetColor(<llFrand(1.0),llFrand(1.0),llFrand(1.0)>, ALL_SIDES);
        //randomizes Red, Green & Blue independently & changes all sides of the prim.
 
    // To change the entire linkset - use this line instead
 
      //llSetLinkColor(LINK_SET, <llFrand(1.0),llFrand(1.0),llFrand(1.0)>, ALL_SIDES);
     }
     }
}
}
</lsl>
</source>
 
Visit my SL wiki page for more simple scripts.  [[User:Toady Nakamura|Toady Nakamura]]

Latest revision as of 15:02, 30 July 2015

In SL, color is composed of three elements (Red, Green, Blue) in values from zero to 1.0;

White is <1.0,1.0,1.0> ( or <TRUE, TRUE, TRUE>) ~~ Black is <0.0,0.0,0.0> or <FALSE,FALSE,FALSE> ... because TRUE is 1 and FALSE is 0.

LSL automatically accepts float numbers (with decimals) for integers and opposite. It's called "implicit typecasting."

Independent randomizing of red, green and blue is done by the use of LSL function llFrand(value).

Included is how to change prim color for both a single prim and a linked set.

Use the "//" comment slashes to activate the line you wish to use, and be sure to deactivate the line you don't want!


default 
{
    state_entry() 
    {
        llSetTimerEvent(2.0); // call a timer event every 2 seconds
    }

    timer() 
    {

    // To only change the prim this script is in - use this line

        llSetColor(<llFrand(1.0),llFrand(1.0),llFrand(1.0)>, ALL_SIDES);

    // To change the entire linkset - use this line instead

       //llSetLinkColor(LINK_SET, <llFrand(1.0),llFrand(1.0),llFrand(1.0)>, ALL_SIDES);
    }
}

Visit my SL wiki page for more simple scripts. Toady Nakamura