Jump to content

I'm getting closer...


JackRipper666
 Share

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

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

Recommended Posts

Hey guys I recently reworked this llSetlinkApha Code. So far I figured out how to make it a lot smaller and almost do what I want lol. But does anyone know how to possibly, make it so that prim 3 in this code isn't show when prim 2 is? Basically it goes and turns one part off and another part on. But prim 2 and 3 turn on at the same time. I'm pretty stumped again on this one lol.

 
default
{
    touch_start(integer num_detected)
    {
       llSetLinkAlpha(1, 0.0, ALL_SIDES);llSetLinkAlpha(2, 1.0, ALL_SIDES);llSetTimerEvent(1.0);llSetLinkAlpha(3,1.0, ALL_SIDES);        
    }
 
    timer()
    {
        llSetLinkAlpha(1, 1.0, ALL_SIDES);llSetLinkAlpha(2, 0.0, ALL_SIDES);llSetTimerEvent(0.0);llSetLinkAlpha(3,0.0, ALL_SIDES); 
    }
}

 

Link to comment
Share on other sites

There´s probably a better way, but I would try something like below to turn one prim at a time invisible:

integer prim;default{    touch_start(integer num_detected)    {        llSetTimerEvent(0.1);        prim = 1;    }     timer()    {        llSetTimerEvent(1.0);        llSetLinkAlpha(prim, 0.0, ALL_SIDES);        integer i = 1;        do {            if (i != prim) llSetLinkAlpha(i, 1.0, ALL_SIDES);        }        while (++i < 4);        ++prim;        if (prim == 5) llSetTimerEvent(0.0);    }}

 

I´m hoping somebody else knows a more elegant way.

Link to comment
Share on other sites


Ron Khondji wrote:

There´s probably a better way, but I would try something like below to turn one prim at a time invisible:
integer prim;default{    touch_start(integer num_detected)    {        llSetTimerEvent(0.1);        prim = 1;    }     timer()    {        llSetTimerEvent(1.0);        llSetLinkAlpha(prim, 0.0, ALL_SIDES);        integer i = 1;        do {            if (i != prim) llSetLinkAlpha(i, 1.0, ALL_SIDES);        }        while (++i < 4);        ++prim;        if (prim == 5) llSetTimerEvent(0.0);    }}

 

I´m hoping somebody else knows a more elegant way.

Been breaking my head on this for a little while, but I think this is the most approachable solution. There is 'something' with the llSetTimerEvent that gets dodgey if we'd incorporate Jack's method... not sure what. I'd pick your solution, Ron :)

Link to comment
Share on other sites

I guess you have the wrong idea how events work.
Let's see what happens when your touch event fires:

1 - llSetLinkAlpha(1, 0.0, ALL_SIDES);  // you set prim #1
2 - llSetLinkAlpha(2, 1.0, ALL_SIDES);  // you set prim #2
3 - llSetTimerEvent(1.0);  // you set up the timer event so it will fire every second from now on
4 - llSetLinkAlpha(3,1.0, ALL_SIDES);  // you set prim #3
5 - touch event ends
.... 1 second later ...
6 - timer event fires
7... you get the idea

You see: of course prim 2 and 3 turn at the same time.

Link to comment
Share on other sites

Something like this....?

 

integer k;  // on - off toggle - same as k = 0    ..if not defined, variables are blank or 0integer n = 1;  // variable for which link numberdefault{    touch_start(integer num_detected)    {                                      // every time you touch, k is toggled         k = !k;                          //touch toggle-either 1 or 0  this is BOOLEAN if k=0, k will become 1, if 1, it becomes 0        if(k)                             // if k is  true (not zero or empty)        {llSetTimerEvent(0.1);}  //if k is 1 - send to timer in tenth of a second        else        { llSetLinkAlpha( LINK_SET, 1.0, ALL_SIDES);llSetTimerEvent(0.0);n = 1;} // if k is 0 - (off) make linkset all visible                                                             // turn off timer and reset n to 1    }     timer()    {                llSetLinkAlpha( LINK_SET, 0.0, ALL_SIDES);   // make linkset (all) invisible        llSetLinkAlpha(n, 1.0, ALL_SIDES);             //  n starts as 1 ( see top declaration) -set link 1 visible         ++n;                                                     //add one to variable n every time the timer fires        if(n > 3)                                                // if n is more than number of prims(links)          {n = 1;}                                                //set n back to the first link number
llSetTimerEvent(1.0); // make the timer fire every second } // this is stopped when you touch again & timer event is set to 0}

 ETA ( edited to add) commented :)

Link to comment
Share on other sites

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