Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Wierd Issue

Phoenicis Sands
Registered User
Join date: 16 Apr 2007
Posts: 6
08-23-2007 05:53
I've been tinkering with a particle system script offline using LSLEditor (kudos to the author BTW). Everything in the editor works fine but when I cut and paste the script into SL I get syntax errors on lines 217, 218 and 219. If I comment those lines out the script compiles without syntax errors but doesn't generate any particles (I suspect one of those lines being commented out causes this)

If I copy those specific lines from the original script and past them into the modified script (I didn't modify those lines) the same thing occurs.

If I move the lines that are currently 217, 218 and 219 to other spots in the script (which I can do because of what those lines are) the lines that are currently 217, 218 and 219 get the syntax error.

The original script runs just fine, though I'm not sure it reaches line 217 as I've added quite a few lines before that to make the whole script work the way I want it to.

Any ideas on what may be causing/how to fix this would be appreciated.
Tiarnalalon Sismondi
Registered User
Join date: 1 Jun 2006
Posts: 402
08-23-2007 06:28
For someone to help you with this they'd probably need to see it to troubleshoot.
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
08-23-2007 06:32
I agree that seeing the script, or at least that section of it, would help a lot..

Almost sounds like you're missing a ;, ), }, " or something on one of the lines *before* 217..
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
08-23-2007 06:41
If you get the same errors for other lines of code by moving the particle related ones around the code, then your script simply may be too big.

See if you can simplify some of the code and check if you can make code less redundant by putting it in its own function and then call that one where that particular code is needed.
Phoenicis Sands
Registered User
Join date: 16 Apr 2007
Posts: 6
08-23-2007 18:15
The problem area moved in the latest iteration, line 229 is where it started, but functionally it's the same spot in the script. I tried adding comments to push the function past where the problem occures, but it didn't work.

Don't know what to do if the script is to big, I had to add a bunch of variables to make the script act the way I wanted it to, the original is less than 217 lines in total, my current version doesn't even get into the script itself until line 235.

Here is the script in it's entirety, any ideas how to shorten it up will be appreciated: (waves bye bye to his nice neat formating)

// Particle System Script
// Created by: Neil Protagonist
// Original by: Ama Omega
// Modified by: Phoenicis Sands
// Last Updated:
// Notes:
// All random values are added to the base, so set the base to the minimum
// acceptable value.
//
// These functions have been added due to a distinct lack in the particle system
// Linden labs should not rely on this doc as a replacement for fixing the inherit
// problems in the particle system.
//
// The script originally reset to recycle the particles so they would not scale out of control with
// succesive iterations of the function. The random function has been rewritten and a set
// of variables added so the script can be looped without the particles scaling out of control P.S.
//


// variables added so the particles can be turned on and off at will P.S.
float htimer = .2; // How fast to recycle the particles P.S.
integer hchannel = 719627; // just the channel I plan on using P.S.
string hmsg;
string name;
key id;
integer tag;



//float fObjSize = llGetScale();

// Mask Flags - set to TRUE to enable
integer iGlow = TRUE; // Set particles to be self illuminated
integer iBounce = FALSE; // Make particles bounce on Z plain of object
integer iInterpColor = TRUE; // Go from start to end color
integer iInterpSize = TRUE; // Go from start to end size
integer iWind = FALSE; // Particles effected by wind
integer iFollowSource = FALSE; // Particles follow the source
integer iFollowVel = TRUE; // Particles turn to velocity direction

// Choose a pattern from the following:
// PSYS_SRC_PATTERN_EXPLODE
// PSYS_SRC_PATTERN_DROP
// PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY
// PSYS_SRC_PATTERN_ANGLE_CONE
// PSYS_SRC_PATTERN_ANGLE
integer iPattern = PSYS_SRC_PATTERN_EXPLODE;

// Select a target for particles to go towards
// "" for no target, "owner" will follow object owner
// and "self" will target this object
// or put the key of an object for particles to go to
key kTarget = "";

////////// BEGIN PARTICLE PARAMS /////////////
// Added 's' variables so script does not have to be reset when looping
// to keep the particles the size you want them P.S.
float fAge = 1.5; // Life of each particle
float sAge = 1.5; // Life of each particle
float fAgeRnd = 0.5; // Random value applied to life.
float fMaxSpeed = 0.10; // Max speed each particle is spit out at
float sMaxSpeed = 0.10; // Max speed each particle is spit out at
float fMaxSpeedRnd = 0.05; // Random value for max speed
float fMinSpeed = 0.05; // Min speed each particle is spit out at
float sMinSpeed = 0.05; // Min speed each particle is spit out at
float fMinSpeedRnd = 0.05; // Random value for min speed
float fStartAlpha = 0.28; // Start alpha (transparency) value
float sStartAlpha = 0.28; // Start alpha (transparency) value
float fStartAlphaRnd = 0.10; // Rnd starting alpha value.
float fEndAlpha = 0.0; // End alpha (transparency) value
float sEndAlpha = 0.0; // End alpha (transparency) value
float fEndAlphaRnd = 0.00; // End alpha value rand.
// float fGravity = 0; // Gravity, added to push to simulate gravity.

vector vStartColor = <1,1,1>; // Start color of particles <R,G,B>
vector sStartColor = <1,1,1>; // Start color of particles <R,G,B>
float fStartColorRnd = 0; // Start color random
vector vEndColor = <0.8,0.4,0.4>; // End color of particles <R,G,B> (if interpColor == TRUE)
vector sEndColor = <0.8,0.4,0.4>; // End color of particles <R,G,B> (if interpColor == TRUE)
float fEndColorRnd = 0; // End color random
vector vStartSize = <0.1,0.1,0.1>; // Start size of particles
vector sStartSize = <0.1,0.1,0.1>; // Start size of particles
float fStartSizeRnd = 0.1; // Start size random
vector vEndSize = <0.0,0.0,0.0>; // End size of particles (if interpSize == TRUE)
vector sEndSize = <0.0,0.0,0.0>; // End size of particles (if interpSize == TRUE)
float fEndSizeRnd = 0.2; // End Size random.
vector vPush = <0,0,4>; // Force pushed on particles
vector sPush = <0,0,4>; // Force pushed on particles
// vector vWind = <0,0,0>; // Force added to push (for simpler editing)

integer iUseRndTexture = 1; // Bool, if == 1, uses random textures in rand func.

string sTexture = "fire_1"; // Texture used if iUseRndTexture == 0

//////////// END PARTICLE PARAMS //////////////////


// System paramaters
float fRate = 0.051; // How fast (rate) to emit particles
float sRate = 0.051; // How fast (rate) to emit particles
float fRateRnd = 0.00; // Random value for rate
float fRadius = 0.01; // Radius to emit particles for BURST pattern
float sRadius = 0.01; // Radius to emit particles for BURST pattern
float fRadiusRnd = 0.01; // Radius random
float fInnerAngle = 0.0; // Inner angle for all ANGLE patterns
float sInnerAngle = 0.0; // Inner angle for all ANGLE patterns
float fInnerAngleRnd = 0.0; // Inner Angle random.
float fOuterAngle = .1; // Outer angle for all ANGLE patterns
float sOuterAngle = .1; // Outer angle for all ANGLE patterns
float fOuterAngleRnd = 0.0; // Outer angle rand
float fLife = 0; // Life in seconds for the system to make particles
float sLife = 0; // Life in seconds for the system to make particles
float fLifeRnd = 0; // Random life rates (yes there is a random for fuckn everything)

integer iCount = 10; // How many particles to emit per BURST
integer sCount = 10; // How many particles to emit per BURST
float fCountRnd = 5; // Random count (rounded)

vector vOmega = <0,0,0.0>; // Rotation of ANGLE patterns around the source
vector sOmega = <0,0,0.0>; // Rotation of ANGLE patterns around the source
float fOmegaRnd = 3; // Random number applied to the omega.


// Script variables
integer flags;

///// Randomize values function ///////
// Changed equations in random function to keep the particles from scaling upwards with every loop P.S.
random()
{
fAge = sAge + llFrand(fAgeRnd);

fMaxSpeed = sMaxSpeed + llFrand(fMaxSpeedRnd);
fMinSpeed = sMinSpeed + llFrand(fMinSpeedRnd);

fStartAlpha = sStartAlpha + llFrand(fStartAlphaRnd);
fEndAlpha = sEndAlpha + llFrand(fEndAlphaRnd);

vStartColor.x = sStartColor.x + llFrand(fStartColorRnd);
vStartColor.y = sStartColor.y + llFrand(fStartColorRnd);
vStartColor.z = sStartColor.z + llFrand(fStartColorRnd);

vEndColor.x = sEndColor.x + llFrand(fEndColorRnd);
vEndColor.y = sEndColor.y + llFrand(fEndColorRnd);
vEndColor.z = sEndColor.z + llFrand(fEndColorRnd);

float o = llFrand(fStartSizeRnd);
vStartSize.x = sStartSize.x + o;
vStartSize.y = sStartSize.y + o;
vStartSize.z = sStartSize.z + o;

float i = llFrand(fEndSizeRnd);
vEndSize.x = sEndSize.x + i;
vEndSize.y = sEndSize.y + i;
vEndSize.z = sEndSize.z + i;

fRate = sRate + llFrand(fRateRnd);
fRadius = sRadius + llFrand(fRadiusRnd);
fInnerAngle = sInnerAngle + llFrand(fInnerAngle);
fOuterAngle = sOuterAngle + llFrand(fOuterAngle);
fLife = sLife + llFrand(fLifeRnd);
iCount = sCount + (integer)llFrand(fCountRnd);

vOmega.x = sOmega.x + llFrand(fOmegaRnd);
vOmega.y = sOmega.y + llFrand(fOmegaRnd);
vOmega.z = sOmega.z + llFrand(fOmegaRnd);



/////// RANDOMIZE TEXTURE ////////////////
if(iUseRndTexture == 1)
{
integer texCount = 2; // number of textures to use. Add to list if more than 2
texCount -= 1;
integer randnum = llRound(llFrand(texCount));

if(randnum == 0)
{
sTexture = "52cf0676-f6f6-0eec-8860-0d545d624be9";
}
if(randnum == 1)
{
sTexture = "6402e6c4-0084-d11d-b2f8-e716a80cae0b";
}

}
///////// END RANDOM TEXTURE /////////////
}

updateParticles()
{
//randomize certain values on each pass
random();
vector scalevec = llGetScale();
float foox = scalevec.x;
float fooy = scalevec.y;
float fooz = scalevec.z;
////// Do not modify below this line //////
flags = 0;
if (kTarget == "owner";) kTarget = llGetOwner();
if (kTarget == "self";) kTarget = llGetKey();
if (iGlow) flags = flags | PSYS_PART_EMISSIVE_MASK;
if (iBounce) flags = flags | PSYS_PART_BOUNCE_MASK;
if (iInterpColor) flags = flags | PSYS_PART_INTERP_COLOR_MASK;
if (iInterpSize) flags = flags | PSYS_PART_INTERP_SCALE_MASK;
if (iWind) flags = flags | PSYS_PART_WIND_MASK;
if (iFollowSource) flags = flags | PSYS_PART_FOLLOW_SRC_MASK;
if (iFollowVel) flags = flags | PSYS_PART_FOLLOW_VELOCITY_MASK;
if (kTarget != "";) flags = flags | PSYS_PART_TARGET_POS_MASK;

llParticleSystem([ PSYS_PART_MAX_AGE,fAge ,
PSYS_PART_FLAGS,flags,
PSYS_PART_START_COLOR,vStartColor,
PSYS_PART_END_COLOR,vEndColor,
PSYS_PART_START_SCALE,vStartSize + <foox, foox, foox>,
PSYS_PART_END_SCALE,vEndSize + <foox, foox, foox>,
PSYS_SRC_PATTERN,iPattern,
PSYS_SRC_BURST_RATE,fRate,
PSYS_SRC_ACCEL,vPush * fooz,
PSYS_SRC_BURST_PART_COUNT,(integer)fooy + iCount,
PSYS_SRC_BURST_RADIUS,fRadius + foox/2,
PSYS_SRC_BURST_SPEED_MIN,fMinSpeed,
PSYS_SRC_BURST_SPEED_MAX,fMaxSpeed,
PSYS_SRC_TARGET_KEY,kTarget,
PSYS_SRC_INNERANGLE,fInnerAngle,
PSYS_SRC_OUTERANGLE,fOuterAngle,
PSYS_SRC_OMEGA, vOmega,
PSYS_SRC_MAX_AGE, fLife,
PSYS_SRC_TEXTURE, sTexture,
PSYS_PART_START_ALPHA, fStartAlpha,
PSYS_PART_END_ALPHA, fEndAlpha
]);
}

default
{
state_entry()
{
id = llGetOwner();
state ParticlesOn;
}
}
state ParticlesOn
{
state_entry()
{
llListen(hchannel,"",id,hmsg);
updateParticles();
llSetTimerEvent(htimer);
}
timer()
{
updateParticles();
}
listen(integer hchannel, string name, key id, string hmsg)
{
if (hmsg == "hellfire off";)
{
state ParticlesOff;
}
}
touch(integer total_number)
{
state ParticlesOff;
}
}
state ParticlesOff
{
state_entry()
{
llListen(hchannel,"",id,hmsg);
}
listen(integer hchannel, string name, key id, string hmsg)
{
if (hmsg == "hellfire on";)
{
state ParticlesOn;
}
}
touch(integer total_number)
{
state ParticlesOn;
}
}
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
08-23-2007 19:49
I posted your code on
http://w-hat.com/lslint/
The first line of the response indicate that the parser finds your code too big. You need to make it smaller or split between different scripts.

From: someone

ERROR:: (230, 1): [E10023] Parser stack depth exceeded; SL will throw a syntax error here.
WARN:: ( 25, 1): [E20009] variable `name' declared but never used.
WARN:: ( 27, 1): [E20009] variable `tag' declared but never used.
WARN:: ( 89, 1): [E20009] variable `sPush' declared but never used.
WARN:: (108, 1): [E20009] variable `fInnerAngleRnd' declared but never used.
WARN:: (111, 1): [E20009] variable `fOuterAngleRnd' declared but never used.
WARN:: (172, 4): [E20011] Condition is always true.
WARN:: (203, 5): [E20011] Condition is always true.
WARN:: (204, 5): [E20012] Condition is always false.
WARN:: (205, 5): [E20011] Condition is always true.
WARN:: (206, 5): [E20011] Condition is always true.
WARN:: (207, 5): [E20012] Condition is always false.
WARN:: (208, 5): [E20012] Condition is always false.
WARN:: (209, 5): [E20011] Condition is always true.
WARN:: (256, 16): [E20001] Declaration of `hchannel' in this scope shadows previous declaration at (23, 1)
WARN:: (256, 33): [E20001] Declaration of `name' in this scope shadows previous declaration at (25, 1)
WARN:: (256, 43): [E20001] Declaration of `id' in this scope shadows previous declaration at (26, 1)
WARN:: (256, 54): [E20001] Declaration of `hmsg' in this scope shadows previous declaration at (24, 1)
WARN:: (274, 16): [E20001] Declaration of `hchannel' in this scope shadows previous declaration at (23, 1)
WARN:: (274, 33): [E20001] Declaration of `name' in this scope shadows previous declaration at (25, 1)
WARN:: (274, 43): [E20001] Declaration of `id' in this scope shadows previous declaration at (26, 1)
WARN:: (274, 54): [E20001] Declaration of `hmsg' in this scope shadows previous declaration at (24, 1)
TOTAL:: Errors: 1 Warnings: 21
Baron Hauptmann
Just Designs / Scripter
Join date: 29 Oct 2005
Posts: 358
08-23-2007 20:17
Also, did you try the syntax checker via the debug menu in LSL-Editor? Did it flag anything? If so, it'll give specific errors and line numbers before you try to copy into SL.
Phoenicis Sands
Registered User
Join date: 16 Apr 2007
Posts: 6
08-24-2007 03:45
Thanks Guys.

I reduced the number of global variables I declare and re-wrote the random function to use the smaller number of variables but have close to the same effect and it now compiles.

Now to stick it into something and see if it works ;P

LSLEditor compiled and ran the script just fine in debug mode, no indication there that it might be to big.


Thanks for the link to w-hat ed44, I've a feeling I'm going to be using that alot.
Debbie Trilling
Our Lady of Peenemünde
Join date: 17 Oct 2006
Posts: 434
08-24-2007 06:36
The "global variables ", "random function ", and "simplify code" are probably red-herrings, imo, as there is nothing particularily "special" or complicated about what the script is attempting to do. I have particle scripts that are far larger in size than this.

Am at work at mo so can not complie, but for a start:

"PSYS_SRC_INNERANGLE" should really be "PSYS_SRC_ANGLE_BEGIN" &
"PSYS_SRC_OUTERANGLE" should really be "PSYS_SRC_ANGLE_END"

See http://lslwiki.net/lslwiki/wakka.php?wakka=llParticleSystem&show_comments=1 for more details

Also suspect something more fundemental is probably going on within your llParticleSystem call too. I'd be tempted to comment it out on a line-by-line basis to try identify the offending line. Once you have located it/them this way, try inserting a hardcoded value, rather than using a variable. This will determine if the variable has been mis-declared or is the wrong type for the particle system constant.

I'llt try have a closer look later today :)
Debbie Trilling
Our Lady of Peenemünde
Join date: 17 Oct 2006
Posts: 434
08-24-2007 13:14
This is a bit of a peculiar one, and I'm not sure I totally understand the reason for problem, tbh. I do have a workaround for you though :)

In summary, the problem is that for some reason the llParticleSystem() does not like the combination of constants that is being passed. The strange thing is though, if you comment out *ANY* three of the llParticleSystem() constants then the script compiles! Even stranger, if you copy/paste the llParticleSystem() call into a new script (and assign values to the constants), the script compiles fully, without need to comment out the three lines.

It gets even more perplexing ~ I ascertained that this problem only occurs when the llParticleSystem() call is made within function updateParticles(); if the llParticleSystem() call is cut/pasted from updateParticles() to default, then it compiles fully.

Perhaps someone else might be able to explain this behavior, because I'm 'fraid I can't!

Regardless, the workaround....

1) Copy all the code currently in updateParticles() & paste it immediately under the first instance of the call to updateParticles() in default
2) Delete this call to updateParticle()
3) Copy all the code currently in updateParticles() & paste it immediately under the second instance of the call to updateParticles() in timer()
4) Delete this call to updateParticle()
5) Delete function updateParticle()
6) Change all instances of "PSYS_SRC_INNERANGLE" to "PSYS_SRC_ANGLE_BEGIN"
7) Change all instances of "PSYS_SRC_OUTERANGLE" to "PSYS_SRC_ANGLE_END"
8) Re-compile

This will do it; not pretty or elegant but workable.

Hope someone can explain this seemingly strange behaviour; probably a v simple reason that I'm missing!

EDIT:
Although the workaround above does work, it has just occured to me that it can be made a little more effcient...

The first call to llParticleSystem() and the attendant code pasted from updateParticles, and now in default, is only there to ensure that a particle stream is created before timer() kicks-in.

However, you have the timer set for 0.2 seconds. As such, this first llParticleSystem call (and attendant code pasted as detailed in 1. above ) is not really needed at all. Might be if timer was set to say, 10, 20 or 30 seconds but, really, not for 0.2 seconds.

As such, in practice, point 1. of the workaround is not really necessary because 0.2 seconds after it the code now pasted into timer() will kick-in (point 3. of the workaround). Sure, it introduces a delay of 0.2 seconds before the particles are generated but hey!
Masakazu Kojima
ケロ
Join date: 23 Apr 2004
Posts: 232
08-24-2007 23:00
See this thread: http://forums.secondlife.com/showthread.php?t=163711#post1398422

Basically, on Windows, the parser stack depth is limited to 150. Because the parser uses right recursion, every global variable and function will be on the stack until the whole globals section can be reduced. This is a common problem with big lists and the easiest fix is obvious once you know what's going on: just split the big list into two. Ex: llParticleSystem([PSYS_PART_FLAGS,...] + [PSYS_SRC_OMEGA, ...]);

Reducing the number of global variables/functions works as well, because it leaves less on the stack, and so does shuffling it into a state rather than a function, because the globals section is completed and reduced to one entry on the stack when the first state is encountered.
Debbie Trilling
Our Lady of Peenemünde
Join date: 17 Oct 2006
Posts: 434
Mystery solved
08-25-2007 00:58
Many thanks, Masakazu, for your explanation and link to the other detailed thread. Quite an eye-opener and something I am glad I am now aware of!
Masakazu Kojima
ケロ
Join date: 23 Apr 2004
Posts: 232
08-25-2007 12:32
Since this has come up a few times now, and my original explanation looks icky with bbcode off, and lslint is supposed to give more helpful error messages instead of more cryptic ones, I went ahead and wrote an article explaining it in detail: http://w-hat.com/stackdepth

I'd appreciate any feedback.
Debbie Trilling
Our Lady of Peenemünde
Join date: 17 Oct 2006
Posts: 434
09-03-2007 01:22
From: Masakazu Kojima
http://w-hat.com/stackdepth

I'd appreciate any feedback.


Very detailed & informative article; quite an eye-opener. Thank you.