Linden Scripting Language
From Wikipedia, the free encyclopedia
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. LSL allows objects to interact with the Second Life world and the Internet (via email, XML-RPC, and most recently, outbound HTTP requests).
Contents |
[edit] LSL design
Linden Scripting Language is a state-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.
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.
There are over 300 library functions 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 structures include integers, floating point numbers, strings, vectors (3D coordinates), and rotations (quaternions). 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 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 KB, which places a practical limit on how much a single script can do.
[edit] Hello World example
A sample Hello World script looks like:
default { state_entry() { llSay(0, "Hello World!"); } }
[edit] LSL's 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 (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 into Second Life is being performed by James Purbick.
[edit] See also
[edit] External links
- LSL forum—Second Life LSL forum
- LSL Wiki—A community effort to supplement the available LSL documentation
- LSL Portal—A new Wiki hosted by Second Life
- Second Life in Mono – Information regarding the move to Mono
- 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