EMITTERSCRIPT_1.lsl 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. // :CATEGORY:Particles
  2. // :NAME:Emitter_Particle_controllable
  3. // :AUTHOR:eltee Statosky
  4. // :CREATED:2010-01-10 05:20:56.000
  5. // :EDITED:2013-09-18 15:38:52
  6. // :ID:282
  7. // :NUM:380
  8. // :REV:1.0
  9. // :WORLD:Second Life
  10. // :DESCRIPTION:
  11. // EMITTERSCRIPT.lsl
  12. // :CODE:
  13. //////////////////////////////////////////////////////////////////
  14. //// eltee Statosky's Particle Creation Engine 1.5
  15. //// 09/09/2004
  16. //// *PUBLIC DOMAIN*
  17. //// Free to use/copy/poke/ripoff and sell stuff with
  18. //////////////////////////////////////////////////////////////////
  19. ///////////////////////////////////////////////////////
  20. // Effect Flag Collection variable
  21. ///////////////////////////////////////////////////////
  22. integer effectFlags;
  23. ///////////////////////////////////////////////////////
  24. // Color Variables
  25. //
  26. // These affect color and transparency
  27. ///////////////////////////////////////////////////////
  28. // colorInterpolation TRUE gives a smooth start to end change
  29. // The colors are presented as <R, G, B> values between 0 and 1
  30. // The alphas are transparency. 1.0 is solid, 0.0 is clear
  31. // glowEffect TRUE has bright 'light like' particles
  32. // glowEffect FALSE has unlit 'smoke like' particles
  33. integer colorInterpolation = TRUE;
  34. vector startColor = <0.8, 0.85, 1.0>;
  35. vector endColor = <0.8, 0.85, 1.0>;
  36. float startAlpha = 1.0;
  37. float endAlpha = 0.0;
  38. integer glowEffect = TRUE;
  39. ///////////////////////////////////////////////////////
  40. // Size & Shape Variables
  41. //
  42. // These affect the particle's physical appearance
  43. ///////////////////////////////////////////////////////
  44. // sizeInterpolation TRUE gives a smooth start to end change
  45. // The sizes are presented as <X, Y, 0.0> (z is meaningless)
  46. // followVelocity TRUE is the only way to get particles to
  47. // 'tilt' but can be very tricky to implement
  48. // texture = "texturename" loads texturename as particle shape
  49. integer sizeInterpolation = TRUE;
  50. vector startSize = <0.1, 0.1, 0.0>;
  51. vector endSize = <0.1, 0.1, 0.0>;
  52. integer followVelocity = FALSE;
  53. //THIS HERE IS WHERE YOU PUT YOUR TEXTURE. REPLACE THE CODE WITH THE -EXACT- TEXTURE NAME INCLUDING THE SUFFIX IF IT HAS ONE (I.E. .JPG, .BMP, etc.) MAKE SURE TO LEAVE THE QUOTE MARKS BEFORE AND AFTER. SAVE, THEN WHEN YOU PUT THIS SCRIPT INTO THE OBJECT MAKE SURE YOU PUT THE TEXTURE AS WELL.
  54. string texture = "shamrock1";
  55. ///////////////////////////////////////////////////////
  56. // Timing & Creation Variables Variables
  57. //
  58. // Affects the number and density of particles
  59. ///////////////////////////////////////////////////////
  60. // ParticleLife sets the Lifetime of one particle (seconds)
  61. // SystemLife sets the lifetime of the emitter (0.0 is infinite)
  62. // EmissionRate is how many seconds between particle spawns
  63. // PartPerEmission is how many particles spawn at a time
  64. float particleLife = 6.0;
  65. float SystemLife = 0.0;
  66. float emissionRate = 1.0;
  67. integer partPerEmission = 1;
  68. ///////////////////////////////////////////////////////
  69. // 3D Particle Space Variables
  70. //
  71. // Affect how the particles spawn into the world
  72. ///////////////////////////////////////////////////////
  73. // The radius is used to spawn angular particle patterns
  74. // The angles are represented on 'both' sides of a prim
  75. // The begin angle is the 'upper' starting point (radians)
  76. // The end angle is the 'lower' stopping point (radians)
  77. // Omega sets the speed of rotation about the <x,y,z> axis
  78. float radius = 0.0;
  79. float beginAngle = 0.0;
  80. float endAngle = 1.5;
  81. vector omega = <0.0, 0.0, 0.0>;
  82. ///////////////////////////////////////////////////////
  83. // Movement & Speed Variables
  84. //
  85. // Affects how particles travel in 3D space
  86. ///////////////////////////////////////////////////////
  87. // The speed values set the minimum and maximum speed
  88. // particles have upon spawning.
  89. // The acceleration is global to all particles (think gravity)
  90. // WindEffect TRUE applies the current sim wind to particles
  91. // BounceEffect TRUE means particles bounce on the 'floor'
  92. // aka the z height of their emitter
  93. // FollowSource TRUE means particles start on their emitter
  94. // and move as it moves.
  95. // FollowTarget means particles travel in linear path from
  96. // emitter to their target object
  97. // Target is declared here but used in the setParticles function
  98. float minSpeed = 0.1;
  99. float maxSpeed = 0.15;
  100. vector acceleration = <0.0, 0.0, -0.1>;
  101. integer windEffect = FALSE;
  102. integer bounceEffect = FALSE;
  103. integer followSource = FALSE;
  104. integer followTarget = FALSE;
  105. key target;
  106. ///////////////////////////////////////////////////////
  107. // Pattern Selection
  108. //
  109. // (Uncomment one of the following)
  110. ///////////////////////////////////////////////////////
  111. // DROP simply drops the particles at the emitters center
  112. // EXPLODE has all particles moving outward from the center
  113. // ANGLE has particles at radius distance and between angle
  114. // values in a 2D plane shape
  115. // ANGLE_CONE has particles at radius distance and between
  116. // angle values in a 3D cone shape
  117. //integer pattern = PSYS_SRC_PATTERN_DROP;
  118. //integer pattern = PSYS_SRC_PATTERN_EXPLODE;
  119. integer pattern = PSYS_SRC_PATTERN_ANGLE;
  120. //integer pattern = PSYS_SRC_PATTERN_ANGLE_CONE;
  121. ///////////////////////////////////////////////////////
  122. // Particle System Call Function
  123. //
  124. // Calling this function applies the particle
  125. // parameters to the current prim the script is in.
  126. ///////////////////////////////////////////////////////
  127. setParticles()
  128. {
  129. // Here is where to set the current target to any valid key
  130. // target=llGetKey(); //Targets the emitter
  131. // target=llGetOwner(); //Targets the owner
  132. // The following if statements are used to construct the mask
  133. if (colorInterpolation) effectFlags = effectFlags|PSYS_PART_INTERP_COLOR_MASK;
  134. if (sizeInterpolation) effectFlags = effectFlags|PSYS_PART_INTERP_SCALE_MASK;
  135. if (windEffect) effectFlags = effectFlags|PSYS_PART_WIND_MASK;
  136. if (bounceEffect) effectFlags = effectFlags|PSYS_PART_BOUNCE_MASK;
  137. if (followSource) effectFlags = effectFlags|PSYS_PART_FOLLOW_SRC_MASK;
  138. if (followVelocity) effectFlags = effectFlags|PSYS_PART_FOLLOW_VELOCITY_MASK;
  139. if (target!="") effectFlags = effectFlags|PSYS_PART_TARGET_POS_MASK;
  140. if (glowEffect) effectFlags = effectFlags|PSYS_PART_EMISSIVE_MASK;
  141. llParticleSystem([
  142. PSYS_PART_FLAGS, effectFlags,
  143. PSYS_SRC_PATTERN, pattern,
  144. PSYS_PART_START_COLOR, startColor,
  145. PSYS_PART_END_COLOR, endColor,
  146. PSYS_PART_START_ALPHA, startAlpha,
  147. PSYS_PART_END_ALPHA, endAlpha,
  148. PSYS_PART_START_SCALE, startSize,
  149. PSYS_PART_END_SCALE, endSize,
  150. PSYS_PART_MAX_AGE, particleLife,
  151. PSYS_SRC_ACCEL, acceleration,
  152. PSYS_SRC_TEXTURE, texture,
  153. PSYS_SRC_BURST_RATE, emissionRate,
  154. PSYS_SRC_ANGLE_BEGIN, beginAngle,
  155. PSYS_SRC_ANGLE_END, endAngle,
  156. PSYS_SRC_BURST_PART_COUNT, partPerEmission,
  157. PSYS_SRC_BURST_RADIUS, radius,
  158. PSYS_SRC_BURST_SPEED_MIN, minSpeed,
  159. PSYS_SRC_BURST_SPEED_MAX, maxSpeed,
  160. PSYS_SRC_MAX_AGE, SystemLife,
  161. PSYS_SRC_TARGET_KEY, target,
  162. PSYS_SRC_OMEGA, omega ]);
  163. }
  164. integer l1;
  165. default
  166. {
  167. on_rez(integer start_param)
  168. {
  169. if(l1!=0)
  170. llListenRemove(l1);
  171. l1=llListen(1,"",llGetOwner(),"");
  172. }
  173. state_entry()
  174. {
  175. if(l1!=0)
  176. llListenRemove(l1);
  177. l1=llListen(1,"",llGetOwner(),"");
  178. }
  179. listen(integer channel, string name, key id, string msg)
  180. {
  181. if(msg=="sparkles on")
  182. {
  183. setParticles();
  184. }
  185. else if(msg=="sparkles off")
  186. {
  187. llParticleSystem([]);
  188. }
  189. else if(msg=="hornglow on")
  190. {
  191. llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <0.94, 0.96, 0.98>, 1.0, 1.5, 1.0]);
  192. }
  193. else if(msg=="hornglow off")
  194. {
  195. llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE, <0.94, 0.96, 0.98>, 1.0, 1.5, 1.0]);
  196. }
  197. }
  198. }
  199. // END //