LSL particle script: soft sparkles around an object
Free LSL particle script for Second Life: soft gold and pink sparkles for gifts, signs and magic items, with colour, size and amount settings and touch on/off.
A few sparkles make a gift box, a sign or a magic wand stand out. This particle script sends out soft, glowing sparkles that fade as they drift. All the important values are at the top, so you can make your own effect without learning the whole particle system.
// Sparkle Particles - free LSL script from WhatSL (https://whatsl.com/scripts/lsl-particle-script)
// Free to use, change and put in your own creations, also ones you sell.
//
// Soft sparkles around the object: good for gifts, magic items, signs and decorations.
// Touch to turn them on and off. Change the colours and sizes below to make your own effect.
vector COLOR_START = <1.0, 0.9, 0.5>; // gold
vector COLOR_END = <1.0, 0.6, 0.9>; // pink
float SIZE_START = 0.10; // metres
float SIZE_END = 0.04;
float PARTICLE_LIFE = 2.0; // seconds each sparkle lives
float BURST_RATE = 0.1; // seconds between bursts
integer BURST_COUNT = 3; // sparkles per burst
string PARTICLE_TEXTURE = ""; // "" = the standard round particle; or a texture UUID
integer START_ON = TRUE;
integer gOn = FALSE;
sparkle(integer on)
{
gOn = on;
if (!on)
{
llParticleSystem([]);
return;
}
list rules = [
PSYS_PART_FLAGS, PSYS_PART_EMISSIVE_MASK | PSYS_PART_INTERP_COLOR_MASK | PSYS_PART_INTERP_SCALE_MASK,
PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_EXPLODE,
PSYS_PART_START_COLOR, COLOR_START,
PSYS_PART_END_COLOR, COLOR_END,
PSYS_PART_START_ALPHA, 1.0,
PSYS_PART_END_ALPHA, 0.0,
PSYS_PART_START_SCALE, <SIZE_START, SIZE_START, 0.0>,
PSYS_PART_END_SCALE, <SIZE_END, SIZE_END, 0.0>,
PSYS_PART_MAX_AGE, PARTICLE_LIFE,
PSYS_SRC_BURST_RATE, BURST_RATE,
PSYS_SRC_BURST_PART_COUNT, BURST_COUNT,
PSYS_SRC_BURST_SPEED_MIN, 0.05,
PSYS_SRC_BURST_SPEED_MAX, 0.3,
PSYS_SRC_ACCEL, <0.0, 0.0, -0.05>
];
if (PARTICLE_TEXTURE != "") rules += [PSYS_SRC_TEXTURE, PARTICLE_TEXTURE];
llParticleSystem(rules);
}
default
{
state_entry()
{
sparkle(START_ON);
}
touch_start(integer total)
{
sparkle(!gOn);
}
}
Free to use, change and put in your own creations, also ones you sell.
How to set it up
- Put the script in the object and save. Sparkles appear right away.
- Touch the object to turn them off and on.
- Change the colours, sizes and amounts and save again to see the result.
Settings
- COLOR_START and COLOR_END: each sparkle fades from the first colour to the second.
- SIZE_START and SIZE_END: the size of a sparkle when it appears and when it disappears, in metres.
- PARTICLE_LIFE: how many seconds each sparkle lives.
- BURST_RATE and BURST_COUNT: how often sparkles appear and how many at a time.
- PARTICLE_TEXTURE: empty for the standard round particle, or the UUID of your own particle texture.
Tips
- Less is more: a few slow sparkles look classier than a cloud of fast ones, and they are easier on the viewer.
- Particles are a setting of the prim. If you delete the script, they keep going. To stop them for good, touch to turn them off first, then delete the script.
Frequently asked questions
Why can't I see any particles?
Your viewer may have particles turned down. Check the maximum particle count in the graphics settings.
How do I make snow or rain instead?
Use a white or blue colour, a longer PARTICLE_LIFE and a stronger downward pull: change PSYS_SRC_ACCEL to something like <0.0, 0.0, -0.5> and place the emitter high up.
Do particles cause lag?
Particles are drawn by each viewer, so they do not slow the region, but very many particles can slow down visitors' viewers. Keep BURST_COUNT small.