Jump to content

LSL Noob needs help!


Kenna UwU
 Share

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

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

Recommended Posts

Hi there! I'm really confused and getting a syntax error on line 0 (integer clips;) and 22 (default) and don't know how to fix it. 

 

It's for a multiple WAV music script, if anyone could help that would be fantastic! 

 

integer clips; 
integer toggle = TRUE;
float clip_length = 9.5;//in seconds
float last_clip_length = 5.5;//length of last clip in seconds
integer cycle;

init()
{
    toggle = TRUE;
    llSetTimerEvent(0);
    llSetSoundQueueing(FALSE);
    llStopSound();
    {
    llTargetOmega(<0,0,0>,0.0,0);
     llOwnerSay("Loading Mojave Music Radio Station, please wait.");
    llSetSoundQueueing(TRUE);
    clips = llGetInventoryNumber(INVENTORY_SOUND);
    llPreloadSound(llGetInventoryName(INVENTORY_SOUND,0));
    llSleep(clip_length/2);
    llOwnerSay("Touch to start.");
}

default
{
    state_entry()
    {
        init();
    }
    on_rez(integer param)
    {
        init();
    }

    touch_start(integer total_number)
    {
            
        if(llDetectedKey(0) == llGetOwner()){
            if(toggle){
            toggle = FALSE;
            llOwnerSay("Starting Player");
            llSetSoundQueueing(TRUE);
            
            llPlaySound(llGetInventoryName(INVENTORY_SOUND,0),1);
            llPreloadSound(llGetInventoryName(INVENTORY_SOUND,1));
            cycle = 1;
            }    
            
    }

            llPreloadSound(llGetInventoryName(INVENTORY_SOUND,1));
            cycle = 1;
            llSetTimerEvent(clip_length/2);
            }
            else { 
            toggle = TRUE;
            llSetTimerEvent(0);
            llOwnerSay("Player Stopped");
            llSetSoundQueueing(FALSE);
            llStopSound();
            }
        }
    }
    timer()
    {
            
            
            if(cycle < clips ){
            llPlaySound(llGetInventoryName(INVENTORY_SOUND,cycle),1);
            cycle = cycle + 1;
                if(cycle < clips){
                llSetTimerEvent(clip_length);
                llPreloadSound(llGetInventoryName(INVENTORY_SOUND,cycle));
                }
                else {
                llSetTimerEvent(last_clip_length);
                llPreloadSound(llGetInventoryName(INVENTORY_SOUND,0));
                }
            }
            else {
            llSetTimerEvent(clip_length);
            llPlaySound(llGetInventoryName(INVENTORY_SOUND,0),1);

Link to comment
Share on other sites

I've got another here as well that is completely fine when there's the initial UUID's, and when I remove about 5 of them it gives me a syntax error where there previously weren't any before. This is the script with the syntax errors - 

 

list FRAGMENTS_DOOMER=[
    10.0,
    "0d44197a-f8d4-6860-b200-acf0785b17dd",
    "bf4b24dc-66a5-9f17-6d51-280b59f1e739",
    "acc764d2-f95a-0821-223d-eba8657c05c3",
    "cf374c5a-3ce7-ac5f-8de0-9bdcfdc5782f",
    "8ceb744c-47e2-c113-1153-0eb86082099e",
    "b1475ffe-177f-ab76-f0f8-95c540139123",
    "08988d9e-309c-0186-cb58-32d16af5e7e5",
    "2d89ba72-8c61-7ca9-a7b2-f2c3a9d054b8",
    "19fc4b80-cd5b-3ce8-2a0b-7280211adf67",
    "71a5c296-9966-a0b1-914f-847a0748c766",
    "920bbecb-80c0-013d-1c00-055497ca01d4",
    "6fd5f16b-4af3-9957-50a0-7cacc0b25ecf",
    "5969cf94-1ef5-e2c8-548b-56122b5bfe13",
    "3a594a68-ffed-1006-9af2-0d379cd41a3f", 
      };

float VOLUME=1;
integer PRELOAD_FACTOR=10;

// Global Variables

integer NEXT;
integer INDEX; 
integer COUNT;
list FRAGMENTS;

// Functions

uInit(){
    llStopSound();


uInitPlay(list F){
    FRAGMENTS=F;
    llStopSound();
    COUNT=llGetListLength(FRAGMENTS);
    float TIMER=llList2Float(FRAGMENTS,0);
    uTimer(TIMER);
    INDEX=0;
    uPlay();


uPlay(){
    INDEX++;
    if(INDEX>=COUNT)INDEX=1;
    key FRAGMENT=llList2Key(FRAGMENTS,INDEX);
    llPlaySound(FRAGMENT,VOLUME);
    NEXT=INDEX+1;
    if(NEXT>=COUNT)NEXT=1;
    integer I;
    key NEXT_FRAGMENT=llList2Key(FRAGMENTS,NEXT);
    for(I=0;I<PRELOAD_FACTOR;I++){
        llTriggerSound(NEXT_FRAGMENT,.001);
        llSleep(.05);


uTimer(float TIMER){
    llSetTimerEvent(TIMER);

uTouch(){
    llTriggerSound("17ccd645-c279-08cf-9ce4-504b8897b7b2",.2);
    llSetTimerEvent(0);


uR(){
    llOwnerSay("Click me to play.");
    llResetScript();
}

// Procedure

default{
    state_entry(){
        uInit();
    }
    touch_end(integer T){
        uTouch();
        state doomer;
    }
    on_rez(integer P){
        uR();
    }
}

state doomer{
    state_entry(){
        uInitPlay(FRAGMENTS_DOOMER);
    }
    timer(){
        uPlay();
    }
    touch_end(integer P){
        uTouch();
        state default;
    }
    on_rez(integer P){
        uR();
    }
}

Link to comment
Share on other sites

In general, the compilation error messages you receive in even a basic script editor like the one in your SL viewer should narrow down the possibilities dramatically, especially if you look to see where your cursor is parked when the error is kicked up.  If that's not enough information, your next step should usually be to check for typos.  The most common ones are failure to match parentheses or {curly brackets} or [ square brackets ], failure to type a semi-colon at the end of a statement, typing a dot where you meant a comma (or a semi-colon), and failure to capitalize properly. All of those are maddeningly common errors, frustrating to find, and humiliating to admit.  They are also so easy to anticipate that they should be at the top of your mind as you write scripts.  I know that I am a clumsy typist, so I can almost guarantee that I will have at least one of those errors in any script I write.  Therefore, that's where I look first when my editor tosses me an error message.

  • Like 2
Link to comment
Share on other sites

I'm not too bad with bracketing typos since I adopted the practice of typing the closing bracket immediately after typing the opening one and then backspacing and filling in what goes between them. Especially helpful when you've got functions as parameters to functions. But yeah, those ordinary punctuation marks are a pain.

  • Like 1
Link to comment
Share on other sites

1 hour ago, KT Kingsley said:

I'm not too bad with bracketing typos since I adopted the practice of typing the closing bracket immediately after typing the opening one and then backspacing and filling in what goes between them.

That's an excellent practice.  A smart editor like Sublime Text does that automatically too, and will also highlight matching pairs of brackets/parentheses so that you can see which ones belong together.  The bottom line in all of this is that the truly challenging and interesting parts of scripting take place as you develop a script's logic, so the annoying trivialities that you create by bad typing are more than just a waste of time.  If you're not careful, they can distract you from focusing on logic.

  • Like 2
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1494 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...