User:Toady Nakamura/Particle Sparkler Touch on off

From Second Life Wiki
< User:Toady Nakamura
Revision as of 19:41, 27 June 2014 by Toady Nakamura (talk | contribs) (new script for 4th July & Canada Day)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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 root.

<lsl> //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 >, PSYS_PART_END_COLOR, < 1.0, 0.8, 0.3 >, PSYS_PART_START_SCALE, < 0.05, 0.13, 0.0 >, PSYS_PART_END_SCALE, < 0.004, 0.009, 0.0 >, PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_EXPLODE, // 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, PSYS_SRC_ACCEL, < 0.0 , 0.0, -0.1>, PSYS_SRC_BURST_PART_COUNT, 8, PSYS_SRC_BURST_RADIUS, 0.0, PSYS_SRC_BURST_SPEED_MIN, 0.8, PSYS_SRC_BURST_SPEED_MAX, 1.2, //PSYS_SRC_TARGET_KEY, target, PSYS_SRC_INNERANGLE, PI, PSYS_SRC_OUTERANGLE, 0.0, PSYS_SRC_OMEGA, < 0, 0, 0 >, PSYS_SRC_MAX_AGE, life, //* PSYS_SRC_TEXTURE, "", PSYS_PART_START_ALPHA, 1.0, PSYS_PART_END_ALPHA, 0.0

   ]);

}

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.


</lsl>

Touch & it goes!