LSL 101/A Gentle Introduction
A Gentle Introduction to Scripting in Second Life
This section of LSL 101: The Wikibook is written for the SL user who wants to script the things they build or own but who, perhaps, has no experience of any kind with programming. If that's you, welcome! It will also be of use to people who have experience in other programming languages and would like a gentle introduction to LSL.
Since scripting is one aspect of building, we will assume that you, the reader, have rudimentary building skills. You should, at minimum, be able to create a prim, edit it, take it in and out of your inventory, be able to do the same with a notecard, and know how to put a notecard into a prim's inventory. That's about it. Everything else you'll need, we'll try to cover.
Whenever you want an object in SL to do something, to respond to a mouse click, to greet someone when they come close to it, to change its texture or colour - all the interesting things that objects do, other than just sit there - a script is needed. Scripts take note of things that happen and are able to carry out actions in response.
Scripts in SL are written in LSL (Linden Scripting Language), a simple but powerful programming language, tied closely to the SL environment. (Simple, in this case, is used to mean it is more limited than many other popular programming languages; not necessarily that it is simpler to learn, though it is not very difficult if you are really interested to do so.)
When you learned to speak you discovered that you needed to know not only some words (vocabulary) but also the order in which to use them (grammar). It is the same with computer languages: you have to learn the words and you have to learn the order in which to use them. When you learned to read and write you discovered that there is also punctuation - commas, full stops (periods, if you are American), brackets, etc. - which help to clarify how different words and phrases relate to each other. The difference between computer languages and human languages is that with human languages people can generally understand your meaning even if your pronunciation or spelling is not completely correct or your grammar is slightly wrong. Computer languages are not like that. If your spelling, punctuation or structure is even slightly wrong the computer will report an error or, at best, not do what you expected it to do. This can be very frustrating for beginners.
Preliminaries concluded, lets get started.