Jump to content

bounds error, pls help


Rhemah
 Share

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

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

Recommended Posts

inout(){
        float alpha = 1.0;
        float glow  = 1.0;
        while (alpha >= 0.0)
        {
            alpha -= 0.001;
            glow  -= 0.01;
            llSetLinkAlpha(LINK_SET, alpha, ALL_SIDES);
            llSetLinkPrimitiveParamsFast(LINK_THIS,[
            PRIM_GLOW, ALL_SIDES, glow
            ]);
        }
        while (alpha < 1.0)
        {
            alpha += 0.001;
            glow  += 0.01;
            llSetLinkAlpha(LINK_SET, alpha, ALL_SIDES);
            llSetLinkPrimitiveParamsFast(LINK_THIS,[
            PRIM_GLOW, ALL_SIDES, glow
            ]);
        }
    }

can someone help me with this, im getting script error: 

llSetPrimitiveParams error running rule #1 (PRIM_GLOW): bounds error; -0.0899993 is not in (0, 1).

 

Link to comment
Share on other sites

The error message tells the tale: the value of the "glow" variable has gone negative, which is not valid and so llSetLinkPrimitiveParams() gave up.

So why did glow go negative?

For starters, the while loops only test alpha, not glow, and alpha decrements much slower than glow, so glow gets to zero much sooner.

But even if the while condition tested for both alpha and glow, there'd still be a bug with the current logic: it decrements after the test, so the variable could pass the test with a zero or near-zero value, then be decremented below zero and the same problem happens.

It's really not enough to merely test for the values being > 0, as opposed to >=. That's because these are floating point numbers, so subtracting 0.1 from 1.0 ten times may not result in a value exactly == 0.0.

Also, I wonder about the different rates of adjusting these parameters. Once the above loop control bug is corrected, the current logic removse all the glow much sooner than the object becomes transparent, but the opposite when fading back in: first there'd be an intense glow that only later filled-in with opaque surface. That may be the intent, or it may not matter much because glow gets so intense at such low values that it's pretty impossible to see anything anyway.

Link to comment
Share on other sites

There are errors in your logic.

You decrement alpha by 0.001 until it goes under zero. That's about 1001 rounds.
At the same you decrement glow by 0.01 - 1001 times so it will end up at -9.01.
Values must be within 0..1

There is a 2nd error

1st you decrement alpha and glow
then you use that value in llSetLinkPrimitiveParams
and then you test if its >=0 in the condition test of the while loop

So the last round will have a value below zero for alpha since you decrement before using SLPPF. That will cause a run time error too.

Another problem you have is that your script will not work.

What are you doing?
You change an object many 100 or 1000 times per second in a CPU-time-consuming loop.
The server will update your viewer maybe about 15 times per second. That varies.
So your loops will run through and then you will see the result.

Edit: well, didn't test it for llSetLinkAlpha but you can try it out once you fixed the logic. :)

Link to comment
Share on other sites

hello everyone,

thanks for replying; however, umm i understand all your explanation but i can't figure how to. Anyway i want to create something like a ball that fades in and out like breathing, i just got this idea from this site: http://wiki.secondlife.com/wiki/LlSetLinkAlpha, i tried in alpha, and it works fine but it will look more fantastic if it also glow like its breathing. any idea u can recommend?

Link to comment
Share on other sites

try something like this?.. not sure if it's what you want, but you can

 look at the script and see how it works, and mess with settings ?

 

integer amt = 1;float x;  integer k;       default{    state_entry()    {  llSetLinkPrimitiveParamsFast(LINK_THIS,          [ PRIM_GLOW, ALL_SIDES,1.0,            PRIM_COLOR, ALL_SIDES, <1.0, 1.0, 1.0>, 1.0]);    }    touch_start(integer total_number)    { if(k = !k)       llSetTimerEvent(0.05);      else        llSetTimerEvent(0.0);    }     timer()    {    if( llGetAlpha(ALL_SIDES) >= 1.0 ||  llGetAlpha(ALL_SIDES) <= 0.0  )           { amt = -amt;           }                  x +=  -0.01 * amt;         llSetLinkPrimitiveParamsFast(LINK_THIS,          [ PRIM_GLOW, ALL_SIDES,x,            PRIM_COLOR, ALL_SIDES, <1.0, 1.0, 1.0>, x]);             }}
  • Like 1
Link to comment
Share on other sites

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