Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

getting two actions with one button

Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
12-10-2006 19:10
I don't know why this won't compile. I have studied, done the class and searched. i can do plenty of other stuff but when it comes to code, I become dyslexic.
I want to change alpha and color and texture in one go from a dialog menu.
How do I make the extra things happen?
snippet...
CODE
 

else if (message=="Venetions")
llSetTexture("7acc7adc-f728-47a4-6ed5-40931057a2b5",ALL_SIDES),
llSetColor(<1,1,1>,ALL_SIDES),
llSetAlpha(1.0,ALL_SIDES);
else if (message=="Closed")
llSetAlpha(1.0,ALL_SIDES);
else if (message=="Blue")
llSetColor(<0,0,1>,ALL_SIDES);
else if (message=="White")
llSetColor(<1,1,1>,ALL_SIDES);
else if (message=="Black")
llSetColor(<0,0,0>,ALL_SIDES);
else if (message=="Medium")
[PHP/]
_____________________
SCOPE Homes, Bangu
-----------------------------------------------------------------
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
12-10-2006 19:16
From: Kornscope Komachi
I don't know why this won't compile. I have studied, done the class and searched. i can do plenty of other stuff but when it comes to code, I become dyslexic.
I want to change alpha and color and texture in one go from a dialog menu.
How do I make the extra things happen?
snippet...
CODE
 

else if (message=="Venetions") {
llSetTexture("7acc7adc-f728-47a4-6ed5-40931057a2b5",ALL_SIDES);
llSetColor(<1,1,1>,ALL_SIDES);
llSetAlpha(1.0,ALL_SIDES);
}
else if (message=="Closed")
llSetAlpha(1.0,ALL_SIDES);
else if (message=="Blue")
llSetColor(<0,0,1>,ALL_SIDES);
else if (message=="White")
llSetColor(<1,1,1>,ALL_SIDES);
else if (message=="Black")
llSetColor(<0,0,0>,ALL_SIDES);
else if (message=="Medium")

Blam.
_____________________
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
12-10-2006 21:04
Use lslint for offline code checking:
http://w-hat.com/lslint/
Ultralite Soleil
Registered User
Join date: 31 Aug 2006
Posts: 108
12-11-2006 14:56
From: Kornscope Komachi
I don't know why this won't compile.

Are you getting a strange "Syntax error" message? It's a known bug/limitation in the LSL compiler when there is a long series of if/else statements. Break it up into smaller statements until it compiles.

Example:
CODE


if (message == "Venetions" || message == "Closed" || message == "Blue")
{
if (message=="Venetions") {
llSetTexture("7acc7adc-f728-47a4-6ed5-40931057a2b5",ALL_SIDES);
llSetColor(<1,1,1>,ALL_SIDES);
llSetAlpha(1.0,ALL_SIDES);
}
else if (message=="Closed")
llSetAlpha(1.0,ALL_SIDES);
else if (message=="Blue")
llSetColor(<0,0,1>,ALL_SIDES);
}
else if (message == "White" || message == "Black" || message == "Medium")
{
if (message=="White")
llSetColor(<1,1,1>,ALL_SIDES);
else if (message=="Black")
llSetColor(<0,0,0>,ALL_SIDES);
else if (message=="Medium")
// etc.
}

Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
12-11-2006 15:22
From: Ultralite Soleil
Are you getting a strange "Syntax error" message? It's a known bug/limitation in the LSL compiler when there is a long series of if/else statements. Break it up into smaller statements until it compiles.


No the reason it wouldnt compile was purely syntaxical.
Kornscope had misunderstood how multiple lines are enclosed inbraces to be treated as a single statement.
Vares Solvang
It's all Relative
Join date: 26 Jan 2005
Posts: 2,235
12-11-2006 19:07
Specifically he was using commas in this line instead of semicolons:

CODE

llSetTexture("7acc7adc-f728-47a4-6ed5-40931057a2b5",ALL_SIDES),
llSetColor(<1,1,1>,ALL_SIDES),
llSetAlpha(1.0,ALL_SIDES);



(compare it to the corrected code.)
_____________________
Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
Got it.
12-14-2006 17:27
Thanks all for helping.
Thanks Tyken, I needed braces around the multiple actions. Not sure if "blam" meant, 'go away fool' or 'here it is'. But there it was.

I tried combinations of commas and semi-colons but not braces. I must have missed something and didn't read about it anywhere and just couldn't see it in looking at numerous scripts. But understanding that the braces are the container or bookends for each section but you can have more in between that run in entireity when the script is run.
(Now it seems fundemental.)

Just another question while i'm on it.

Multiple lines, enclosed in braces are to be treated as a single statement. Is there a limit to this?

Can you have more in between those too? You would enclose in braces again?

Also I think the limit to the if-else list is 16?
_____________________
SCOPE Homes, Bangu
-----------------------------------------------------------------