Unofficial LSL Reference

[[language:start]]


Unofficial LSL reference

User Tools

Login

You are currently not logged in! Enter your authentication credentials below to log in. You need to have cookies enabled to log in.

Login

Forgotten your password? Get a new one: Set new password

This is an old revision of the document!


NOTE: This is not a LSL tutorial. It's a reference guide about the structure of the language.

A script must adhere to the following structure:

<globals>
<default_state>
<other_states>

<globals> are zero or more global declarations. Each global declaration is either a variable declaration or a user-defined function declaration.

<default_state> is a state. It is declared with the keyword default followed by an open brace symbol {, then one or more event declarations, and finally a close brace symbol }. This state is mandatory.

<other_states> are zero or more states. If you need more states than default, you can define them with the keyword state followed by the state name, then an open brace symbol {, then one or more event declarations, and finally a close brace symbol }. See state for more information.

Any names can be used for variables, functions, function parameters, states or labels that you define, except for a few that can't because they have special meanings for the language. Those which have special meanings are called reserved keywords.

The following words are reserved keywords in LSL:

  • state: To declare states and change to another state.
  • default: The default state, which is the state that is entered when a script starts running.
  • if: Check if a condition is true and take different actions depending on the outcome.
  • else: Optional part of an if statement that executes when the condition is false.
  • while: Loop while a condition is true, or don't execute the loop statements at all if the condition is false.
  • do: Loop while a condition is true; the loop executes at least once.
  • for: Loop while a condition is true, executing an expression at start and another one while looping.
  • return: Return from an event or user function, possibly returning a value.
  • jump: Jump to another location within the current function.
  • TRUE: Constant for the value 1, treated especially by the compiler.
  • FALSE: Constant for the value 0, treated especially by the compiler.
  • event: Reserved keyword that is unused. Using it anywhere except in comments or strings is guaranteed to give a syntax error.
  • print: Obsolete debug message printing method that does nothing. Do not use; use llOwnerSay or similar instead.

In addition to all these, all types, events and constants are also reserved words, meaning you can't use them as names for your own variables, labels, states, parameters or functions. The library functions are not reserved words (you can't define a function with a name of a library function, because they are in the global namespace, but you can use the same name for your own variables or parameters — not that you would want to, though).

See also a list of the symbols allowed.