Jump to content
Sign in to follow this  
pLiCk Mixmaster

colour changing lights

Recommended Posts

im sure this has been up before but the ones i saw didnt use the script i found. i am new to scripting in fact i used to code on c64 and thats it so dont really know the new stuff, even though it looks familiar......my question i found a script that turns on and off lights and i am trying to change the colour in it. i have been playing around with the colour vector but nothing is changing

 

// V1 //
 
vector color = <1.0, 1.0, 1.0>; // R,G,B (red, green, blue) values.
 
float intensity = 1.0;          // 0.0 to 1.0 (1.0 = full brightness)
 
float radius = 20.0;            // 0.1 to 20.0 (20.0 = full sphere)
 
float falloff = 0.01;           // 0.01 to 2.0 (2.0 = least spread)
 
/////////////////////////////////////////////////////////////////////////
 
integer on; // Global variable used to measure the condition 'on or off'.
 
Switch() // The switching function.
{
    on = (!on); // Flip the boolean value of the integer 'on'.
    llSetPrimitiveParams([PRIM_POINT_LIGHT, on, color, intensity, radius, falloff]);
}
 
default
{
    touch_end(integer nd)
    {
        Switch(); // Unconditionally call the switch to operate.
    }
}

 

 

pleas help on how i can change the colour, and i actually want to understand

Share this post


Link to post
Share on other sites

You have the syntax for the llSetPrimitiveParams function in your script already, although I would use llSetLinkPrimitiveParamsFast instead because it doesn't have a delay built into it.  

Color vectors in SL are normalized RGB vectors, so <255.0,255.0,255.0> (white) is <1.0,1.0,1.0> in SL.  To translate "ordinary" RGB into something useful here, then, simply divide each value by 255.0.  See https://wiki.secondlife.com/wiki/Category:LSL_Color and, even more useful, http://lslwiki.net/lslwiki/wakka.php?wakka=color .

If you want to change colors interactively instead of digging into the script each time you want to change the value of your color vector, one way to do it would be to load a set of vectors into a list and then offer the options in a dialog

 

  • Thanks 1

Share this post


Link to post
Share on other sites

This line works but it's bad style:

on = (!on); // Flip the boolean value of the integer 'on'.

Don't need any brackets there, they don't do anything. The customary style is

on = !on; // Flip the boolean value of the integer 'on'.

Share this post


Link to post
Share on other sites

To change the color of the light:

SetPrimitiveParams(PRIM_POINT_LIGHT,integer bolean on/off, vector<color>, float intensity, float radius, float falloff)

example:

SetPrimitiveParams(PRIM_POINT_LIGHT,0, <1.0,0.1,0.0>, 0.75, 8.0, 0.57);

or

vector color = <0.0,0.0,1.0>;   // pure blue ("colour" if you are British =D)

list lights_on = [1,color,1.0,10.0,0.75];

SetPrimitiveParams(lights_on);

 

  1. To use PRIM_POINT_LIGHT all 5 fields must contain data.
  2. A named variable can be used for any data field
  3. You can use a predefined LIST for the data but to change any variable data the list must be re-defined; ie, list light_on = [1,color,intens,rad,falloff];  - but once defined, this list will not change even if the named variables do untill you redefine the list. You can change or replace one element in the list without redefining the entire list with llListReplaceList().
  4. "radius" defines how far in meters the light will extend (effect objects)
  5. "fall off" usually discribes (in most 3D software) how far from the origin light the light will fall to half intensity. In Second Life,  this is a percentage, 0 to 1, and seems to discribe the light intensity at the maximum set radius. A light with 20 meter radius and .5 (50%) falloff, the light intensity at 20 meters will appear 50% of the original intensity. This may not be what this number actually represents but it is the overall effect of this number.

sugestion: be carefull with your effect radius and adjust it according to the type of light it's coming from if you want to be "realistic" A camp fire in RL has a lighting effect out to about 15 feet or 5 meters. If you set it to 20 meters with no fall off it will light up things too far away to be realistic.

PS. I also learned on a C64, Basic and 6500 machine code.

 

  • Thanks 1

Share this post


Link to post
Share on other sites

After re-reading  your post I see that your question is more about a method to change the color rather than an explination of the light itself. 

in your touch_start state you could call another function that returns a random color vector or include the randome routine within the touch state itself.

You could do as Rolig Loon suggests and present pre-set colors in a dialog

You could link a touch pad to the light with a grid of different colors that when touched would message the light with the new color vector values. Use llDetectedTouchST() or llDetectedTouchUV() which ever works best for the selector texture and llMessageLinked() + link_message() for communication between prims.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...