Jump to content

Particle script firing off at the wrong times


Lilah Munster
 Share

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

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

Recommended Posts

Let me preface this by admitting I am not a stellar scripter, and particle scripts are about my least favorite thing, but for this purpose, I need them.  The object in question is an attachment, and the script is essentially a candle that is controlled via HUD.  The fire and smoke particles work fine, the problem is that the object also emits smoke when an avatar teleports or logs in, and also when the object content changes. 

I have tried inserting an llParticleSystem([ ]); into state_entry, and also adding an on_rez (which the script doesn't really need otherwise) with an empty particle system to stop it, but that's not working.  Here's the relevant code:

//string defining bits stripped out

default
{
    state_entry()
    {
        llParticleSystem([  ]);
        llListen(-8675309,"","","");
    }


    listen( integer channel, string name, key id, string message )

//Texture change stuff stripped out 

 else if (message == "On") {
            integer i = llGetNumberOfPrims();

        for( ; i >= 0; --i ) {
            if( llGetLinkName(i) == candle ) {
                 llParticleSystem([  

//Long fire particle parameters stripped out

]);
}

 else if (message == "Off") {
            integer i = llGetNumberOfPrims();

        for( ; i >= 0; --i ) {
            if( llGetLinkName(i) == candle ) {
                 llParticleSystem([  

//Long smoke particle parameters stripped out

]);
}
}
}
}
}

I've also tried it like this:

//string defining bits stripped out

default
{
    state_entry()
    {
        llListen(-8675309,"","","");
    }


    listen( integer channel, string name, key id, string message )

//Texture change stuff stripped out

else if (message == "On") {
            integer i = llGetNumberOfPrims();

        for( ; i >= 0; --i ) {
            if( llGetLinkName(i) == candle ) {
                 llParticleSystem([  
//Long fire particle parameters stripped out
]);
}
}
}
else if (message == "Off") {
            integer i = llGetNumberOfPrims();

        for( ; i >= 0; --i ) {
            if( llGetLinkName(i) == candle ) {
                 llParticleSystem([  
//Long smoke particle parameters stripped out
]);

}
}
}
}
 on_rez(integer start_param)
        {
            llParticleSystem([  ]);
        }
}

I may have dropped a bracket snipping the code for brevity.  Everything works, except for that unwanted extra smoke.

Link to comment
Share on other sites

The llParticleSystem function will only affect particle generation for the prim that the script is in.  It looks to me as if you are trying to start and stop particles in some other prim(s) named "candle".  If so, then the function you need is llLinkParticleSystem.  It's essentially the same function as llParticleSystem but it targets a specific prim.  It's a very handy function, since it saves you the trouble of putting particle scripts in a half dozen prims and sending link mesages back and forth all the time.

Also, incidentally, your for loops are all counting down from llGetNumberOfPrims() to zero, but in a linkset with more than one prim, there is no link zero.  In this case, you will probably not get a script error, because the non-existant link zero is not named "candle", so the if test will always evaluate to FALSE when it gets that far.  Still, there might be situations when you were looking for a FALSE condition, and the script would spit up.

Link to comment
Share on other sites

There are multiple candles in a linkset, but there's a script in each one.  I know it looks like it's a single script in the root prim with the for loops because the texture change part needs the object names to do what it does, and I really prefer to use a single script in the root whenever I can, so I tend to write things that way.

Can you point me at something that explains how to make my for loops no longer count down to zero?

Link to comment
Share on other sites

I'm not quite sure that I am reading your reply correctly, but you can do all of the texture change and the particle generation from a single script in the root prim if you use llSetLinkPrimitiveParamsFast and llLinkParticleSystem.  Those two functions and a few others are a godsend for anyone who needs to perform similar actions in more than one link of a linkset.

And getting your loop to count down to 1 instead of 0 is just a matter of changing the condition from i >= 0 to i > 0 .

 

Link to comment
Share on other sites

i looked the code, you dropped more than a few brackets. I can not even get the code. The else if after the listen is void, You have to start with an if statement. You repeated the statement in regards to on or off., am also at a loss to why you are testing for the link number in this instance when a changed link event would suffice. It appears that you have pasted a snippet in an effort to get a result, You need to learn basics first.

Link to comment
Share on other sites

Some code was stripped-out, it's true -- and unfortunately, that part includes the particle system definition with the main problem here -- but there's nothing related to "a changed link event" going on here, so that's not going to help.

The thing about particle systems is that they are a prim property that get defined for a viewer without script execution. We're all familiar with one effect of that: the particle system needs to be scrubbed from a prim, not merely deleted by removing the script. Here, the effect is that the "smoke"-generating particle system appears every time the object comes into view because that's how particles work, not because the script is actively making it happen.

Almost surely that particle system is defined with a non-zero PSYS_SRC_MAX_AGE on the premise that this will make the particles stop emitting after that time interval -- and that's how it works for viewers after they've seen the particles being emitted. That doesn't remove the particle system from the object -- it's still there, and will show itself every time the object rezzes into view.

So, to get the intended effect here, you'll need to add a timer event (or similar) to clear the particle system sometime after the smoke clears.

Link to comment
Share on other sites

i appreciate what you are saying, it is diffucult to asses the examples on what has been posted. The main problem i have is i can not see when the asset is cleared, loading every veiwer unnececerly is not cool.. Personly i do not have the partical def in the main  I not being very helpfull.

Link to comment
Share on other sites

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