Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Particle Control Script Advice

Dmitriy Gausman
Registered User
Join date: 16 May 2007
Posts: 132
05-20-2008 07:11
Hello-

I have an object with a tip jar script in it. What I want to do is only have a particle effect emit from the object when someone pays.

I would appreciate some guidance how to approach this. My limited knowledge would have me use 2 separate scripts. The main one is the tip script. At the point where the payment is made, should I use a "llMessageLink" to get the particle script to run? I never used this so I am not so sure how, but if that is the right direction, i can try to learn.

Once the particle script is running, i want to be able to have the particles appear for a limited time and then turn off and return to the main tip program. Would I use a timer for that in the particle script?

I tried to look in a few places to see if there are any scripts that already do this, but either I was not very clear how I searched or this is just not a resaleable item.

Well, any ideas would be a great start for me. Thank you :-)

Dmitriy
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
05-20-2008 07:54
You can do it either as two seperate scripts or incorporate it all into one.
There is litle to be gained from spliting it out at this level of complexity although personally I think is good practise for larger projects.

I'm no 100% certain but I think setting the particle parameters will be enough to retrigger the effect, even if is exactly the same parameters used. So all you would need to do is reset the parameters each time you are paid without needing a timer to stop them in between. Visit the Particle Lab for a really good tutorial on particles.
_____________________
I'm back......
Dmitriy Gausman
Registered User
Join date: 16 May 2007
Posts: 132
05-20-2008 09:01
Thank you, Newgate. It worked perfectly. I embedded llParticleSystem after the payment. I was not able to get it to turn off, so I put an llSetTimerEvent(10) at the top and at the end of the program, i just added a Timer() and then llParticleSystem([]);
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
05-21-2008 00:42
From: Dmitriy Gausman
Thank you, Newgate. It worked perfectly. I embedded llParticleSystem after the payment. I was not able to get it to turn off, so I put an llSetTimerEvent(10) at the top and at the end of the program, i just added a Timer() and then llParticleSystem([]);


It would depend on exactly what effect you where trying to generate but usinga timer isnt too bad. You should only start the timer when you start the particle system and then kill it inside the timer event.
_____________________
I'm back......
Cerulean Deadlight
Registered User
Join date: 6 May 2007
Posts: 28
05-21-2008 01:30
You don't need to use a timer.

PSYS_SRC_BURST_PART_COUNT, 50,
PSYS_SRC_BURST_RATE, 0.5,
PSYS_SRC_MAX_AGE, 0.9,


Something like this would work. The particles are made at 0.5 seconds, and then the emitter stops producing particles before the second burst. I've tried this in a touch event and it triggers correctly every time.


But whatever works! It probably doesn't make any difference.
Debbie Trilling
Our Lady of Peenemünde
Join date: 17 Oct 2006
Posts: 434
05-21-2008 02:48
Setting a value for PSYS_SRC_MAX_AGE, as Cerulean has shown, is functionally equivilent to setting a timer, but is more efficient.

For particle work, it is the correct solution...

...or rather, it would be, were it not for a long-term particle system bug when PSYS_SRC_MAX_AGE is set to a non-zero value.

As as result of this bug, what you will find in practice is that the particles will not only fire after a payment is made (correctly), but also when the client right-clicks to 'Pay', every time the object is touched, every time an AV tp's into the area, every time the object is rezzed. In short, because of this bug, the particles will fire every time a client update is performed for the object

For full details of this bug see Caveat 2 of this wiki entry http://wiki.secondlife.com/wiki/LlParticleSystem

Note well, this bug is not an issue when PSYS_SRC_MAX_AGE is set to zero; only when it is set to a non-zero value

So we need a solution that allows us to use the particle system's own internal "timer", PSYS_SRC_MAX_AGE, but with a workaround for the bug:

The following code snipet demonstrates how to do this:

CODE



//particle control

// SystemSafeSet prevents erroneous particle emissions
float SystemSafeSet = 0.00;

// SystemAge is the life span of the particle system
float SystemAge = 0.75;

StartParticles()
{
// set the system safe variable from zero to the value that you want the particle system to survive for
SystemSafeSet = SystemAge;

// make the particle call
llParticleSystem([
....,
....,
....,
PSYS_SRC_MAX_AGE, SystemSafeSet, // populated by SystemSafeSet
]);

// let the script sleep for a time equivilent to SystemAge
llSleep(SystemAge);

// set SystemSafe back to zero to prevent erroneous particle emmisions
SystemSafeSet = 0.00;

// clear the prim of particles
llParticleSystem([]);
}


default
{

state_entry()
{
SystemSafeSet = 0.00;
SystemAge = 0.75;

}

touch_start(integer touches)
{
StartParticles();
}

// default end
}

_____________________
http://wiki.secondlife.com/wiki/User:debbie_Trilling
Cerulean Deadlight
Registered User
Join date: 6 May 2007
Posts: 28
05-21-2008 19:27
You might also just be able to change the particle count to 0, then bump it up to whatever you need when you click, and then back to 0.
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
05-21-2008 22:19
From: Cerulean Deadlight
You don't need to use a timer.

PSYS_SRC_BURST_PART_COUNT, 50,
PSYS_SRC_BURST_RATE, 0.5,
PSYS_SRC_MAX_AGE, 0.9,

Something like this would work. The particles are made at 0.5 seconds, and then the emitter stops producing particles before the second burst. I've tried this in a touch event and it triggers correctly every time.

But whatever works! It probably doesn't make any difference.

I suggest (also) using a timer. Here's the reason. If you start the particles at a time T1, and the max source age is t, then avatars who start and remain near the source will indeed only see the particles between T1 and T1+t. However, an avatar who arrives at some later time T2 will see the particles between T2 and T2+t (the source age starts when a client first draws the particles, not when they are started on the server). If this is an issue, you'll want to actually turn the particles off at approximately T1+t using 'llParticleSystem([]);'.
Debbie Trilling
Our Lady of Peenemünde
Join date: 17 Oct 2006
Posts: 434
05-22-2008 00:57
From: Cerulean Deadlight
You might also just be able to change the particle count to 0, then bump it up to whatever you need when you click, and then back to 0.


Well, you *could*, yes. You *could* also set the alpha to zero.

But...the particle system would still fire in every one of those situations listed, albeit you would not actually *see* anything.

I dont see much point in forcing a client update on every AV in the area, when they are not even going to see anything. It is a very inefficient "solution". It is covering up and disguising the problem, rather than using a properly thought out workaround.
_____________________
http://wiki.secondlife.com/wiki/User:debbie_Trilling