Jump to content

Color script whit ++


Urzul
 Share

You are about to reply to a thread that has been inactive for 3922 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi,trying to do script to lower the blue or the red darker.

look like ++only work on 1+1+1

so i get to this

float r;

if (choice == "Red+")
        {
            r++;
            llSetLinkPrimitiveParams(link, [ PRIM_COLOR, ALL_SIDES, <r/10, g/10, b/10>, 1.0]);
        }

anything better

 

Link to comment
Share on other sites

Color in SL is described by a vector in the range [ <0.0,0.0,0.0> , <1.0,1.0,1.0> ] ,  If you want to make any one of the three components of a color vector darker,  set its value progressively lower than 1.0. To decrease your value of the red component in steps of 0.05, for example:

if (Choice == "Red+"){    if (r < 19)    {        float R = (float)(++r) / 20.0;        llSetLinkPrimitiveParamsFast(link,[PRIM_COLOR,ALL_SIDES,<1.0 - R,g,b>]);    }}

 

 

 

Link to comment
Share on other sites

 

The increment and decrement operators (++Var, --Var++, Var++ and Var--; watch out for the difference!) do indeed only work for integer values of 1.

They are ultra-short forms of "Var += 1" and "Var -=.1".

Which are short forms of "Var = Var + 1" and "Var = Var - 1".

Kernighan and Ritchie - who developed the C language - wanted to save you a lot of typing :-)  Because incrementing and decrementing variables by one was such a common operation they got their own operators.

Your can add (or subtract) any value, including floats, using the +=/-= form, eg; float r; ... r += 0.1234;

[And because this is the second time in recent days that I've been geeky about the origin of LSL's syntax I'll just add "Thank you Grace Hopper"]

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3922 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...