Urzul Posted July 28, 2013 Share Posted July 28, 2013 Hi,trying to do script to lower the blue or the red darker.look like ++only work on 1+1+1so i get to thisfloat 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 More sharing options...
Rolig Loon Posted July 28, 2013 Share Posted July 28, 2013 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 More sharing options...
PeterCanessa Oh Posted July 29, 2013 Share Posted July 29, 2013 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 More sharing options...
Ela Talaj Posted July 30, 2013 Share Posted July 30, 2013 Yeah...too bad there's no operators overloading in LSL Link to comment Share on other sites More sharing options...
Recommended Posts
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