LSL 101/Compile Time Errors

From Second Life Wiki
Jump to navigation Jump to search
← Creating a Script ↑̲  LSL 101  ̲↑

Let's look more closely at what happens when you save a script. If all goes well, you will see the two lines

Compile successful!
Save complete

in the pane below your script. These messages correspond to the two major steps that happen each time you save.

The first step is called compilation. The compiler is a part of SL that reads your script and translates it into a form that can be executed by SL. (Specifically, it is executed by a sim's server.) In order for the compiler to do this translation, your script has to be perfect from a grammatical point of view. If it comes across an error, the compiler will stop and give you an error message. In some cases, you'll see immediately what your mistake is. But the error messages aren't nearly as specific as they might be, so sometimes you'll have to scratch your awhile before you figure out what is wrong. In order to give you a head start, we'll look at some examples here.

Let's start with the basic new script that SL creates. <lsl>

default {

    state_entry()
    {
         // Let the object's owner know the script is working
         llOwnerSay( "Congratulations! Your script has started to execute." );
    }

    touch_start( integer num_detected )
    {
         // Let the object's owner know the script is working
         llOwnerSay( "I've been touched!" );
    }

} </lsl> Suppose that in typing this in, we mistype the first comment by using \\ instead of //.