Jump to content

Transparency & Glow Cycle Script


AngelusWolffe
 Share

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

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

Recommended Posts

Hey folks!

 

Pretty scrubby at LSL, have minor amounts of success here and there.

 

I found the script below and its _perfect_ for what I want, save for it doesn't control glow.

I tried messing around with setprimative stuff but met with no success.

The Script:

 

float   gap = 2.0;
float alpha = 0.3;
integer toggle;
integer flag = -1;
default
{
    state_entry()
    {   llSetLinkAlpha(LINK_SET, 0.3, ALL_SIDES);
        llSensorRepeat("", NULL_KEY, AGENT, 10, PI,2);       
    }
    sensor(integer total_number)
    {  if ( toggle == FALSE )  //  toggle is false, switch it to true and only trigger the timer ONCE when someone is in range
       {    toggle = TRUE;     // toggle is now true, and the IF above will not fire again untill reset
            llSetTimerEvent(0.2); 
       }
    }
    no_sensor()  // reset all variables and turn off timer fading
    {    alpha = 0.3;
         llSetLinkAlpha(LINK_SET, alpha, ALL_SIDES);        
         flag = -1;
         toggle = FALSE;
         llSetTimerEvent(0.0);
    }
    timer()
    {   flag = (++flag % 3);    // add one to the flag variable ... (++flag % 3) ... will loop from 0 to 2 and start at 0 again 
        // fade out      
        while (alpha >= 0.0)
        {   alpha -= 0.0001;  // adjust alpha BEFORE setting it
            llSetLinkAlpha(LINK_SET, alpha, ALL_SIDES);   
        }
        if( flag == 2 )  // every GAP seconds the flag gets increased until it reaches 2 .... this is when the fade IN happens  ONLY when flag is 2
        {  // fade in
           while (alpha < 0.3)
           {   alpha += 0.0001;
               llSetLinkAlpha(LINK_SET, alpha, ALL_SIDES);
           }
        }
         llSetTimerEvent(gap);
    }

--------------------------------------------

All credit to original scripter, but regardless, just looking to add glow cycling into this script :)

 

Any help would be greatly appreciated.

Link to comment
Share on other sites

In the LSL wki, have a look at PRIM_GLOW under the entries for llSetLinPrimitiveParams, it's quite straightforward to use, You'll also be able to adjust the alpha of selected sides using PRIM_COLOR but you will need to get the colour of the side first since it must be present in the list of properties to be set.

 

llSetLinkPrimtiveParams(linkNum, [PRIM_GLOW, side, intensity]);

  • Like 1
Link to comment
Share on other sites

On 10/10/2021 at 4:56 AM, Profaitchikenz Haiku said:

In the LSL wki, have a look at PRIM_GLOW under the entries for llSetLinPrimitiveParams, it's quite straightforward to use, You'll also be able to adjust the alpha of selected sides using PRIM_COLOR but you will need to get the colour of the side first since it must be present in the list of properties to be set.

 

llSetLinkPrimtiveParams(linkNum, [PRIM_GLOW, side, intensity]);

In regards to : llSetLinkPrimtiveParams(linkNum, [PRIM_GLOW, side, intensity]);

 

I see the wiki recommends llSetLinkPrimtiveParamsFast instead. Should I be using that?

Additionally, I'm not quite certain where to place llSetLinkPrimtiveParams(linkNum, [PRIM_GLOW, side, intensity]);

Should I be placing it after the  "llSetLinkAlpha(LINK_SET, alpha, ALL_SIDES);"  entries?

Link to comment
Share on other sites

It won't matter all that much whether you use the -Fast version of the function, but there's no real disadvantage so personally I use it exclusively. Its advantage, when it matters, is that it doesn't have an artificial 200 msec built-in delay that the non-Fast version has, which it inherited from functions such as llSetPos().

As to placement, the alpha and glow operations probably belong next to each other assuming the effects are supposed to be simultaneous. In fact ideally the script would replace the llSetLinkAlpha() with a llSetLinkPrimitiveParamsFast() call that does both the alpha and glow manipulation, but it's slightly tricky because there's no PRIM_ALPHA parameter, and instead we have to use the alpha argument to the PRIM_COLOR parameter, a la

llSetLinkPrimitiveParamsFast(LINK_SET, [
    PRIM_GLOW, ALL_SIDES, glow,
    PRIM_COLOR, ALL_SIDES, <1,1,1>, alpha ]);

assuming the color stays white for everything throughout.

This isn't just about simplifying the script; it's a bit more efficient because both effects are achieved in a single, combined object update rather than one for glow and another for alpha, and a high volume of object updates is one way scripts can lag viewers. This script appears to use tight while-loops to fade visibility in and out, meaning it will emit a lot of object updates, so maybe best not to double them.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1087 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...