Difference between revisions of "PSYS Template"

From Second Life Wiki
Jump to navigation Jump to search
m
m (some reformatting to improve readability and added LSL TIp with reference to llLinkParticleSystem)
Line 1: Line 1:
{{LSL Header}}
{{LSL Header}}
====PSYS Template====
====PSYS Template====
--[[User:BETLOG Hax|BETLOG Hax]] UTC+10: 20090709 2208 [SLT: 20090709 0508]
{{LSL Tip|You might want to use [[llLinkParticleSystem]] instead of [[llParticleSystem]] dependant upon the desired effects.}}
--[[User:BETLOG Hax|BETLOG Hax]] SLT: July 9th 2009


All of the flags for making particles in a script with important inter-relationship comments only.
All of the flags for making particles in a script with important inter-relationship comments only.
Line 7: Line 8:
(declaring a bunch of variables instead of just learning to read the actual flag names is stupid)
(declaring a bunch of variables instead of just learning to read the actual flag names is stupid)
<lsl>
<lsl>
integer    gOn         = TRUE;
integer hasParticleEffect = TRUE;
//=========================================================================
 
list particle_effects()
{
     return
        [PSYS_PART_FLAGS, ( 0
            | PSYS_PART_INTERP_COLOR_MASK
            | PSYS_PART_INTERP_SCALE_MASK
            | PSYS_PART_EMISSIVE_MASK
//          | PSYS_PART_WIND_MASK
//          | PSYS_PART_BOUNCE_MASK
//          | PSYS_PART_FOLLOW_SRC_MASK  //disables BURST_RADIUS
//          | PSYS_PART_FOLLOW_VELOCITY_MASK
//          | PSYS_PART_TARGET_POS_MASK  //target TARGET_KEY
//          | PSYS_PART_TARGET_LINEAR_MASK    //requires TARGET_KEY disables ACCEL, BURST_RADIUS
            ),
        PSYS_PART_START_COLOR,      <1.0, 0.5, 0.0>,
        PSYS_PART_START_ALPHA,      1.0,
        PSYS_PART_END_COLOR,        <0.3, 0.0, 0.0>,
        PSYS_PART_END_ALPHA,        0.0,
        PSYS_PART_START_SCALE,      <0.5, 0.5, 0>,
        PSYS_PART_END_SCALE,        <0.5, 0.5, 0>,
        PSYS_PART_MAX_AGE,          1.0,
        PSYS_SRC_ACCEL,            ZERO_VECTOR,
        PSYS_SRC_PATTERN,          8,
//              DROP (1), EXPLODE (2), ANGLE (4), ANGLE_CONE (8), ANGLE_CONE_EMPTY (10)
//              1 - disables BURST_RADIUS, BURST_SPEED_MIN, BURST_SPEED_MAX
//              4/8/10 - requires ANGLE_BEGIN, ANGLE_END
        PSYS_SRC_TEXTURE,          "",
        PSYS_SRC_BURST_RATE,        0.05,
        PSYS_SRC_BURST_PART_COUNT,  4,
        PSYS_SRC_BURST_RADIUS,      1.0,
        PSYS_SRC_BURST_SPEED_MIN,  0.0,
        PSYS_SRC_BURST_SPEED_MAX,  0.1,
        PSYS_SRC_MAX_AGE,          0.0,
        PSYS_SRC_TARGET_KEY,        NULL_KEY,
        PSYS_SRC_OMEGA,            ZERO_VECTOR,
        PSYS_SRC_ANGLE_BEGIN,      0.5,
        PSYS_SRC_ANGLE_END,         0.5];
}
 
toggle_particles()
{
    hasParticleEffect = !hasParticleEffect;
 
    if (hasParticleEffect)
//  {
        llParticleSystem( particle_effects() );
//  }
    else
//  {
        llParticleSystem([]);
// }
}
 
default
default
{
{
     on_rez(integer start_param)
     on_rez(integer start_param)
     {   llResetScript();
     {
    }
        llResetScript();
    touch_start(integer num_detected)
    {  gOn = !gOn; 
        state cycle;
     }
     }
     state_entry()
     state_entry()
     {   if(gOn)
     {
        {  llParticleSystem( [
         toggle_particles();
                PSYS_PART_FLAGS, ( 0
                    | PSYS_PART_INTERP_COLOR_MASK
                    | PSYS_PART_INTERP_SCALE_MASK
                    | PSYS_PART_EMISSIVE_MASK
    //                | PSYS_PART_WIND_MASK
    //                | PSYS_PART_BOUNCE_MASK
    //                | PSYS_PART_FOLLOW_SRC_MASK  //disables BURST_RADIUS 
    //                | PSYS_PART_FOLLOW_VELOCITY_MASK
    //                | PSYS_PART_TARGET_POS_MASK  //target TARGET_KEY   
    //                | PSYS_PART_TARGET_LINEAR_MASK    //requires TARGET_KEY disables ACCEL, BURST_RADIUS
                )
                ,PSYS_PART_START_COLOR,    <1.0, 0.5, 0.0>
                ,PSYS_PART_START_ALPHA,    1.0
                ,PSYS_PART_END_COLOR,      <0.3, 0.0, 0.0>
                ,PSYS_PART_END_ALPHA,      0.0
                ,PSYS_PART_START_SCALE,    <0.5, 0.5, 0>
                ,PSYS_PART_END_SCALE,      <0.5, 0.5, 0>
                ,PSYS_PART_MAX_AGE,        1.0    //particle age
                ,PSYS_SRC_ACCEL,            <0.0, 0.0, 0.0>
                ,PSYS_SRC_PATTERN,          8
    //1=DROP,2=EXPLODE,4=ANGLE,8=ANGLE_CONE,10=ANGLE_CONE_EMPTY
    //1 - disables BURST_RADIUS, BURST_SPEED_MIN, BURST_SPEED_MAX
    //4/8/10 - requires ANGLE_BEGIN, ANGLE_END
    //                ,PSYS_SRC_INNERANGLE,      DEPRECIATED
    //                ,PSYS_SRC_OUTERANGLE,      DEPRECIATED   
                ,PSYS_SRC_TEXTURE,          ""
    //                llGetInventoryName(INVENTORY_TEXTURE, 0) //the first tex in inv
                ,PSYS_SRC_BURST_RATE,      0.05
    //                ,14,                        UNDOCUMENTED               
                ,PSYS_SRC_BURST_PART_COUNT, 4
                ,PSYS_SRC_BURST_RADIUS,    1.0
                ,PSYS_SRC_BURST_SPEED_MIN,  0.0
                ,PSYS_SRC_BURST_SPEED_MAX,  0.1
                ,PSYS_SRC_MAX_AGE,          0.0 //emission duration
                ,PSYS_SRC_TARGET_KEY,
                        (key)""
    //                    llGetLinkKey(llGetLinkNum() + 1)
    //                    llGetKey()
                ,PSYS_SRC_OMEGA,            <0.0, 0.0, 0.0>
                ,PSYS_SRC_ANGLE_BEGIN,      0.5
                ,PSYS_SRC_ANGLE_END,        0.5
            ]);
        }
        else
         {  llParticleSystem([]);
        }
     }
     }
}
 
//======================================================================================
    touch_start(integer num_detected)
state cycle
     {
{  state_entry()
        toggle_particles();
     {   state default;
     }
     }
}
}
//======================================================================================
</lsl>
</lsl>
[[Category:LSL Examples]]
[[Category:LSL Examples]]

Revision as of 13:23, 29 October 2012

PSYS Template

KBcaution.png Important: You might want to use llLinkParticleSystem instead of llParticleSystem dependant upon the desired effects.

--BETLOG Hax SLT: July 9th 2009

All of the flags for making particles in a script with important inter-relationship comments only.
(declaring a bunch of variables instead of just learning to read the actual flag names is stupid) <lsl> integer hasParticleEffect = TRUE;

list particle_effects() {

   return
       [PSYS_PART_FLAGS, ( 0
           | PSYS_PART_INTERP_COLOR_MASK
           | PSYS_PART_INTERP_SCALE_MASK
           | PSYS_PART_EMISSIVE_MASK

// | PSYS_PART_WIND_MASK // | PSYS_PART_BOUNCE_MASK // | PSYS_PART_FOLLOW_SRC_MASK //disables BURST_RADIUS // | PSYS_PART_FOLLOW_VELOCITY_MASK // | PSYS_PART_TARGET_POS_MASK //target TARGET_KEY // | PSYS_PART_TARGET_LINEAR_MASK //requires TARGET_KEY disables ACCEL, BURST_RADIUS

           ),
       PSYS_PART_START_COLOR,      <1.0, 0.5, 0.0>,
       PSYS_PART_START_ALPHA,      1.0,
       PSYS_PART_END_COLOR,        <0.3, 0.0, 0.0>,
       PSYS_PART_END_ALPHA,        0.0,
       PSYS_PART_START_SCALE,      <0.5, 0.5, 0>,
       PSYS_PART_END_SCALE,        <0.5, 0.5, 0>,
       PSYS_PART_MAX_AGE,          1.0,
       PSYS_SRC_ACCEL,             ZERO_VECTOR,
       PSYS_SRC_PATTERN,           8,

// DROP (1), EXPLODE (2), ANGLE (4), ANGLE_CONE (8), ANGLE_CONE_EMPTY (10) // 1 - disables BURST_RADIUS, BURST_SPEED_MIN, BURST_SPEED_MAX // 4/8/10 - requires ANGLE_BEGIN, ANGLE_END

       PSYS_SRC_TEXTURE,           "",
       PSYS_SRC_BURST_RATE,        0.05,
       PSYS_SRC_BURST_PART_COUNT,  4,
       PSYS_SRC_BURST_RADIUS,      1.0,
       PSYS_SRC_BURST_SPEED_MIN,   0.0,
       PSYS_SRC_BURST_SPEED_MAX,   0.1,
       PSYS_SRC_MAX_AGE,           0.0,
       PSYS_SRC_TARGET_KEY,        NULL_KEY,
       PSYS_SRC_OMEGA,             ZERO_VECTOR,
       PSYS_SRC_ANGLE_BEGIN,       0.5,
       PSYS_SRC_ANGLE_END,         0.5];

}

toggle_particles() {

   hasParticleEffect = !hasParticleEffect;
   if (hasParticleEffect)

// {

       llParticleSystem( particle_effects() );

// }

   else

// {

       llParticleSystem([]);

// } }

default {

   on_rez(integer start_param)
   {
       llResetScript();
   }
   state_entry()
   {
       toggle_particles();
   }
   touch_start(integer num_detected)
   {
       toggle_particles();
   }

} </lsl>