Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

random on/off for particles

maihem Sinister
Registered User
Join date: 7 Oct 2008
Posts: 29
09-28-2009 07:42
I have been looking for some sort of controler script that would start then stop a particle effects script i got from the partical lab, with no luck what so ever and dispite several attempts at cut and past with scripts i can not manage to make it work so i am hoping some one here either knows of such a script or would be willing to lend a hand here :)

basicaly what i am trying to do is have this script start shooting particles then stop after 5 seconds, random starts would be a nice effect but that may be asking a bit much so if it started every 45 seconds or so that would work fine.

i tried to post the script...no amount of editing could get me past what ever it is that is blocking it from being posted though :(
it is the ""steam under presure" PARTICLE TEMPLATE" from the particle lab i can send it to you in world if that helps
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
09-28-2009 07:54
http://wiki.secondlife.com/wiki/LlSetTimerEvent

And to post the script make sure you don't have anything but a space or a number after a < sign.
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
09-28-2009 07:58
Just put the call to your particle function ("particles()" or whatever it's called) in a timer event with a toggle to turn particles on and off...

CODE

// As a global variable ...
integer ON;
// In state_entry ....
llSetTimerEvent(5);
ON = TRUE;

//Then, later...
timer()
{
if(ON)
{
particles();
llSetTimerEvent((integer)llFrand(45));
}
else
{
llParticleSystem([]);
llSetTimerEvent(5);
}
ON= !ON
}
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
09-28-2009 08:07
You can also give the particle system a limited lifetime and let it turn off by itself.
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
EF Klaar
Registered User
Join date: 11 Jun 2007
Posts: 330
09-28-2009 08:11
This post explains how to deal with posting problems in these forums: /327/5d/330018/1.html.

This example illustrates one way to get the result you want:

(Edit) I've posted an updated version of this below, in view of Argent's comment.
CODE

float interval_max = 30.0;
float interval_min = 10.0;
float duration = 5.0;
list particle_rules = [PSYS_PART_FLAGS, PSYS_PART_EMISSIVE_MASK, PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_EXPLODE];

default
{
state_entry ()
{
llSay (PUBLIC_CHANNEL, "Hello, Avatar!");
llSetTimerEvent (0.1);
}
timer ()
{
llSetTimerEvent (llFrand (interval_max - interval_min) + interval_min);
llParticleSystem (particle_rules);
llSleep (duration);
llParticleSystem ([]);
}
}


Note that because of a bug in the PSYS_SRC_MAX_AGE setting, it is often necessary to use an llSleep call followed by a call to llParticleSystem with an empty list as the parameter to turn the particles off after a certain time.
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
09-28-2009 08:15
What bug?
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
EF Klaar
Registered User
Join date: 11 Jun 2007
Posts: 330
09-28-2009 08:20
From: Argent Stonecutter
What bug?
Er, this one?

Caveats
1.When using particle systems that have a non-zero emitter age (PSYS_SRC_MAX_AGE) setting, you may notice that the particle system may restart without any scripted trigger going off. This is due to a bug which causes the emitter to "reset" when any of the prim properties are updated or otherwise sent to the viewer. As a result, you may have to use a timer or a forced sleep and then clear the particle system once the age has expired. Debbie Trilling has posted a work-around here: /54/fa/260031/1.html#post1996465
EF Klaar
Registered User
Join date: 11 Jun 2007
Posts: 330
09-28-2009 08:24
I must confess I haven't been able to reproduce this so far.
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
09-28-2009 08:31
Since the particle system is being restarted randomly anyway, I don't think this is an issue.
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
EF Klaar
Registered User
Join date: 11 Jun 2007
Posts: 330
09-28-2009 08:34
This version uses the PSYS_SRC_MAX_AGE setting instead of an llSleep and llParticleSystem call to turn off the particles.

CODE

float interval_max = 30.0;
float interval_min = 10.0;
float duration = 5.0;
list particle_rules = [PSYS_PART_FLAGS, PSYS_PART_EMISSIVE_MASK, PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_EXPLODE, PSYS_SRC_MAX_AGE, duration];

default
{
state_entry ()
{
llSay (PUBLIC_CHANNEL, "Hello, Avatar!");
llSetTimerEvent (0.1);
}
timer ()
{
llSetTimerEvent (llFrand (interval_max - interval_min) + interval_min);
llParticleSystem (particle_rules);
}
}
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
09-28-2009 08:54
You'll need to initialize particle_rules in state_entry() because duration isn't a constant.
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
EF Klaar
Registered User
Join date: 11 Jun 2007
Posts: 330
09-28-2009 09:11
From: Argent Stonecutter
You'll need to initialize particle_rules in state_entry() because duration isn't a constant.
I'm afraid you've lost me there. It produces no compile or run-time errors, and it does produce bursts five seconds long.
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
09-28-2009 09:19
From: EF Klaar
I'm afraid you've lost me there. It produces no compile or run-time errors, and it does produce bursts five seconds long.
ORLY? It sure didn't used to. I started working on a patch to make that kind of thing work but never finished it, when I fixed the negative number bug a few years back.
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
maihem Sinister
Registered User
Join date: 7 Oct 2008
Posts: 29
09-28-2009 19:54
thanks very much, those scripts do work fine, i am just having some trouble incorporating the particle peramiters into it :p

float interval_max = 30.0;
float interval_min = 10.0;
float duration = 5.0;
list particle_parameters=[]; // stores your custom particle effect, defined below.
list target_parameters=[]; // remembers targets found using TARGET TEMPLATE scripts.

default {
state_entry() {
llSetTimerEvent (0.1);
}
timer ()
{
llSetTimerEvent (llFrand (interval_max - interval_min) + interval_min);
particle_parameters = [ // start of particle settings
// Texture Parameters:
PSYS_SRC_TEXTURE, llGetInventoryName(INVENTORY_TEXTURE, 0),
PSYS_PART_START_SCALE, < 0.05, .05, FALSE > , PSYS_PART_END_SCALE, < 1.0, 1.0, FALSE > ,
PSYS_PART_START_COLOR, < 1,1,1 > , PSYS_PART_END_COLOR, < 1,1,1 > ,
PSYS_PART_START_ALPHA, (float)0.5, PSYS_PART_END_ALPHA, (float)0.0,

// Production Parameters:
PSYS_SRC_BURST_PART_COUNT, (integer) 1,
PSYS_SRC_BURST_RATE, (float) 0.01,
PSYS_PART_MAX_AGE, (float)2.4,
PSYS_SRC_MAX_AGE,(float) 0.0,

// Placement Parameters:
PSYS_SRC_PATTERN, (integer)8, // 1=DROP, 2=EXPLODE, 4=ANGLE, 8=ANGLE_CONE,

// Placement Parameters (for any non-DROP pattern):
PSYS_SRC_BURST_SPEED_MIN, (float).01, PSYS_SRC_BURST_SPEED_MAX, (float)5.01,
// PSYS_SRC_BURST_RADIUS, 0.0,

// Placement Parameters (only for ANGLE & CONE patterns):
PSYS_SRC_ANGLE_BEGIN, (float) 0.01*PI, PSYS_SRC_ANGLE_END,(float) 0.02*PI,
PSYS_SRC_OMEGA, < 0,0,0 > ,

// After-Effect & Influence Parameters:
PSYS_SRC_ACCEL, < 0.0,0.0,0.0 > ,
// PSYS_SRC_TARGET_KEY, llGetLinkKey(llGetLinkNum() + 1),

PSYS_PART_FLAGS, (integer)( 0 // Texture Options:
| PSYS_PART_INTERP_COLOR_MASK
| PSYS_PART_INTERP_SCALE_MASK
| PSYS_PART_EMISSIVE_MASK
| PSYS_PART_FOLLOW_VELOCITY_MASK
// After-effect & Influence Options:
// | PSYS_PART_WIND_MASK
// | PSYS_PART_BOUNCE_MASK
// | PSYS_PART_FOLLOW_SRC_MASK
// | PSYS_PART_TARGET_POS_MASK
// | PSYS_PART_TARGET_LINEAR_MASK
)
//end of particle settings
];


}

link_message( integer sibling, integer num, string mesg, key target_key ) {
//if ( mesg != CONTROLLER_ID ) { // this message isn't for me. Bail out.
return;
} //else if ( num == 0 ) { // Message says to turn particles OFF:
//llParticleSystem( [ ] );
} //else if ( nu
EF Klaar
Registered User
Join date: 11 Jun 2007
Posts: 330
09-28-2009 23:07
In the code you post you set up the variable particle parameters, but I do not see you feed it to llParticleSystem anywhere. Also, using PSYS_SRC_MAX_AGE,(float) 0.0 creates a never-ending stream, which must be turned off explicitly.
maihem Sinister
Registered User
Join date: 7 Oct 2008
Posts: 29
09-29-2009 00:06
i'll try that thanks :)