PSYS Template

From Second Life Wiki
Revision as of 16:38, 24 January 2015 by ObviousAltIsObvious Resident (talk | contribs) (<lsl> tag to <source>)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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)

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();
    }
}