Jump to content

I need to have two separated objects blink at the same time


VeranniCakes
 Share

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

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

Recommended Posts

If the star and the heart are linked in the same object, all you need to do is put a SLPPF command in a timer and turn the effect on/off in successive steps in the cycle.  So, something like:

integer iON;

default
{
    state_entry()
    {
        llSetTimerEvent(3.0);
        llSetLinkPrimitiveParamsFast(LINK_SET,[34,link_number_of_the_star,PRIM_FULLBRIGHT, ALL_SIDES, iON, PRIM_GLOW, ALL_SIDES, 0.05*iON,
            34,link_number_of_the_heart,PRIM_FULLBRIGHT, ALL_SIDES, iON, PRIM_GLOW, ALL_SIDES, 0.05*iON]);
    }

    timer()
    {
        iON = !iON;
        llSetLinkPrimitiveParamsFast(LINK_SET,[34,link_number_of_the_star,PRIM_FULLBRIGHT, ALL_SIDES, iON, PRIM_GLOW, ALL_SIDES, 0.05*iON,
            34,link_number_of_the_heart,PRIM_FULLBRIGHT, ALL_SIDES, iON, PRIM_GLOW, ALL_SIDES, 0.05*iON]);
    }
}

assuming that you know the link numbers of the star and the heart, which you need to replace above.  You can of course adjust the timer and the intensity of the glow as you wish.

As usual, any scripts posted as part of responses in this forum should be understood to be examples, not necessarily optimized or tested in world.  

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

No, it's the number of that link.  And SLPPF is llSetLinkPrimitiveParamsFast.

if you don't already know the number of each link, then you can ask the script to find it as it starts, provided that you have named the links appropriately.  For example, if you have named them "Star" and "Heart" (nice logical choices), then you could add lines in the state_entry event like:

        integer i;
        while ( i < llGetNumberOfPrims() )
        {
            string strName = llGetLinkName(i);
            if ( strName == "Star" )
            {
                link_number_of_the_star = i;
            }
            else if (  strName == "Heart" )
            {
                link_number_of_the_heart = i;
            }
        }

and then be sure to make link_number_of_the_star and link_number_of_the_heart global variables, just like iON is now.

  • Like 1
Link to comment
Share on other sites

The link number is assigned to objects in a Link Set when they are linked. If you're linking up N objects, the first one you select will be link #N and the last one will be link #1 (and also the root link, after which the entire Link Set will be named).

http://wiki.secondlife.com/wiki/Link

SLPPF stands for llSetLinkPrimitiveParamsFast(), the function that allows you to set parameters on objects in a Link Set.

Link to comment
Share on other sites

Yes. Substitute:

llSetLinkPrimitiveParamsFast(LINK_SET,[34,link_number_of_the_star,PRIM_FULLBRIGHT, ALL_SIDES, iON, PRIM_GLOW, ALL_SIDES, 0.05*iON,
            34,link_number_of_the_heart,PRIM_FULLBRIGHT, ALL_SIDES, !iON, PRIM_GLOW, ALL_SIDES, 0.05*!iON]);

I encourage you to keep on playing with it to see what you can do by adding some extras cautiously.  Study a couple of basic tutorials to get yourself started. We all started this way at some point. As long as you have a script that already works, you know that you can toss your experiments if they don't work the first time.  Be bold.

  • Like 1
Link to comment
Share on other sites

It looks like Veranni's requirements are growing faster than her ability to realize them. Dunno if she'll return here, but here's how I'd approach the problem.

Here's the page that describes llSetLinkPrimitiveParamsFast()... http://wiki.secondlife.com/wiki/LlSetPrimitiveParams

And here I've color coded Rolig's example so you can see the parameter lists for the two prims in her example function call...

llSetLinkPrimitiveParamsFast(LINK_SET ,[PRIM_LINK_TARGET,link_number_of_the_star,PRIM_FULLBRIGHT, ALL_SIDES, iON, PRIM_GLOW, ALL_SIDES, 0.05*iON,             PRIM_LINK_TARGET,link_number_of_the_heart,PRIM_FULLBRIGHT, ALL_SIDES, iON, PRIM_GLOW, ALL_SIDES, 0.05*iON]);

When I work with SLPPF, I insert carriage returns in the rule list to make more sense of the sub lists, like this (I've also hard coded the link numbers):

llSetLinkPrimitiveParamsFast(LINK_SET,[
    PRIM_LINK_TARGET, 1, PRIM_FULLBRIGHT, ALL_SIDES, iON, PRIM_GLOW, ALL_SIDES, 0.05*iON,
    PRIM_LINK_TARGET, 2, PRIM_FULLBRIGHT, ALL_SIDES, iON, PRIM_GLOW, ALL_SIDES, 0.05*iON
]);

Each prim's rule list starts with PRIM_LINK_TARGET (Rolig uses the actual numerical equivalent of 34) and ends with 0.05*iON. The variable iON is doing the work of blinking the prims. iON toggles back and forth (iON = !iON;) with each timer firing and that causes the prim's PRIM_FULLBRIGHT switch to toggle between TRUE and FALSE and the PRIM_GLOW value toggle between zero and 0.05 (a significant amount of glow). If you want to manipulate multiple prims in a link set simultaneously, and in sync, you'd concatenate rule lists for each prim in one super list for SLPPF as Rolig did.

But now you've indicated that you want them to blink independently, which makes sense for a headband. So, how do we make one timer (there is only one) manipulate multiple prims independently? You could put a script in each blinking prim, removing all but one rule list and setting the link number to LINK_THIS. You'd change the timer value in each script as you wish to make them blink at different rates.

You can also do it with just the one script. There are many ways, I'll pick one. If we generate a random number between zero and one at each timer call, and then round that number to the nearest integer, we'll get a random distribution of zeros and ones. We can use those zeros and ones to turn PRIM_FULLBRIGHT on and off, and if we multiply that same random number by the 0.05 PRIM_GLOW parameter, we'll get random blinking. There is no need to save a variable between timer calls in this method, but we must use the same variable to control both PRIM_FULLBRIGHT and PRIM_GLOW. If you don't mind those two parameters changing independently (creating two levels of brightness), you can eliminate the variable completely and just generate different random numbers for each parameter.

Here's a complete example that randomly blinks two linked prims...

default
{
    state_entry()
    {
        llSetTimerEvent(0.5);
    }

    timer()
    {
        integer i = llRound(llFrand(1.0));
        llSetLinkPrimitiveParamsFast(LINK_SET,[PRIM_LINK_TARGET,1,PRIM_FULLBRIGHT, ALL_SIDES, i, PRIM_GLOW, ALL_SIDES, 0.05*i]);
        i = llRound(llFrand(1.0));
        llSetLinkPrimitiveParamsFast(LINK_SET,[PRIM_LINK_TARGET,2,PRIM_FULLBRIGHT, ALL_SIDES, i, PRIM_GLOW, ALL_SIDES, 0.05*i]);
    }
    
}

We can expand this to changing the prim's color. The red, green, and blue components of a prim's color can be generated by three llFrand(1.0) calls feeding the color vector. Here's an example:

llSetLinkPrimitiveParamsFast(LINK_SET,[PRIM_LINK_TARGET,1,PRIM_FULLBRIGHT, ALL_SIDES, i, PRIM_GLOW, ALL_SIDES, 0.05*i, PRIM_COLOR<llFrand(1),llFrand(1),llFrand(1)>]);

Some very dark colors will eventually result from that, so it might be wise to replace llFrand(1) with something like (llFrand(0.5)+0.5).

 

Edited by Madelaine McMasters
  • Thanks 1
Link to comment
Share on other sites

a way this can be done is, in the timer() event we increment a global index variable. Then use the index to select a color vector from a list, using the selection as the PRIM_COLOR parameter

example:

integer index = 0;

default
{
    timer()
    {
	// 3 colors
	vector color = llList2Vector([<1.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 1.0>], index);

        llSetLink.... PRIM_COLOR, color, .....

	++index; // increment the index
        if (index == 3) index = 0; // reset the index to the first color vector  
    }
}

 

Edited by Mollymews
snipped snip
  • Like 1
Link to comment
Share on other sites

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