Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Fireworks Emitter_Particle_Script  

Emitter_Particle_Script

Emitter Particle Script.lsl

Category: Fireworks
By : Ama Omega
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Emitter_Particle_Script
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Emitter_Particle_Script_1.lsl
1
2
3 // Particle Script 0.4j
4 // Created by Ama Omega 3-7-2004
5 // Updated by Jopsy Pendragon 5-11-2004
6 // For classes/tutorials/tricks, visit the Particle Labratory in Teal
7 // Values marked with (*) are defaults.
8
9 // SECTION ONE: APPEARANCE -- These settings affect how each particle LOOKS.
10 integer glow = TRUE; // TRUE or FALSE(*)
11 vector startColor = <1,1,1>; // RGB color, black<0,0,0> to white<1,1,1>(*)
12 vector endColor = <1,1,1>; //
13 float startAlpha = 1.0; // 0.0 to 1.0(*), lower = more transparent
14 float endAlpha = 1.0; //
15 vector startSize = <0.2,0.2,0>; // <0.04,0.04,0>(min) to <10,10,0>(max>, <1,1,0>(*)
16 vector endSize = <0.1,0.1,0>; // (Z part of vector is discarded)
17 string texture = "TRU POOFER BALLOONS"; // Texture used for particles. Texture must be in prim's inventory.
18
19 // SECTION TWO: FLOW -- These settings affect how Many, how Quickly, and for how Long particles are created.
20 // Note,
21 integer count = 3; // Number of particles created per burst, 1(*) to 4096
22 float rate = 0.2; // Delay between bursts of new particles, 0.0 to 60, 0.1(*)
23 float age = 5.0; // How long each particle lives, 0.1 to 60, 10.0(*)
24 float life = 0.0; // When to stop creating new particles. never stops if 0.0(*)
25
26 // SECTION THREE: PLACEMENT -- Where are new particles created, and what direction are they facing?
27 float radius = 1.0; // 0.0(default) to 64? Distance from Emitter where new particles are created.
28 float innerAngle = PI; // "spread", for all ANGLE patterns, 0(default) to PI
29 float outerAngle = 0.0; // "tilt", for ANGLE patterns, 0(default) to TWO_PI, can use PI_BY_TWO or PI as well.
30 integer pattern = PSYS_SRC_PATTERN_ANGLE_CONE; // Choose one of the following:
31 // PSYS_SRC_PATTERN_EXPLODE (sends particles in all directions)
32 // PSYS_SRC_PATTERN_DROP (ignores minSpeed and maxSpeed. Don't bother with count>1 )
33 // PSYS_SRC_PATTERN_ANGLE_CONE (set innerangle/outerange to make rings/cones of particles)
34 // PSYS_SRC_PATTERN_ANGLE (set innerangle/outerangle to make flat fanshapes of particles)
35 vector omega = <0,0,0>; // How much to rotate the emitter around the <X,Y,Z> axises. <0,0,0>(*)
36 // Warning, there's no way to RESET the emitter direction once you use Omega!!
37 // You must attach the script to a new prim to clear the effect of omega.
38
39 // SECTION FOUR: MOVEMENT -- How do the particles move once they're created?
40 integer followSource = FALSE; // TRUE or FALSE(*), Particles move as the emitter moves, (TRUE disables radius!)
41 integer followVel = FALSE; // TRUE or FALSE(*), Particles rotate towards their direction
42 integer wind = FALSE; // TRUE or FALSE(*), Particles get blown away by wind in the sim
43 integer bounce = FALSE; // TRUE or FALSE(*), Make particles bounce on Z altitude of emitter
44 float minSpeed = 0.1; // 0.01 to ? Min speed each particle is spit out at, 1.0(*)
45 float maxSpeed = 0.1; // 0.01 to ? Max speed each particle is spit out at, 1.0(*)
46 vector push = <0,0,-0.1>; // Continuous force pushed on particles, use small settings for long lived particles
47 key target = "self"; // Select a target for particles to arrive at when they die
48 // can be "self" (emitter), "owner" (you), "" or any prim/persons KEY.
49
50 // SECTION FIVE: Ama's "Create Short Particle Settings List"
51 integer enableoutput = TRUE; // If this is TRUE, clicking on your emitter prim will cause it to speak
52 // very terse "shorthand" version of your particle settings. You can cut'n'paste
53 // this abbreviated version into a call to llParticleSystem([ ]); in another script.
54 // Pros: Takes up far less scripting space, letting you focus on the rest of your code.
55 // Cons: makes tune your settings afterwards rather awkward
56
57 // === Don't muck about below this line unless you're comfortable with the LSL scripting language ====
58
59 // Script variables
60 integer pre = 2; //Adjust the precision of the generated list.
61 integer flags;
62 list sys;
63 integer type;
64 vector tempVector;
65 rotation tempRot;
66 string tempString;
67 integer i;
68
69 string float2String(float in)
70 {
71 return llGetSubString((string)in,0,pre - 7);
72 }
73
74 updateParticles()
75 {
76 flags = 0;
77 if(target == "owner") target = llGetOwner();
78 if(target == "self") target = llGetKey();
79 if(glow) flags = flags | PSYS_PART_EMISSIVE_MASK;
80 if(bounce) flags = flags | PSYS_PART_BOUNCE_MASK;
81 if(startColor != endColor) flags = flags | PSYS_PART_INTERP_COLOR_MASK;
82 if(startSize != endSize) flags = flags | PSYS_PART_INTERP_SCALE_MASK;
83 if(wind) flags = flags | PSYS_PART_WIND_MASK;
84 if(followSource) flags = flags | PSYS_PART_FOLLOW_SRC_MASK;
85 if(followVel) flags = flags | PSYS_PART_FOLLOW_VELOCITY_MASK;
86 if(target != "") flags = flags | PSYS_PART_TARGET_POS_MASK;
87 sys = [ PSYS_PART_MAX_AGE,age,
88 PSYS_PART_FLAGS,flags,
89 PSYS_PART_START_COLOR, startColor,
90 PSYS_PART_END_COLOR, endColor,
91 PSYS_PART_START_SCALE,startSize,
92 PSYS_PART_END_SCALE,endSize,
93 PSYS_SRC_PATTERN, pattern,
95 PSYS_SRC_ACCEL, push,
101 PSYS_SRC_INNERANGLE,innerAngle,
102 PSYS_SRC_OUTERANGLE,outerAngle,
103 PSYS_SRC_OMEGA, omega,
104 PSYS_SRC_MAX_AGE, life,
105 PSYS_SRC_TEXTURE, texture,
106 PSYS_PART_START_ALPHA, startAlpha,
107 PSYS_PART_END_ALPHA, endAlpha
108 ];
109 float newrate = rate;
110 if(newrate == 0.0) newrate=.01;
111 if( (age/rate)*count < 4096) llParticleSystem(sys);
112 else {
113 llInstantMessage(llGetOwner(),"Your particle system creates too many concurrent particles.");
114 llInstantMessage(llGetOwner(),"Reduce count or age, or increate rate.");
115 llParticleSystem( [ ] );
116 }
117 }
118 integer onoff;
119 default
120 {
122 {
123 onoff=0;
124 updateParticles();
125 }
126
128 {
129 if( enableoutput == TRUE ) {
130 if( onoff ) llResetScript();
131 onoff++;
132 llParticleSystem( [ ] );
133 return;
134 }
135 if(1) return; // Comment out this line to enable this function
136 llWhisper(0,"...Generating List...");
137 for (i=1;i<42;i+=2)
138 {
139 type = llGetListEntryType(sys,i);
140 if(type == TYPE_FLOAT)
141 {
142 tempString = float2String(llList2Float(sys,i));
143 sys = llDeleteSubList(sys,i,i);
144 sys = llListInsertList(sys,[tempString],i);
145 }
146 else if(type == TYPE_VECTOR)
147 {
148 tempVector = llList2Vector(sys,i);
149 tempString = "<" + float2String(tempVector.x) + ","
150 + float2String(tempVector.y) + ","
151 + float2String(tempVector.z) + ">";
152 sys = llDeleteSubList(sys,i,i);
153 sys = llListInsertList(sys,[tempString],i);
154 }
155 else if(type == TYPE_ROTATION)
156 {
157 tempRot = llList2Rot(sys,i);
158 tempString = "<" + float2String(tempRot.x) + ","
159 + float2String(tempRot.y) + ","
160 + float2String(tempRot.z) + ","
161 + float2String(tempRot.s) + ">";
162 sys = llDeleteSubList(sys,i,i);
163 sys = llListInsertList(sys,[tempString],i);
164 }
165 else if(type == TYPE_STRING || type == TYPE_KEY)
166 {
167 tempString = "\"" + llList2String(sys,i) + "\"";
168 sys = llDeleteSubList(sys,i,i);
169 sys = llListInsertList(sys,[tempString],i);
170 }
171 }
172 i = llListFindList(sys,[20,""]);
173 if(i != -1) sys = llDeleteSubList(sys,i,i+1);
174 llWhisper(0,"[" + llList2CSV(llList2List(sys,0,22)) + ",");
175 llWhisper(0,llList2CSV(llList2List(sys,23,-1)) + "]");
176 }
177 }// END //

Back to the Best Free Tools in Second Life and OpenSim.