Jump to content

Simple fireworks script


SeeAirAhh Josephina
 Share

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

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

Recommended Posts

I'm wanting to take a prim with a fireworks texture, expand it and retract it.  I think I'm on the right track and this needs to be slowed down but this is what I have so far

vector  gScaleSmall = <0.5, 0.5, 0.5>;

default
{
    touch_start(integer total_number)
    {
        @Loophere;
        {
        
        llSetScale(gScaleSmall + <0.5,0.5,0.5>);        
        llSetScale(gScaleSmall + <0.5,0.5,0.5>);
        llSetScale(gScaleSmall + <0.5,0.5,0.5>);
        llSetScale(gScaleSmall + <0.5,0.5,0.5>);
        llSetScale(gScaleSmall + <0.5,0.5,0.5>);
        llSetScale(gScaleSmall - <0.5,0.5,0.5>);
        llSetScale(gScaleSmall - <0.5,0.5,0.5>);
        llSetScale(gScaleSmall - <0.5,0.5,0.5>);
        llSetScale(gScaleSmall - <0.5,0.5,0.5>);
        llSetScale(gScaleSmall - <0.5,0.5,0.5>);
        }
    jump Loophere;
    }
}
 

it works but it's going to fast right now, this is real simple so I understand what I'm doing so far.  I'm sure people here would have great suggestions.

Link to comment
Share on other sites

I would recommend steering away from jumps, because they can lead to bad habits. Instead, you could use a real loop:

vector  gScaleSmall = <0.5, 0.5, 0.5>;

default
{
    touch_start(integer total_number)
    {
        while (TRUE)
        {
            llSetScale(gScaleSmall + <0.5,0.5,0.5>);
            llSetScale(gScaleSmall - <0.5,0.5,0.5>);
        }
    }
}

You'll notice I also took out the duplicated lines. I assume you added them to try to "slow down" the changes, with little luck. Instead, you could use llSleep, which pauses the script for some amount of time.

while (TRUE)
{
    llSetScale(gScaleSmall + <0.5,0.5,0.5>);
    llSleep(0.2);
    llSetScale(gScaleSmall - <0.5,0.5,0.5>);
    llSleep(0.2);
}

Changing the delay gives you finer control of the effect. There's also the potential problem that this is an infinite loop -- it will never stop, and the script will never do anything else. Ideally, you wouldn't do this. Instead you'd have something like a timer event where you do one of those two things. (increasing or decreasing size)

vector  gScaleSmall = <0.5, 0.5, 0.5>;
integer gExpand = TRUE;

default
{
    touch_start(integer total_number)
    {
        llSetTimerEvent(0.2); // Sets a time interval
    }

    timer() // Happens at regular intervals
    {
        if (gExpand == TRUE)
        {
            llSetScale(gScaleSmall + <0.5,0.5,0.5>);
            gExpand = FALSE;
        }
        else
        {
            llSetScale(gScaleSmall - <0.5,0.5,0.5>);
            gExpand = TRUE;
        }
    }
}

Slightly more complicated, but this way the script can handle other events as well, such as being touched again, hearing messages from other objects, etc. It works by having a gExpand variable that has one of two values -- TRUE or FALSE -- 1 or 0 -- and it either sets the scale bigger or smaller depending on what the value is. Then it changes that value so that the other thing will happen next time.

  • Like 2
Link to comment
Share on other sites

  • 5 weeks later...

@SeeAir Can i suggest if you are making fireworks you link all parts  The reason I suggest this as its easy to create fireworks but not so easy to keep control of all the parts and not send them all over someones  sim. D.  Its really easy for this to get out of control  especially if you are throwing more than one shell at same time.

Link to comment
Share on other sites

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