LSL 101/Strings and Simple Output
← Comments, White-space and Formatting | ↑̲ LSL 101 ̲↑ | Simplest Output → |
Here's our sample program, with a line added so that the script actually does something.
<lsl> default {
state_entry() { // Let the object's owner know the script is working llOwnerSay( "Congratulations! Your script has started to execute." ); }
} </lsl>
The line that starts with llOwnerSay is a statement that instructs the object containing the script to chat a text message that will only be seen by the object's owner. Since you will usually be scripting objects you own, this will generally be you. This is a convenient way to get information about what your script is doing, without spamming text chat to everyone around you. But if you have an occasion (and permission) to script someone else's object, you would want to use one of the other communication statements, which we'll discuss in due time.
Let's start by looking at the punctuation in this line. Every statement in LSL must end with a semicolon. This is probably the easiest punctuation mark to overlook, but if it isn't there, your script isn't acceptable. Furthermore, the error message you get will probably puzzle you, because it will tell you the error is on the line following the missing semicolon, and it won't tell you that it is a semicolon that is missing. So work especially hard at remembering your semicolons.
The next set of punctuation marks to observe is the pair of double quote marks surrounding the text "Congratulations! Your script has started to execute.". Double quote marks always come in pairs, and they, together with whatever characters come between them, are called a string. Strings can contain any printable characters (although a few require a special trick). The most important use of strings is to display text in SL. The actual content of a string does not have any effect on how your script runs, unless you specifically write code to examine the string and take different actions depending on what the content is.