Jump to content
You are about to reply to a thread that has been inactive for 143 days.

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

Recommended Posts

Posted

When I try to use this script in sl, i get a syntax error on line 61, 0. Ive tried changing the brackets and semicolon. but i am still getting same error. 

 

I would appreciate any advice;

Thank you in advance

Sam

 

// Script to play 30 ten-second clips of "Kumosta Aking Mahal"
// Smooth and fluid, loop indefinitely
// Volume set to maximum, echo sound forward

integer playing = FALSE;
integer clipIndex = 0;
list clips = [
    "Kumosta Aking Mahal 1",
    "Kumosta Aking Mahal 2",
    "Kumosta Aking Mahal 3",
    "Kumosta Aking Mahal 4",
    "Kumosta Aking Mahal 5",
    "Kumosta Aking Mahal 6",
    "Kumosta Aking Mahal 7",
    "Kumosta Aking Mahal 8",
    "Kumosta Aking Mahal 9",
    "Kumosta Aking Mahal 10",
    "Kumosta Aking Mahal 11",
    "Kumosta Aking Mahal 12",
    "Kumosta Aking Mahal 13",
    "Kumosta Aking Mahal 14",
    "Kumosta Aking Mahal 15",
    "Kumosta Aking Mahal 16",
    "Kumosta Aking Mahal 17",
    "Kumosta Aking Mahal 18",
    "Kumosta Aking Mahal 19",
    "Kumosta Aking Mahal 20",
    "Kumosta Aking Mahal 21",
    "Kumosta Aking Mahal 22",
    "Kumosta Aking Mahal 23",
    "Kumosta Aking Mahal 24",
    "Kumosta Aking Mahal 25",
    "Kumosta Aking Mahal 26",
    "Kumosta Aking Mahal 27",
    "Kumosta Aking Mahal 28",
    "Kumosta Aking Mahal 29",
    "Kumosta Aking Mahal 30"
];

default {
    state_entry() {
        llSetTimerEvent(0.1); // Ensure the timer event is set correctly
    }

    touch_start(integer total_number) {
        if (playing) {
            llStopSound();
            playing = FALSE;
        } else {
            playing = TRUE;
            playNextClip();
        }
    }

    timer() {
        if (playing) {
            playNextClip();
        }
    }
}

playNextClip() {
    if (playing) {
        llPlaySound(llList2String(clips, clipIndex), 1.0);
        llSleep(10.0);
        clipIndex = (clipIndex + 1) % llGetListLength(clips);
        llSetTimerEvent(0.1); // Fix for syntax error at (61,0)
    }
}
 

Posted (edited)

Ah, well, I'm going to guess that your line 61 is at the start of the final block that starts with playNextClip.  That whole block (except for the very final } bracket) is a user-defined function.  It belongs at the TOP of the script, not inside the body of it.

EDIT:  Yeah, what Wulfie said... :)

Edited by Rolig Loon
  • Like 2
Posted

could you please clarify, i am not sure what that means exactly. do i move line 61 above default? or everything 61 and below?

 

I apologize, I am not familiar with scripting much

 

Posted

As I said,

3 minutes ago, Rolig Loon said:

That whole block (except for the very final } bracket) is a user-defined function.  It belongs at the TOP of the script, not inside the body of it.

from the line that says playNextClip() { ... everything except the very last } bracket.

Posted

I moved that whole thing above the default, but now the syntax error moved to the default line. syntax error now at 45,1

 

// Script to play 30 ten-second clips of "Kumosta Aking Mahal"
// Smooth and fluid, loop indefinitely
// Volume set to maximum, echo sound forward

integer playing = FALSE;
integer clipIndex = 0;
list clips = [
    "Kumosta Aking Mahal 1",
    "Kumosta Aking Mahal 2",
    "Kumosta Aking Mahal 3",
    "Kumosta Aking Mahal 4",
    "Kumosta Aking Mahal 5",
    "Kumosta Aking Mahal 6",
    "Kumosta Aking Mahal 7",
    "Kumosta Aking Mahal 8",
    "Kumosta Aking Mahal 9",
    "Kumosta Aking Mahal 10",
    "Kumosta Aking Mahal 11",
    "Kumosta Aking Mahal 12",
    "Kumosta Aking Mahal 13",
    "Kumosta Aking Mahal 14",
    "Kumosta Aking Mahal 15",
    "Kumosta Aking Mahal 16",
    "Kumosta Aking Mahal 17",
    "Kumosta Aking Mahal 18",
    "Kumosta Aking Mahal 19",
    "Kumosta Aking Mahal 20",
    "Kumosta Aking Mahal 21",
    "Kumosta Aking Mahal 22",
    "Kumosta Aking Mahal 23",
    "Kumosta Aking Mahal 24",
    "Kumosta Aking Mahal 25",
    "Kumosta Aking Mahal 26",
    "Kumosta Aking Mahal 27",
    "Kumosta Aking Mahal 28",
    "Kumosta Aking Mahal 29",
    "Kumosta Aking Mahal 30"
];
playNextClip() {
    if (playing) {
        llPlaySound(llList2String(clips, clipIndex), 1.0);
        llSleep(10.0);
        clipIndex = (clipIndex + 1) % llGetListLength(clips);
        llSetTimerEvent(0.1); // Fix for syntax error at (61,0)
    }
default {
    state_entry() {
        llSetTimerEvent(0.1); // Ensure the timer event is set correctly
    }

    touch_start(integer total_number) {
        if (playing) {
            llStopSound();
            playing = FALSE;
        } else {
            playing = TRUE;
            playNextClip();
        }
    }

    timer() {
        if (playing) {
            playNextClip();
        }
    }
}


}
 

 

Posted

OK, the problem is that your script, as posted, is hard to read.  I had to reformat it to make it look right.  That very last } bracket should have moved up too:

integer playing = FALSE;
integer clipIndex = 0;
list clips = [
    "Kumosta Aking Mahal 1",
    "Kumosta Aking Mahal 2",
    "Kumosta Aking Mahal 3",
    "Kumosta Aking Mahal 4",
    "Kumosta Aking Mahal 5",
    "Kumosta Aking Mahal 6",
    "Kumosta Aking Mahal 7",
    "Kumosta Aking Mahal 8",
    "Kumosta Aking Mahal 9",
    "Kumosta Aking Mahal 10",
    "Kumosta Aking Mahal 11",
    "Kumosta Aking Mahal 12",
    "Kumosta Aking Mahal 13",
    "Kumosta Aking Mahal 14",
    "Kumosta Aking Mahal 15",
    "Kumosta Aking Mahal 16",
    "Kumosta Aking Mahal 17",
    "Kumosta Aking Mahal 18",
    "Kumosta Aking Mahal 19",
    "Kumosta Aking Mahal 20",
    "Kumosta Aking Mahal 21",
    "Kumosta Aking Mahal 22",
    "Kumosta Aking Mahal 23",
    "Kumosta Aking Mahal 24",
    "Kumosta Aking Mahal 25",
    "Kumosta Aking Mahal 26",
    "Kumosta Aking Mahal 27",
    "Kumosta Aking Mahal 28",
    "Kumosta Aking Mahal 29",
    "Kumosta Aking Mahal 30"
];
playNextClip() {
    if (playing) {
        llPlaySound(llList2String(clips, clipIndex), 1.0);
        llSleep(10.0);
        clipIndex = (clipIndex + 1) % llGetListLength(clips);
        llSetTimerEvent(0.1); // Fix for syntax error at (61,0)
    }
}

default {
    state_entry() {
        llSetTimerEvent(0.1); // Ensure the timer event is set correctly
    }

    touch_start(integer total_number) {
        if (playing) {
            llStopSound();
            playing = FALSE;
        } else {
            playing = TRUE;
            playNextClip();
        }
    }

    timer() {
        if (playing) {
            playNextClip();
        }
    }
}

 

  • Like 1
Posted (edited)

@Shuuichii  For reference scripts usually use the following structure...

Quote

// Example Script

// Variable Definitions
integer a = 0;
float b = 0.0;
string c = "zero";

// Function Definitions

doStuff()
{
    // code that does stuff
}

doOtherStuff()
{
    // code that does other stuff
}

// Main Script Body/Default State

default {
    state_entry() {
        doStuff(); // Does stuff
    }

    touch_start(integer total_number) {
        doOtherStuff(); // Does other stuff
    }
}

You almost have it right but you missed the closing curly bracket when copying the function from the end of the script.

Delete the last } in your script and add a } before the line that says default {

Edited by Fluffy Sharkfin
  • Like 2
Posted

Thank You to all of you, You have all been a great help and i appreciate it greatly, it is working now. 

 

Really Helpful 

 

Thank You again

 

Sam

  • Like 2
Posted

Glad the problem got solved but reading the script raised a formatting question for me.

When I was at university we were taught to make brackets line up vertically, i.e. the closing bracket was level  with the opening bracket to aid bracket checking. When I worked in the industry, that was the standard my employer laid down too.

Reading scripts many years later, I find I am in a, possibly small, minority.

When did the change take hold and what are the arguments for it?

Posted (edited)
1 hour ago, LissomePrey said:

When did the change take hold and what are the arguments for it?

https://en.wikipedia.org/wiki/Indentation_style

It's not everywhere all at once, there are still different proponents of different styles. For LSL, I usually see allman style promoted the most, except from people who came from 'industry' and are used to the style your code above uses.

Edited by Quistess Alpha
Posted

There are no formatting standards in SL, and hence there has been no change. This is not a company shop.  We are all independent scripters, doing whatever works. 

I generally tend to follow the model you are familiar with myself, but when I grabbed the OP's script and dropped it into Sublime Text (the editor I prefer, other than the in-house editor in the viewer), the brackets did not line up by default.  I suspect that's because the OP's script used a significantly different model and Sublime Text wasn't quite sure what to do with it, other than try to be internally consistent.  As long as I am in Sublime Text, it really doesn't make any difference how a script is formatted, however, because the editor automatically highlights matching brackets so you can see how they are paired.

Posted (edited)

I wasn't suggesting there should be a standard. More that before my long hiatus from coding there seemed to be one standard and now there seems to be another. I accept happily we all code differently.

 

Now reading Quistess's link :) I guess I was taught Allman.

Edited by LissomePrey
  • Like 1
You are about to reply to a thread that has been inactive for 143 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
×
×
  • Create New...