Linden Scripting Language

from Wikipedia, the free encyclopedia

The Linden Scripting Language (or LSL for short ) is an imperative scripting language developed by Linden Lab that is used to control objects in the virtual 3D world of Second Life .

Structure and properties

LSL is an event-driven language that was developed based on finite automata . Each script consists of at least one standard state with the designation default , which also represents the initial state of the machine.

conditions

As with deterministic finite automata, every LSL script has a fixed, finite number of uniquely named states, above all the default state, which represents the initial state and must be present. State changes are carried out with the state statement, which expects the name of the target state as a parameter.

variables

LSL knows local and global variables . Variables can have the following data types:

  • integer : signed 32-bit integers in the value range from −2 31 to 2 31 −1 (i.e. from −2,147,483,648 to +2,147,483,647, or 0x80000000 to 0x7FFFFFFF hexadecimal ).
  • float : 32-bit floating point numbers in IEEE-754 format (i.e. absolute from 1.175494351 · 10 −38 to 3.402823466 10  +38 ).
  • string : character strings. The length of character strings is theoretically unlimited, but in practice is limited by the size of the memory reserved for the program. Since the bytecode, heap and stack share this memory area, the maximum length for character strings - depending on the script - for execution can be as small as desired.
  • key : UUID ( Universally Unique ID ), which represent temporally and spatially unique 16-byte keys in the Second Life universe. They serve to identify objects, avatars, textures, audio files and logical constructs / connections ( HTTP and RPC connections , listeners, ...) and others.
  • vector : triplet of three named float components 'x', 'y' and 'z'; They primarily serve to represent vectors in the naive three-dimensional sense, to represent colors in the RGB color space , and sometimes also as offset and position vectors for aligning textures.
  • rotation : Quaternion as a type for representing complex rotations.
  • list : a type for representing linear lists. LSL lists can be viewed as arrays , i.e. That is, they represent sequences of fixed length n of LSL values ​​whose components are addressed from 0 to n − 1. LSL lists cannot contain any further lists.

Events

In each state, a LSL scripts can events ( events ) are declared. The set of defined events is specified by Linden Lab, such as state_entry () (the script adopts the named state), touch_start (integer num) ('num' avatars have touched the containing object , i.e. clicked it) or http_response (key id , integer status, list metaData, string body) (an HTTP server sent its response).

An instruction block is associated with each event, which is executed when the event occurs and can be freely defined by the programmer. LSL scripts are synchronized in such a way that never more than one event occurs at the same time; this means that no collisions can occur during operations on global variables.

Functions

Linden Lab offers a relatively extensive function library that can be freely used by the programmer. There are both pure functions according to the classical concept (for example llSin (float x) for calculating the sine function ) as well as functions with procedural market statistics (for example llTargetOmega (...), which can be used to start an autarkic object rotation).

It is also possible to define your own functions, which can also be mixed forms of function and procedure and can operate on global variables of the script.

example

Here is the standard sample script from Linden Lab, which corresponds to the usual Hello World program .

 default
 {
    state_entry()
    {
        llSay(0, "Hello, Avatar!");
    }

    touch_start(integer num_detected)
    {
        llSay(0, "Touched.");
    }
 }

LSL and mono

In autumn 2008, Linden Lab began to replace the LSL implementation used up to now with the open source software Mono , which is a .NET-compatible runtime environment and which has resulted in significant runtime improvements. In addition, the memory available for each script quadrupled from 16 KiB to 64 KiB. At about the same time, the mono-based replica of LSL for OpenSimulator , the open source equivalent of Second Life, began.

Web links