#redirect [[Second Life#Content]]
'''Linden Scripting Language''', or LSL, is the programming language used by residents of ''[[Second Life]]'', a [[virtual world]] by [[Linden Lab]]. LSL scripts can control the behavior of in-world objects. LSL has a syntax similar to [[C (programming language)|C]]. LSL allows objects to interact with the [[Second Life]] world and the Internet (via email, [[XML-RPC]], and most recently, outbound [[HTTP]] requests).
{{Rwh}}
==LSL Design==
{{R to section}}
Linden Scripting Language is a state-[[Event-driven programming|event driven]] scripting language, in the sense of a [[finite state machine]].
A script consists of variables, function definitions, and one or more named states. Each state contains a description of how to react to events which occur while the program is within that state. The system sends events to the script, such as timers, movement, chat (from other agents), email, and collisions (with objects in the virtual world). Scripts can change most aspects of the state of the object and communicate with other objects and agents. As soon as a script is added to an object, it begins to execute.
[[Category:Mono project applications]] ▼
A script is tightly bound to the concept of ''object'' (not in the object-oriented sense). An object in SL represents something like a chair or a wall, or possibly something invisible. Zero or more scripts can be placed inside an object, where they all execute simultaneously.
[[Category: ProgrammingScripting languages]] ▼
There are over 300 library [[function (programming)|function]]s available. Users can also define additional functions. LSL is a [[strongly typed language]] that is compiled to [[bytecode]] before runtime execution in a [[virtual machine]] on one of Linden Lab's servers.
LSL's native [[data structure]]s include [[integers]], [[floating point numbers]], [[strings]], [[vectors]] (3D coordinates), and [[rotation]]s ([[quaternion]]s). There are also heterogeneous lists. There is no built-in persistent data storage, such as a file or database. On the other hand, scripts continue to run even when a user is not logged in, and if an object is saved (taken into inventory), and then re-introduced into the world later, it still maintains its state. In addition, the mechanisms for communicating via HTTP can be used to store state externally.
Some functions in LSL have built-in delays, which range from a 0.2-second delay when moving a non-physical object to a 20-second pause when sending an [[email|e-mail message]]. The delays help prevent developers from writing LSL scripts that could overtax system resources. Memory available to LSL scripts is capped at about 16 [[Kilobyte|KB]], which places a practical limit on how much a single script can do.
==Hello World Example==
A sample [[Hello World]] script looks like:
<span style='color:darkblue'>default</span>
<span style='color:green'>{</span>
<span style='color:darkred'>state_entry</span><span style='color:green'>()</span>
<span style='color:green'>{</span>
<span style='color:darkred'>llSay</span><span style='color:green'>(</span><span style='color:darkorange'>0</span>, "<span style='color:darkorange'>Hello World!</span>"<span style='color:green'>)</span>;
<span style='color:green'>}</span>
<span style='color:green'>}</span>
==LSL Future==
Second Life's revised version of its scripting system was originally scheduled for release in the first quarter of 2006, but has been pushed back indefinitely. Linden Lab is still moving forward, however, as evidenced by demonstrations presented at Microsoft, available for download from microsoft.com. The new engine executing scripts uses [[Mono (software)|Mono]] (the open source implementation of the Microsoft .NET framework) as the virtual machine for scripts running on the servers.
The LSL scripting language remains the same, but executing on the Mono underpinnings gives a 50 to 150 times speed increase. An additional benefit of this change is that any language that compiles to the Mono [[virtual machine]] can potentially be uploaded to execute in ''Second Life.''
The integration of [[Mono (software)|Mono]] into second life is being performed by [[James Purbick]]
==External links and references==
* [http://www.secondlife.com/ Second Life] Second Life website
* [http://forums.secondlife.com/forumdisplay.php?f=54 LSL forum] Second Life LSL forum
* [http://lindenlab.com/ Linden Lab] official website
* [http://lslwiki.org/ LSL Wiki], a community effort to supplement the available [[Linden Scripting Language|LSL]] documentation
* [http://blog.secondlife.com/2005/08/01/second-life-in-mono/ Second Life in Mono] Information regarding the move to Mono
* [http://blog.secondlife.com/2006/09/14/langnet-symposium-videos/ Lang.NET Symposium Videos] Official Linden Blog post regarding the video presentation made by [[James Purbrick]] and [[Cory Ondrejka]] at the 2006 Lang.NET Symposium
▲[[Category:Programming languages]]
[[Category:Second Life]]
▲[[Category:Mono project applications]]
[[pt:LSL]]
|