LSL 101/Simple Script Skeleton

From Second Life Wiki
Jump to navigation Jump to search

Here is the simplest possible valid LSL script. It doesn't actually ask the computer to do anything but all scripts have, at minimum, this structure:

<lsl> default {

    state_entry() 
    {
    }

} </lsl>

Looking at this, the first thing you might notice is that the ratio of punctuation to words is quite high. This is a general characteristic of LSL. Along with parenthesis and curly braces, there will be lots of semicolons, quotation marks and square brackets, and it all has to be done just right. Fortunately, the rules for using punctuation are much simpler than for a natural language. So even though you are likely to struggle a lot with punctuation at the beginning, that phase won't last long.

In addition to the punctuation, there are two words in this example, "default" and "state_entry". In LSL, the underscore is not punctuation mark, but one of the characters that can be used in names. It's most often used to combine what might be multiple words in English into a single word, since LSL requires every name to be a single word.

(For an alternative possible order of (or maybe philosophy of?) development, see LSL 101/Simple Script Skeleton(A).)