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

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

language:start [2017-06-25 05:36 SLT]
sei add navbar
language:start [2018-10-11 10:08 SLT] (current)
sei words -> keywords
Line 1: Line 1:
 $nav $nav
- The following words are reserved keywords in LSL:+ 
 +**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:​ 
 + 
 +<​code>​ 
 +<​globals>​ 
 +<​default_state>​ 
 +<​other_states>​ 
 +</​code>​ 
 + 
 +`<​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 $lkw[state]. It is declared with the keyword $lkw[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 $kw[default],​ you can define them with the keyword $kw[state] followed by the state name, then an open brace symbol ''​{'',​ then one or more event declarations,​ and finally a close brace symbol ''​}''​. See $lkw[state] for more information. 
 + 
 +The shortest script that can be written is: 
 + 
 +<code lsl2> 
 +default{timer(){}} 
 +</​code>​ 
 + 
 +which has a $kw[default] state containing a $ev[timer] event, which will do nothing because the script lacks the code necessary to trigger it. So, this script does nothing at all. 
 + 
 +Spaces and newlines between words or symbols can be used at will, with some exceptions. For example, the above minimalistic,​ do-nothing script can be rewritten in a more readable way, as follows: 
 + 
 +<code lsl2> 
 +default 
 +
 +    timer() 
 +    { 
 +    } 
 +
 +</​code>​ 
 + 
 +Names must start with a letter or underscore ''​_'',​ and may be followed by any sequence of letters, numbers or underscores. For example, ''​_'',​ ''​____'',​ ''​X2392Z'',​ ''​_1st'',​ ''​abracadabra''​ and ''​My_name''​ are all valid names; ''​1st''​ and ''​N#​1''​ are not. Names must not have any spaces in between. 
 + 
 +No spaces can appear between composite symbols that are formed by two symbols, like ''​++''​ or ''>​=''​. In some pathological cases, a space can even change the meaning of an expression; for example, ''​a * --b''​ is not the same as ''​a * - -b''​. 
 + 
 +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:
  
   * $lkw[state]:​ To declare states and change to another state.   * $lkw[state]:​ To declare states and change to another state.
-  * $lkw[default]: The default state.+  * $kw[default]: The default ​$lkw[state],​ which is the state that is entered when a script starts running.
   * $lkw[if]: Check if a condition is true and take different actions depending on the outcome.   * $lkw[if]: Check if a condition is true and take different actions depending on the outcome.
   * $lkw[else]: Optional part of an $kw[if] statement that executes when the condition is false.   * $lkw[else]: Optional part of an $kw[if] statement that executes when the condition is false.
Line 13: Line 55:
   * $lct[TRUE]: Constant for the value 1, treated especially by the compiler.   * $lct[TRUE]: Constant for the value 1, treated especially by the compiler.
   * $lct[FALSE]:​ Constant for the value 0, treated especially by the compiler.   * $lct[FALSE]:​ Constant for the value 0, treated especially by the compiler.
-  * <wrap important>​$lkw[event]</​wrap>:​ Reserved keyword that does nothingDo not use.+  * <wrap important>​$lkw[event]</​wrap>:​ Reserved keyword that is unusedUsing it anywhere except in comments or strings is guaranteed to give a syntax error.
   * <wrap important>​$lkw[print]</​wrap>:​ Obsolete debug message printing method that does nothing. Do not use; use $lfn[llOwnerSay] or similar instead.   * <wrap important>​$lkw[print]</​wrap>:​ Obsolete debug message printing method that does nothing. Do not use; use $lfn[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, 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).+In addition to all these, all [[/​types/​]],​ [[/​events/​]] and [[/​constants/​]] are also reserved ​keywords, 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 $lkw[symbols] allowed. ​ See also a list of the $lkw[symbols] allowed. ​