Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Please Help with this particle script

Mako Davidson
Registered User
Join date: 27 Jun 2006
Posts: 56
06-20-2007 09:22
I need to get the particles in this script to follow the owner of an object, it is placed in when the object is rezzed. I have been told to make the target key the owner before calling the particle function

e.g.
target = llGetOwner();
updateParticles();

where in the script do the above lines go pease???

//Change the beginning variable values to adjust the particle effect. Advanced users can write more complex functions into the script to be run on particle use.

integer interpColor = TRUE;//If TRUE, particles fade from startColor to endColor
vector startColor = <1,1,1>;//Starting color
vector endColor;//Ending color

float startAlpha = 1.0;//Starting visibility, 1 is fully visible, less than 1 is faded, 0 is invisible
float endAlpha = 0;//Ending visibility
integer emissive= TRUE;//If TRUE, particles glow in the dark

integer interpScale = TRUE; //If TRUE, particles change size from startScale to endScale
vector startScale = <10,5,5>; //Begining size
vector endScale = <.1,10,.1>; //Ending size

integer followVelocity = TRUE; //If TRUE, particles will turn to face their rotations
string texture = ""; //Texture of the particles, "" will use the default texture

float particleAge = 30; //Lifetime of each particle in seconds
float sourceAge = 0; //Lifetime of the entire system. 0 is indefinate

float burstRate = .01; //Time, in seconds, to release each wave of particles. 0 is fastest possible
integer burstCount = 20; //Number of particles to include in each wave
float burstRadius = 0; //Distance from the source to emit particles

integer pattern = PSYS_SRC_PATTERN_ANGLE_CONE; //Pattern at which to emit particles, options are PSYS_SRC_PATTERN_ANGLE,PSYS_SRC_PATTERN_ANGLE_CONE,PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY,PSYS_SRC_PATTERN_DROP,PSYS_SRC_PATTERN_EXPLODE
float angleBegin = 0; //Specifies where not to create particles, dependent on pattern. 0-PI
float angleEnd = .2; //Specifies where to create the particles for each pattern, 0-PI

vector omega = <0,0,0>; //Specifies the rate at which the source rotates
float speedMin = 15; //Specifies the lower bound on particle speed
float speedMax = 20; //Specifies the upper bound on particle speed

integer windMask = FALSE; //If TRUE, particles will be influenced by SL's wind
integer bounceMask = FALSE; //If TRUE, particles will bounce off an invisible floor set at the source's z position
integer followSource = FALSE; //If TRUE, particles will follow the source if moved. Nullifies burstRadius
vector acceleration = <0,0,-1>; //Sets an acceleration on each particle

vector offset = <0,0,-0.5>; //Offset from targets center for source to follow

Effect()
{
endColor = (<;(integer)llFrand(3)/2,(integer)llFrand(3)/2,(integer)llFrand(3)/2>;);
key target;


integer Flags;
list effect;
if (interpColor) Flags = Flags|PSYS_PART_INTERP_COLOR_MASK;
if (interpScale) Flags = Flags|PSYS_PART_INTERP_SCALE_MASK;
if (windMask) Flags = Flags|PSYS_PART_WIND_MASK;
if (bounceMask) Flags = Flags|PSYS_PART_BOUNCE_MASK;
if (followSource) Flags = Flags|PSYS_PART_FOLLOW_SRC_MASK;
if (followVelocity) Flags = Flags|PSYS_PART_FOLLOW_VELOCITY_MASK;
if (target != "";){ Flags = Flags|PSYS_PART_TARGET_POS_MASK;}
if (emissive) Flags = Flags|PSYS_PART_EMISSIVE_MASK;
effect=[PSYS_SRC_TARGET_KEY,target,PSYS_PART_FLAGS,Flags,PSYS_SRC_PATTERN,pattern,PSYS_PART_START_COLOR,startColor,PSYS_PART_END_COLOR,endColor,PSYS_PART_START_ALPHA,startAlpha,PSYS_PART_END_ALPHA,endAlpha,PSYS_PART_START_SCALE,startScale,PSYS_PART_END_SCALE,endScale,PSYS_PART_MAX_AGE,particleAge,PSYS_SRC_ACCEL,acceleration,PSYS_SRC_TEXTURE,texture,PSYS_SRC_BURST_RATE,burstRate,PSYS_SRC_ANGLE_BEGIN,angleBegin,PSYS_SRC_ANGLE_END,angleEnd,PSYS_SRC_BURST_PART_COUNT,burstCount,PSYS_SRC_BURST_RADIUS,burstRadius,PSYS_SRC_BURST_SPEED_MIN,speedMin,PSYS_SRC_BURST_SPEED_MAX,speedMax,PSYS_SRC_MAX_AGE,sourceAge,PSYS_SRC_OMEGA,omega];
llParticleSystem(effect);
}

default
{

state_entry()
{
if (llGetObjectName() == "Particle Effects";) //This is simply to ensure that a lag spike doesnt cause this script to go live while inside FP
{
llSetTimerEvent(5);
llMessageLinked(LINK_SET,0,"offset",(string)offset);
llSleep(.1);
Effect();
}
}
timer()
{
Effect();
}

}
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
06-20-2007 12:23
From: Mako Davidson
I need to get the particles in this script to follow the owner of an object, it is placed in when the object is rezzed. I have been told to make the target key the owner before calling the particle function

e.g.
target = llGetOwner();
updateParticles();

where in the script do the above lines go pease???
In the Effect() function, replace the line:
key target;
with:
key target = llGetOwner();

You don't need the "updateParticles();" -- that's a reference from a totally different "wrapper" of llParticleSystem();
Mako Davidson
Registered User
Join date: 27 Jun 2006
Posts: 56
06-20-2007 12:58
thankyou Qie :) that's what was throwing me.
Brin Allen
Registered User
Join date: 25 May 2007
Posts: 10
06-20-2007 12:59
From: Qie Niangao
In the Effect() function, replace the line:
key target;
with:
key target = llGetOwner();

You don't need the "updateParticles();" -- that's a reference from a totally different "wrapper" of llParticleSystem();


Settle down... I was just giving an example
Jopsy Pendragon
Perpetual Outsider
Join date: 15 Jan 2004
Posts: 1,906
06-20-2007 13:18
There are 4 different freely mod/copy/trans "Targetting" examples in The Particle Laboratory in TEAL if you care to see other methods. Sounds like you've got your answer though. :)

--
Bring back vB code!

The Particle Laboratory--
Tutorials, Samples, Scripts, Textures, Sandbox and more...
above Teal(200,50).