Jump to content

Error ??


2toe Bigboots
 Share

You are about to reply to a thread that has been inactive for 4684 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

WHy do i get a syntax error on state clocked ??

 

float cloakSpeed = .1;
 
default

{
    touch_start(integer total_number)
   {
        if(llDetectedKey(llGetOwner()));
    {
        integer x;
        float xf;
        for (x=9; x>=0; x--)
        {
            xf = x * .1;
            llSleep(cloakSpeed);
            llSetAlpha(xf,ALL_SIDES);      
        }
        state cloaked;
    }

state cloaked
{
    touch_start(integer total_number)
    {
        if(llDetectedKey(llGetOwner()));
    }
        integer x;
        float xf;
        for (x=1; x<11; x++)
        {
            xf = x * .1;
            llSleep(cloakSpeed);
            llSetAlpha(xf,ALL_SIDES);  
        }
        state default;
    }
}

 

Link to comment
Share on other sites

Looking at the script a little more I realized it was a complete bracket mess ;)

float cloakSpeed = .1; default{    touch_start(integer total_number)   {        if(llDetectedKey(0))    {        integer x;        float xf;        for (x=9; x>=0; x--)        {            xf = x * .1;            llSleep(cloakSpeed);            llSetAlpha(xf,ALL_SIDES);              }        state cloaked;    }   }}state cloaked{    touch_start(integer total_number)    {        if(llDetectedKey(0)) {        integer x;        float xf;        for (x=1; x<11; x++)        {            xf = x * .1;            llSleep(cloakSpeed);            llSetAlpha(xf,ALL_SIDES);          }        state default;    }}

 

  • Like 1
Link to comment
Share on other sites

Actually, it's not a missing  } .  The OP put a } right after the if statement instead of a { .  This sort of error is very easy to detect if you always write in an external LSL editor that has decent error checking and gives meaningful error messages.

ETA:  Yup, and the missing } at the end of state default, which you got and I overlooked, Darkie.  :smileytongue:

Link to comment
Share on other sites

indents.... should happen with every open brace, and every close brace should see an un-indent, in pretty much every style.

the two most popular bracint styles are 1TBS and Allmans

1TBS:

default{ //-- open brace on the same line as the control structure    state_entry(){        //-- always another indent level after each brace    } //-- closing brace drops back an indent level to the level of it's control structure} //-- you know you've done it right when you close at no indent, every open must have a close

Benefit: less scrolling,  lines always end with a brace or a semicolon (or a line continuation character for banner lines)

Allmans:

default{ //-- open brace on separate new line after the control structure    state_entry()    {        //-- always another indent level after each brace    } //-- closing brace at the same indent level of it's control structure} //-- you know you've done it right when you close at no indent, every open must have a close

 Benefit: more separation of block code makes it quicker to identify and braces are quick to match (unlesss the code scrolls too far)

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4684 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...