Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Syntax Help

Ruboneout Shoreman
Registered User
Join date: 29 Jul 2009
Posts: 38
01-22-2010 11:48
I'm trying to make a greeter script that is operated by a menu and has 3 different modes. It can either give you a notecard, dialog box, or chat message upon visiting... Here is apart of my code

listen(integer channel, string name, key id, string msg)
{
if(msg == button1)
{
if(notecard == 0)
{
if(dialog == 0)
{
if(say == 0)
{
llOwnerSay("Please select a mode first, then press On.";);
}

else
{
llOwnerSay("on";);
llSensorRepeat("", "", AGENT, 20, TWO_PI, .1);
}
}
}


}

As you can probably see, I am by far nothing special of a scripter, but i represented each mode by 0 = off, and 1 = on. Above, i have it so if every mode is "off" then you will be prompt to set a mode before you are able to turn the sensor on. However, I think my brackets are completely in the wrong places. When i move the brackets around, I can get 1 of the 3 modes working, depending where I put the brackets.. Could someone please direct me in the proper way to handle this.. I never worked with so many if statements within each other before :O. Thank you.
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
01-22-2010 11:56
You need to close off all your if statments BEFORE executing the else

CODE

listen(integer channel, string name, key id, string msg)
{
if(msg == button1)
{
if(notecard == 0)
{
if(dialog == 0)
{
if(say == 0)
{
llOwnerSay("Please select a mode first, then press On.");
}
}
}
}
else
{
llOwnerSay("on");
llSensorRepeat("", "", AGENT, 20, TWO_PI, .1);

}
}
_____________________
My tutes
http://www.youtube.com/johanlaurasia
Ruboneout Shoreman
Registered User
Join date: 29 Jul 2009
Posts: 38
01-22-2010 11:58
Thank you :D
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
01-22-2010 12:07
It's easier to see a problem like that if you're always careful to indent nested blocks of code. When you post scripts here, too, always surround it with
CODE
 ....  
or
CODE
 .... 
tags so that the indents are preserved. (If you can't see them, then hit the "Quote" button on a post.)
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at