Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Problems with particle script maybe a bug!!!

Robertt Goodliffe
Registered User
Join date: 1 Jan 2006
Posts: 16
01-16-2007 15:15
Ok im having problems with the particle script ill post below and was wondering if its a bug or if something about particle scripts I dont know about.

Basicly what is happening the script is only suppose to realease a burst of particles when a timer goes off. However it seems that for no reason the object will release the burst of particles when ever somebody right clicks the object then again when they deselect the object. Or if another script in another prim in the object speaks on chat.

It sounds like a bug to me. At first it doesnt do it at all, but then when i log out and log in or teleport to where my object is i am greeted by a bust of particles out of the object and then when ever it is right clicked it creates another burst of particles.

The particle script is stored in prim which contains another script with no particles effects.
The object has 3 prims in total 4 scripts in total, 2 scripts in the Parent Prim including the Particle Script.

CODE


///////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//// eltee Statosky's Particle Creation Engine 1.2
//// 03/19/2004
//// *PUBLIC DOMAIN*
//// Free to use
//// Free to copy
//// Free to poke at
//// Free to hide in stuff you sell
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//// Changelog:
//// 1.2: (1) Seperated out variable value assignments to
//// dedicated function call (easier to copy/paste)
//// (2) Improved several comments
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
////// Particle System Variables
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////



///////////////////////////////////////////////////////
// Effect Flag Collection variable
///////////////////////////////////////////////////////
integer effectFlags;
integer running=FALSE;

///////////////////////////////////////////////////////
// Color Secelection Variables
///////////////////////////////////////////////////////
// Interpolate between startColor and endColor
integer colorInterpolation;
// Starting color for each particle
vector startColor;
// Ending color for each particle
vector endColor;
// Starting Transparency for each particle (1.0 is solid)
float startAlpha;
// Ending Transparency for each particle (0.0 is invisible)
float endAlpha;
// Enables Absolute color (true) ambient lighting (false)
integer glowEffect;

///////////////////////////////////////////////////////
// Size & Shape Selection Variables
///////////////////////////////////////////////////////
// Interpolate between startSize and endSize
integer sizeInterpolation;
// Starting size of each particle
vector startSize;
// Ending size of each particle
vector endSize;
// Turns particles to face their movement direction
integer followVelocity;
// Texture the particles will use ("" for default)
string texture;

///////////////////////////////////////////////////////
// Timing & Creation Variables Variables
///////////////////////////////////////////////////////
// Lifetime of one particle (seconds)
float particleLife;
// Lifetime of the system 0.0 for no time out (seconds)
float SystemLife;
// Number of seconds between particle emissions
float emissionRate;
// Number of particles to releast on each emission
integer partPerEmission;

///////////////////////////////////////////////////////
// Angular Variables
///////////////////////////////////////////////////////
// The radius used to spawn angular particle patterns
float radius;
// Inside angle for angular particle patterns
float innerAngle;
// Outside angle for angular particle patterns
float outerAngle;
// Rotational potential of the inner/outer angle
vector omega;

///////////////////////////////////////////////////////
// Movement & Speed Variables
///////////////////////////////////////////////////////
// The minimum speed a particle will be moving on creation
float minSpeed;
// The maximum speed a particle will be moving on creation
float maxSpeed;
// Global acceleration applied to all particles
vector acceleration;
// If true, particles will be blown by the current wind
integer windEffect;
// if true, particles 'bounce' off of the object's Z height
integer bounceEffect;
// If true, particles spawn at the container object center
integer followSource;
// If true, particles will move to expire at the target
//integer followTarget = TRUE;
// Desired target for the particles (any valid object/av key)
// target Needs to be set at runtime
key target;

///////////////////////////////////////////////////////
//As yet unimplemented particle system flags
///////////////////////////////////////////////////////
integer randomAcceleration = FALSE;
integer randomVelocity = FALSE;
integer particleTrails = FALSE;

///////////////////////////////////////////////////////
// Pattern Selection
///////////////////////////////////////////////////////
integer pattern;



///////////////////////////////////////////////////////
// Particle System Call Function
///////////////////////////////////////////////////////
setParticles()
{
// Here is where to set the current target

// Feel free to insert any other valid key
target="";
// The following block of if statements is used to construct the mask
if (colorInterpolation) effectFlags = effectFlags|PSYS_PART_INTERP_COLOR_MASK;
if (sizeInterpolation) effectFlags = effectFlags|PSYS_PART_INTERP_SCALE_MASK;
if (windEffect) effectFlags = effectFlags|PSYS_PART_WIND_MASK;
if (bounceEffect) effectFlags = effectFlags|PSYS_PART_BOUNCE_MASK;
if (followSource) effectFlags = effectFlags|PSYS_PART_FOLLOW_SRC_MASK;
if (followVelocity) effectFlags = effectFlags|PSYS_PART_FOLLOW_VELOCITY_MASK;
if (target!="") effectFlags = effectFlags|PSYS_PART_TARGET_POS_MASK;
if (glowEffect) effectFlags = effectFlags|PSYS_PART_EMISSIVE_MASK;
llParticleSystem([
PSYS_PART_FLAGS, effectFlags,
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, startSize,
PSYS_PART_END_SCALE, endSize,
PSYS_PART_MAX_AGE, particleLife,
PSYS_SRC_ACCEL, acceleration,
PSYS_SRC_TEXTURE, texture,
PSYS_SRC_BURST_RATE, emissionRate,
PSYS_SRC_INNERANGLE, innerAngle,
PSYS_SRC_OUTERANGLE, outerAngle,
PSYS_SRC_BURST_PART_COUNT, partPerEmission,
PSYS_SRC_BURST_RADIUS, radius,
PSYS_SRC_BURST_SPEED_MIN, minSpeed,
PSYS_SRC_BURST_SPEED_MAX, maxSpeed,
PSYS_SRC_MAX_AGE, SystemLife,
PSYS_SRC_TARGET_KEY, target,
PSYS_SRC_OMEGA, omega ]);
}


///////////////////////////////////////////////////////
// Particle Effect Function
// - Edit the values here to change the effect
///////////////////////////////////////////////////////
ParticleFallsEffect()
{
//Color
colorInterpolation = TRUE;
startColor = <1, 1, 1>;
endColor = <1, 1, 1>;
startAlpha = 1;
endAlpha = 1;
glowEffect = TRUE;
//Size & Shape
sizeInterpolation = TRUE;
startSize = <0.4, 0.4, 0.0>;
endSize = <0.3, 0.3, 0.0>;
followVelocity = FALSE;
texture = "tut-front";
//Timing
particleLife = 15.0;
SystemLife = 2;
emissionRate = 0.02;
partPerEmission = 2;
//Emission Pattern
radius = 2.0;
innerAngle = 1.0;
outerAngle = 2.0;
omega = <0.0, 0.0, 0.2>;
pattern = PSYS_SRC_PATTERN_EXPLODE;
// Drop parcles at the container objects' center
// PSYS_SRC_PATTERN_DROP;
// Burst pattern originating at objects' center
// PSYS_SRC_PATTERN_EXPLODE;
// Use 2D angle between innerAngle and outerAngle
// PSYS_SRC_PATTERN_ANGLE;
// Use 3D cone spread between innerAngle and outerAngle
// PSYS_SRC_PATTERN_ANGLE_CONE;
//Movement
minSpeed = 2;
maxSpeed = 4;
acceleration = <0.0, 0.0, 0>;
windEffect = FALSE;
bounceEffect = FALSE;
followSource = TRUE;
target = "";
// llGetKey() targets this script's container object
// llGetOwner() targets the owner of this script
//Particle Call
setParticles();
}
integer prize = 2825;
integer highscore = 0;
integer lwamount = 4060;
integer channel = 125;
integer Handle = 0;
integer listener;
integer onoff = 1;
integer shout = 1800;
string lastwinner = " ";


default
{
state_entry()
{
running=TRUE;
ParticleFallsEffect();
llListenRemove(listener);
listener = llListen(channel, "", llGetOwner(), "");
onoff=1;
llSetTimerEvent(shout);
}

on_rez(integer start_parm)
{

llListenRemove(listener);
listener = llListen(channel, "", llGetOwner(), "");


}

listen(integer channel, string name, key id, string message)
{
list msg = llParseString2List(message, [" "], []);
string comand = llList2String(msg,0);
if (comand == "particleson")
{
llOwnerSay("Particles are now turned on!!!!");
onoff = 1;
return;
}

if (comand == "particlesoff")
{
llOwnerSay("Particles are now turned off!!!!");
onoff = 0;
return;
}

if (comand == "shout")
{
shout = llList2Integer(msg,1);
if (shout == 0)
{
llOwnerSay("Shout Message is turned off");
llSetTimerEvent(shout);
return;
}
llOwnerSay("Shout Message will be stated every " + (string)shout + " seconds");
llSetTimerEvent(shout);
return;
}
}

link_message(integer sender_num, integer num, string str, key id)
{

if (str == "jackpot")
{
prize = num;
return;
}

if (str == "lwamount")
{
lwamount = num;
return;
}

if (num == 1234567890)
{
lastwinner = str;
return;
}
}

timer()
{
llShout(0,"MESSAGE");
if (onoff == 1)
{
ParticleFallsEffect();
llSleep(2);
llParticleSystem([]);

}


}


}

Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
01-16-2007 16:22
Dunno. I put that script into a prim and couldn't reproduce your symptoms at all.

Have you tried just doing that? Just create a prim and put ONLY that script in it, to see if it does the same thing? If it doesn't, then some other script it somehow triggering the particles.

--------------------
UPDATE:

Actually, it started doing this same thing to me after I left and came back in about 5 mins, even though it didn't do it initially.

There is a known issue related to particle systems which have a system age (not particle age) setting > 0. That's why you put the llSleep(2.0); llParticleSystem([]); call in the timer event, to stop that. However, you didn't do this in the one you put in the state_entry event, so for the first 30 minutes, it will blast the particles any time the prim is "edited", or if you change groups.

So, unless you need it to blast particles out on reset, just put a llParticleSystem([]); call in the state_entry event and that should fix it.
Robertt Goodliffe
Registered User
Join date: 1 Jan 2006
Posts: 16
Thx Talarus
01-16-2007 17:08
I spoke to the create of the original script and he said basicly exactly the same thing. I have placed the llParticleSystem([]); into state entry and it no longer seems to do it anymore.

So a big thankyou to yourself and eltee Statosky for your help.