User:Toady Nakamura/Particle Sparkler Touch on off
Jump to navigation
Jump to search
- Visit my SL wiki home page for more simple scripts that work. -- Toady Nakamura
Build instructions:
- Create your sparkler, probably a cylinder with a tiny sphere on top.
- Link the two with the tiny sphere on top as the root.
- Place this script into the linked build, by default it goes to root.
- When installed, touch & the particles start. They will go out again x seconds later. Set that below, see * float life = 10.0;
// Holiday Sparkler 06/27/14 // Inspired by Jopsy Pendragon
// Visit the Particle Lab at Teal Sim if you have never done so.
// Modified by Toady Nakamura for classes
float life = 10.0; // time in seconds before sparkler burns out
updateParticles()
{
llParticleSystem([
PSYS_PART_FLAGS,
PSYS_PART_EMISSIVE_MASK // glow
| PSYS_PART_BOUNCE_MASK // don't go below emitter
| PSYS_PART_INTERP_COLOR_MASK // change color
| PSYS_PART_INTERP_SCALE_MASK // change size
// | PSYS_PART_WIND_MASK // blow on wind
// | PSYS_PART_FOLLOW_SRC_MASK // follow emitter or stay stuck (true?)
| PSYS_PART_FOLLOW_VELOCITY_MASK// rotate towards where they're going
// | PSYS_PART_TARGET_POS_MASK // for targetting particles
,// you need this comma
PSYS_PART_MAX_AGE, 1.75, // each sprite
PSYS_PART_START_COLOR, < 0.9, 0.9, 1.0 >, // beginning color
PSYS_PART_END_COLOR, < 1.0, 0.8, 0.3 >, // ending color of sprites
PSYS_PART_START_SCALE, < 0.05, 0.13, 0.0 >, // beginning size
PSYS_PART_END_SCALE, < 0.004, 0.009, 0.0 >, // ending size of sprites
PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_EXPLODE, // sends particles in all directions
// PSYS_SRC_PATTERN_DROP // ignores minSpeed and maxSpeed. Don't bother with count>1
// PSYS_SRC_PATTERN_ANGLE_CONE // set innerangle/outerange to make rings/cones of particles
// PSYS_SRC_PATTERN_ANGLE // set innerangle/outerangle to make flat fanshapes of particles
PSYS_SRC_BURST_RATE, 0.1, // how fast they come out, lower numbers are faster
PSYS_SRC_ACCEL, < 0.0 , 0.0, -0.1>, // push on each particle, given as xyz vector data
PSYS_SRC_BURST_PART_COUNT, 8, // how many to emit at each burst
PSYS_SRC_BURST_RADIUS, 0.0, // how close to center of emitter to emit
PSYS_SRC_BURST_SPEED_MIN, 0.8, // slowest speed
PSYS_SRC_BURST_SPEED_MAX, 1.2, // fastest speed
//PSYS_SRC_TARGET_KEY, target, // no target so // commented out
//PSYS_SRC_INNERANGLE, PI, // for angle patterns only
//PSYS_SRC_OUTERANGLE, 0.0, // for angle patterns only
PSYS_SRC_OMEGA, < 0, 0, 0 >, // emitter rotates after each burst.
PSYS_SRC_MAX_AGE, life, //* life of sprite display in seconds defined above
PSYS_SRC_TEXTURE, "", // system texture if ""
PSYS_PART_START_ALPHA, 1.0,// start fully visible
PSYS_PART_END_ALPHA, 0.0 // end completely transparent
]);
}
all_off()
{
llParticleSystem([ ]); // off particles
llSetTimerEvent(0); // off time
}
default
{
state_entry()
{
all_off();
}
touch_start(integer i)
{
updateParticles(); // touch to reset/turn on the particles
llSetTimerEvent(life); // run timer just as long as particle life
// to be sure they turn off
}
timer()
{
all_off();
}
}
//// NOTES --------------------------------------------------
// if you wish to target owner, the target = llGetOwner(),
// if you wish to target the prim itself, target = llGetKey(),
// best to leave everything about targetting commented out unless it's in use.