Optional Birth particle_plug_in.lsl 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. // :CATEGORY:XS Pet
  2. // :NAME:XS Pet Robot
  3. // :AUTHOR:Ferd Frederix
  4. // :KEYWORDS: Pet,XS,breed,breedable,companion,Ozimal,Meeroo,Amaretto,critter,Fennux,Pets
  5. // :CREATED:2013-09-06
  6. // :EDITED:2014-01-30 12:24:21
  7. // :ID:988
  8. // :NUM:1460
  9. // :REV:0.50
  10. // :WORLD:Second Life, OpenSim
  11. // :DESCRIPTION:
  12. // XS Pet plug in for particle effects when a pet lays an egg.
  13. // :CODE:
  14. //// plug in for particle effects when a pet lays an egg.
  15. // You can look at my script library at http://outworldz.com/cgi/freescripts.plx?Category=Particles for particle subroutines.
  16. // Just be sure that whatever subroutine you use, it is named "startParticles()".
  17. // To mix particles together and have more than one effect, you have to put a script in additional prims.
  18. // Change the particle effect, and put this script in different child prims, as each prim can have only one particle emitter.
  19. // you can change this next line
  20. float SECONDS = 5.0; // how long to play the effect before it is shut off
  21. // this message is sent by xs_brain when she lays an egg. A Global Constant in the XS Pets. Don't mess with it.
  22. integer LINK_LAY_EGG = 970; // Rez Object(Egg...
  23. // this next function makes the particles.
  24. // change this function to any particle effect you want.
  25. startParticles() {
  26. // this is a well-documented particle subroutine by Xah Lee from
  27. // http://outworldz.com/cgi/freescripts.plx?ID=1240
  28. llParticleSystem([
  29. //------------------------------------
  30. // overall pattern of the whole particles
  31. // pick one in the following.
  32. // The pattern EXPLODE is good for fireworks. The DROP would be good for water drops. The PATTERN_ANGLE will burst particles in a pie-shape in the x-plane. Good for example for rainbow. ANGLE_CONE is a cone along the z-axes, good for example for jet exhaust, or water fountain. ANGLE_CONE_EMPTY is like ANGLE_CONE, but where ANGLE_CONE shoots, ANGLE_CONE_EMPTY will not.
  33. PSYS_SRC_PATTERN,
  34. PSYS_SRC_PATTERN_EXPLODE
  35. //PSYS_SRC_PATTERN_DROP
  36. //PSYS_SRC_PATTERN_ANGLE
  37. //PSYS_SRC_PATTERN_ANGLE_CONE
  38. //PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY
  39. ,
  40. //------------------------------------
  41. // THE SHAPE OF EACH PARTICLE
  42. PSYS_SRC_TEXTURE, "", // invt name, or UUID of a texture, when blank it wil be white spots
  43. //------------------------------------
  44. // parameters for the particle emiter. (units for time are in seconds.)
  45. // duration of the emitter will be spawning. Use 0. for forever. 60. is the max.
  46. PSYS_SRC_MAX_AGE, 0.0,
  47. //frequency of spawning
  48. PSYS_SRC_BURST_RATE, 0.9, //
  49. // number of particles per burst
  50. PSYS_SRC_BURST_PART_COUNT, 4,
  51. // The distance the particle will be created from the emitter.
  52. PSYS_SRC_BURST_RADIUS, 1.0,
  53. // Particles will fly off at a random speed between min and max.
  54. // For example, if you want a burst such that all sparkles are on the increasingly larger spherical boundary,
  55. // set the max and min speed to the same value such as 1.0.
  56. // If you want the sparkles to be inside the spherical boundary as well, use for example 0.1 and 1.0.
  57. PSYS_SRC_BURST_SPEED_MIN, 1.0,
  58. PSYS_SRC_BURST_SPEED_MAX, 1.0,
  59. // A force on the particle after they are emitted. Each unit is meter per second. Max is 100.
  60. // So, to emulate water falling from a sprinkler nozzle, use <0.0,0.0,-0.8> to emulate a gravity.
  61. // To emulate smoke being sucked into a tunnel, use a vector with non-zero x and y coordinates.
  62. PSYS_SRC_ACCEL, <0.0,0.0,0.1>, // push up so the particles rise slowly = 0.1 in th Z axis
  63. // The following are for the directions of the particle burst.
  64. // They are valid if the particle pattern is one of PSYS_SRC_PATTERN_ANGLE, PSYS_SRC_PATTERN_ANGLE_CONE, PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY.
  65. // The PSYS_SRC_OMEGA will rotate the shooting. Angle starts from the z-axes and are in radians.
  66. PSYS_SRC_ANGLE_BEGIN, 1.0,
  67. PSYS_SRC_ANGLE_END, 1.1,
  68. PSYS_SRC_OMEGA, < 0.0, 0.0 , 0.0>,
  69. //------------------------------------
  70. // parameters that controls the particle sprites (a sprite is a 2D image that always faces the viewer.Particles are sprites.)
  71. // the age of each particle. Max is 30.
  72. PSYS_PART_MAX_AGE, 10.0,
  73. // The end color must have PSYS_PART_INTERP_COLOR_MASK on in PSYS_PART_FLAGS
  74. PSYS_PART_START_COLOR, <1.0,0.0,0.0>, // from Red
  75. PSYS_PART_END_COLOR, <0.0,0.0,1.0>, // to Blue as they age
  76. // The ALPHA is transparency, from 0 to 1. 1 means opaque.
  77. PSYS_PART_START_ALPHA, 0.8 , // Start from 0.8 = slighty transparent, like smoke
  78. PSYS_PART_END_ALPHA, 0.0 , // to 0, wheich makes them fade away
  79. //scale change. valid values are from 0.031 to 4.0 .
  80. //must have INTERP_SCALE_MASK on in PSYS_PART_FLAGS.
  81. PSYS_PART_START_SCALE, <1.0,1.0,0.0>, // from full size
  82. PSYS_PART_END_SCALE, <0.1,0.1,0.0>, // to 1/10 size, so they shrink as they age
  83. //------------------------------------
  84. // miscellaneous behaviors controlled by PSYS_PART_FLAGS, you can comment out any of the lines that begin with |
  85. PSYS_PART_FLAGS
  86. , 0 // leave this alone, a 0 or'd with the following is harmless, but it stops errors if you comment out everything below
  87. // glows. Basically brighter.
  88. | PSYS_PART_EMISSIVE_MASK
  89. // change particle color. Makes PSYS_PART_START_COLOR, PSYS_PART_END_COLOR work.
  90. | PSYS_PART_INTERP_COLOR_MASK
  91. // make it change size during its life. makes PSYS_PART_START_SCALE, PSYS_PART_END_SCALE work.
  92. | PSYS_PART_INTERP_SCALE_MASK
  93. // make particles bounce off emiter's z-axis height, works only when the particle falls after bust.
  94. | PSYS_PART_BOUNCE_MASK
  95. // The PSYS_PART_FOLLOW_SRC_MASK makes the emitted particle's positions follow the emiter (disables PSYS_SRC_BURST_RADIUS). If not set, then particles once emitted outside of the PSYS_SRC_BURST_RADIUS will flow by themselves.
  96. // For example, a blinking LED on a watch should have this set. Smokes from a cigerette should not have this set.
  97. | PSYS_PART_FOLLOW_SRC_MASK
  98. // Orient the particle sprite (the image) with the emiter's bursting direction.
  99. // For example, a rotating water sprinkler should have this set.
  100. // But if your sprite is textual such as "I Love You", then it should not have this set.
  101. | PSYS_PART_FOLLOW_VELOCITY_MASK
  102. // straight line to target (cancels PSYS_SRC_ACCEL, PSYS_SRC_BURST_RADIUS)
  103. //| PSYS_PART_TARGET_LINEAR_MASK
  104. // make it blown by wind
  105. //| PSYS_PART_WIND_MASK
  106. //make particles follow a target specified at PSYS_SRC_TARGET_KEY
  107. //PSYS_PART_TARGET_POS_MASK
  108. //------------------------------------
  109. // following behavior. (needs PSYS_PART_FOLLOW_VELOCITY_MASK on)
  110. //PSYS_SRC_TARGET_KEY,llGetKey(),
  111. ]);
  112. }
  113. // Plays the effect for SECONDS, then shuts it off.
  114. PlayEffect()
  115. {
  116. startParticles(); // turn particles on
  117. llSleep(SECONDS); // wait X seconds
  118. llParticleSystem([]); // turn particles off
  119. }
  120. // This is the default state we are in
  121. default
  122. {
  123. // play the effect for X seconds when you reset the script so you can see it and debug it. Otherwise is unused.
  124. state_entry()
  125. {
  126. PlayEffect();
  127. }
  128. // The pet sends a link message when it lays an egg.
  129. link_message(integer sender, integer num, string str, key id)
  130. {
  131. if (num == LINK_LAY_EGG)
  132. {
  133. PlayEffect();
  134. }
  135. }
  136. }