Just some random particle script shortcuts I use often:
Setting up a simple "touch" on/off switch, with an auto-off timer.
CODE
default {
state_entry() {
llParticleSystem( [
// (your particle definition here )
] );
// llResetTime(); // edited - completely unnecessary, see next posts
llSetTimerEvent( 5.0 * 60.0 ); // 5 minute auto-off internval.
}
on_rez(integer n) { llResetScript(); }
touch_start(integer num_detected) { state particles_off; }
timer() { state particles_off; }
state_exit() { llParticleSystem( [ ] ); } // turns off particles
}
state particles_off {
touch_start( integer num_detected ) { state default; }
}
To automatically use the first texture in the prim's inventory for the particle effect:
CODE
default {
state_entry() {
string texture = "";
if ( llGetInventoryNumber( INVENTORY_TEXTURE ) > 0 )
texture = llGetInventoryName( INVENTORY_TEXTURE, 0 );
llParticleSystem( [
// (your particle definitions here and... ),
PSYS_SRC_TEXTURE, texture
] );
}
changed(integer change_type) {
// start over if prim's inventory changes
if ( change_type & CHANGED_INVENTORY ) { llResetScript(); }
}
}
Want a prim to target the parent object it's linked to?
Don't use listens! Try this:
CODE
default {
state_entry() {
key target = NULL_KEY;
if ( llGetLinkNumber() > 1 ) target = llGetLinkKey( 1 );
llParticleSystem( [
// (your particle definitions here ),
// PSYS_PART_FLAGS, (your flags)
| PSYS_PART_TARGET_POS_MASK,
PSYS_SRC_TARGET_KEY, target
] );
}
changed(integer change_type) {
// start over if the object's links change
if ( change_type & CHANGED_LINK ) { llResetScript(); }
}
on_rez(integer n) { llResetScript(); }
}
If you want to target a child prim of the object (instead of the parent prim), replace the 1 in llGetLinkKey(1) with the # of the child prim. You can get the child prim to tell you it's link number with: llOwnerSay( llGetLinkNumber() );
