Who Is Online


Tuesday, 26 September 2017 06:12

Random Color Changer

//  Random Color Changer
//  Created by Water Rogers for IBM/Opensource
//  Purpose
//  --------------------------------------------------------------
//  This is a basic example of how you can randomize color
//  It aso shows simple on/off functionality and introduces
//  the llMessageLinked() concept for communicating between
//  multiple objects/scripts of the same link set.
//  Requirements
//  --------------------------------------------------------------
//  A single prim is all that is necessary for this example.
//  --------------------------------------------------------------
float   g_Timer     = 5.0;        //  How fast to change colors (seconds)
integer g_RandomOn  = TRUE;       //  The on/off switch for randomizing
//  --------------------------------------------------------------
        //  ------------------------------------------------------
        //  This is the entry-point of the script.  After a script
        //  has been saved or reset, this event will fire off first
        //  ------------------------------------------------------
        //  Here we set up a simple timer to fire off once every g_Timer
        //  seconds
    touch_start(integer num_detected)
        g_RandomOn = !g_RandomOn;
        if(g_RandomOn) llSetTimerEvent(g_Timer);
        else llSetTimerEvent(0);
        //  This event is called each g_Timer seconds as declared
        //  previously in the state_entry() event.
        //  llSetColor() will change the color of an object taking
        //  vector color and integer face as arguments.  the color
        //  vector is in this form: <float R, float G, float B> where
        //  <0,0,0> = Black and <1,1,1> = White.  In between 0 and 1
        //  is the focus of our different color values, which is why
        //  we use llFrand() to generate a random float number between
        //  0 and 1.  ALL_SIDES is a bit-field global to tell the script
        //  that we want all faces of the object colored -- otherwise
        //  we could specify a particular face to color using the
        //  integer representation of the face.
        vector rand_color = <llFrand(1), llFrand(1), llFrand(1)>;
        llSetColor(rand_color, ALL_SIDES);
        //  We also want to control the color of the beam.  Since
        //  llSetColor() only affects the object the script is contained
        //  in, we need to send a message to the beam object within the
        //  link set.  The best way to do this is to send a message
        //  using llMessageLinked().  This works much like a listen
        //  command, except the object only talks to other objects
        //  that are linked to it, making it much more secure.
        llMessageLinked(LINK_SET, 1, (string)rand_color, NULL_KEY);


Flash Scratch to SL - Your Scripting Tool

Script ImageNeed to write a LSL script and don't know how to script?  I know I hate trying to get my head around LSLS when I an in a time crunch. So why not give Flash Scratch a try! Its a great tool for learning and scoding your own scripts for Second Life without having to pay someone to do it and without a crash course in LSL

A Huge thanks to John Bennet of ATLAS Institute at University of Colorado and Eric Rosenbaum at MIT for writing Scratch for SL to begin with.

Read more: Flash Scratch to SL - Your Scripting Tool