LSL 101/Creating a Script

From Second Life Wiki
< LSL 101
Revision as of 13:44, 17 May 2009 by Omei Turnbull (talk | contribs) (New page: Category:LSL 101 {{NavNextPrev|prev=The touch_start Event|next=}} We've covered enough of the LSL basics that it makes sense to go ahead and actually create and test a script in SL. ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
← The touch_start Event ↑̲  LSL 101  ̲↑

We've covered enough of the LSL basics that it makes sense to go ahead and actually create and test a script in SL. If you're not there already, log in, go to some place you have permission to build, and create a cube. Go into Edit mode and rename the object to something like First LSL 101 Test, or whatever other naming convention you generally use.

Now left click on the Content Tab, and then on the New Script button inthe Content tab. Two things should happen. The line New Script should appear in the Contents list, and your cube should char the phrase Hello, Avatar!. Before we look at the new script, lets rename "New Script" to something more meaningful, like First LSL 101 Test v0. The v0 at the end is short for version 0. If you've ever built anything in that took more than an hour or so, you've probably learned the wisdom of making periodic backups of your work. With scripting, it is even more important to regularly make a copy of your work and number each copy sequentially. Compared to the backups you make while building objects, you'll probably have more script backups, you'll be going back to older versions of a script more often, and it is generally much harder to distinguish between two scripts that have the same name than two objects that have the same. You can get away without assigning scripts version numbers for very small scripts, but you might as well get in the habit of doing it from the start.

(By the way, if it seems strange to start at version 0 instead of version 1, be warned that programmers, unlike normal people, generally start counting at 0. We'll be seeing a lot of built-in functions that require you to start counting at 0. So it's another thing you might as well get used to from the start.)