What is this?

The below is a document that was included with the Second Life client and is kept here for historical documentation. For a more accurate and updated LSL reference see http://lslwiki.net.

 

 

Linden Scripting Language Reference


Table of Contents

Introduction. 9

Overview.. 9

Design Goals of LSL. 9

Description. 9

Example – door.lsl 10

User’s Manual 12

Overview.. 12

Program Structure. 12

Variables. 13

States and Event Handlers. 13

Comments. 14

Types. 14

Arithmetic Operations. 15

Type Conversion. 16

Implicit Type Casting. 16

Explicit Type Casting. 16

Loop Constructs. 16

for 16

do-while. 17

while. 17

Conditional Statements. 17

if 17

if-else. 17

Jumps. 18

Example Code. 18

New Firework Script 18

Gambling Script 19

The Cannon Scripts. 20

Reference Manual 22

Events. 22

state_entry() 23

state_exit() 23

touch_start(integer total_number) 23

touch(integer total_number) 23

touch_end(integer total_number) 23

collision_start(integer total_number) 23

collision(integer total_number) 23

collision_end(integer total_number) 23

land_collision_start(vector position) 24

land_collision(vector position) 24

land_collision_end(vector position) 24

timer() 24

listen(integer channel, string name, key id, string message) 24

sensor(integer total_number) 24

no_sensor() 24

control(key name, integer levels, integer edges) 24

at_target(integer number, vector targetpos, vector ourpos) 24

not_at_target() 25

at_rot_target(integer number, rotation targetrot, rotation ourrot) 25

not_at_rot_target() 25

money(key giver, integer amount) 25

email(string time, string address, string subject, string body, integer remaining) 25

run_time_permissions(integer permissions) 25

changed(integer changed) 25

attach(key attached) 25

moving_start() 25

moving_end() 26

on_rez(integer start_param) 26

link_message(integer sender_num, integer num, string str, key id) 26

object_rez(key id) 26

dataserver(key requested, string data) 26

Arithmetic Operations. 26

Assignment and Comparison. 26

Integer Arithmetic. 26

Integer Constants. 26

Float Arithmetic. 28

Floating Point Constants. 29

Vector Arithmetic. 29

Rotation Arithmetic. 29

String Arithmetic. 29

Key Constant 29

Library Function Calls. 29

llSin. 29

llCos. 29

llTan. 29

llAtan2. 30

llSqrt 30

llPow.. 30

llAbs. 30

llFabs. 30

llFrand. 30

llFloor 30

llCeil 30

llRound. 31

llVecMag. 31

llVecNorm.. 31

llVecDist 31

llRot2Euler 31

llEuler2Rot 31

llAxes2Rot 31

llRot2Fwd. 31

llRot2Left 31

llRot2Up. 32

llRotBetween. 32

llWhisper 32

llSay. 32

llShout 32

llListen. 32

llListenControl 33

llListenRemove. 33

llSensor 33

llSensorRepeat 33

llSensorRemove. 33

llDetectedName. 33

llDetectedKey. 33

llDetectedOwner 34

llDetectedPos. 34

llDetectedVel 34

llDetectedGrab. 34

llDetectedRot 34

llDetectedLinkNumber 35

llDie. 35

llGround. 35

llCloud. 35

llWind. 35

llSetStatus. 35

llGetStatus. 35

llSetScale. 35

llGetScale. 36

llSetColor 36

llGetColor 36

llSetAlpha. 36

llGetAlpha. 36

llSetTexture. 36

llGetTexture. 36

llScaleTexture. 36

llOffsetTexture. 37

llRotateTexture. 37

llSetTextureAnim.. 37

llSetPos. 38

llGetPos. 38

llGetLocalPos. 38

llSetRot 38

llGetRot 38

llGetLocalRot 38

llSetText 38

llSetForce. 39

llGetForce. 39

llTarget 39

llTargetRemove. 39

llRotTarget 39

llRotTargetRemove. 39

llMoveToTarget 39

llStopMoveToTarget 39

llApplyImpulse. 40

llApplyRotationalImpulse. 40

llSetTorque. 40

llGetTorque. 40

llSetForceAndTorque. 40

llGetVel 40

llGetAccel 40

llGetOmega. 40

llGetTimeOfDay. 41

llGetWallclock. 41

llGetTime. 41

llResetTime. 41

llGetAndResetTime. 41

llPlaySound. 41

llLoopSound. 41

llTriggerSound. 42

llTriggerSoundLimited. 42

llStopSound. 42

llPreloadSound. 42

llAdjustSoundVolume. 42

llSetSoundQueueing. 43

llLoopSoundMaster 43

llLoopSoundSlave. 43

llPlaySoundSlave. 43

llGetSubString. 43

llDeleteSubString. 44

llInsertString. 44

llToUpper 44

llToLower 44

llStringLength. 44

llGiveMoney. 44

llMakeExplosion. 45

llMakeFountain. 45

llMakeSmoke. 45

llMakeFire. 45

llRezObject 45

llSetTimerEvent 45

llSleep. 45

llLookAt 45

llRotLookAt 46

llStopLookAt 46

llCollisionFilter 46

llTakeControls. 46

llReleaseControls. 46

llAttachToAvatar 46

llDetachFromAvatar 46

llGetOwner 47

llInstantMessage. 47

llEmail 47

llGetNextEmail 47

llGetKey. 47

llSetBuoyancy. 47

llSetHoverHeight 47

llStopHover 47

llMinEventDelay. 48

llStartAnimation. 48

llStopAnimation. 50

llPointAt 50

llStopPointAt 50

llTargetOmega. 51

llGetStartParameter 51

llRequestPermissions. 51

llGetPermissionsKey. 51

llGetPermissions. 51

llGetLinkNumber 51

llSetLinkColor 51

llCreateLink. 52

llBreakLink. 52

llBreakAllLinks. 52

llGetLinkKey. 52

llGetLinkName. 52

llGetInventoryNumber 52

llGetInventoryName. 52

llGiveInventory. 53

llRemoveInventory. 53

llSetScriptState. 53

llGetEnergy. 53

llSetText 53

llSetText 53

llPassTouches. 53

llPassCollisions. 54

llRequestAgentData. 54

llRequestInventoryData. 54

llSetDamage. 54

llTeleportAgentHome. 54

llModifyLand. 54

llCollisionSound. 54

llCollisionSprite. 55

llGetAnimation. 55

llResetScript 55

llMessageLinked. 55

llPushObject 55

llPassCollisions. 55

llGetScriptName. 55

llGetNumberOfSides. 55

llAxisAngle2Rot 56

llRot2Axis. 56

llRot2Angle. 56

llAcos. 56

llAsin. 56

llAngleBetween. 56

llGetInventoryKey. 56

llAllowInventoryDrop. 56

llGetSunDirection. 56

llGetTextureOffset 57

llGetTextureScale. 57

llGetTextureRot 57

llSubStringIndex. 57

llGetOwnerKey. 57

llGetCenterOfMass. 57

llListSort 57

llGetListLength. 57

llList2Integer 58

llList2Float 58

llList2String. 58

llList2Key. 58

llList2Vector 58

llList2Rot 58

llList2List 58

llDeleteSubList 58

llGetListEntryType. 59

llList2CSV.. 59

llCSV2List 59

llListRandomize. 59

llList2ListStrided. 59

llListInsertList 59

llListFindList 59

llGetObjectName. 60

llSetObjectName. 60

llGetDate. 60

llEdgeOfWorld. 60

llGetAgentInfo. 60

llKey2Name. 60

llEjectFromLand. 60

llParseString2List 60

llOverMyLand. 61

llGetLandOwnerAt 61

llGetNotecardLine. 61

llGetAgentSize. 61

llSameGroup. 61

llUnSit 61

llGroundSlope. 61

llGroundNormal 62

llGroundContour 62



Introduction

Overview

This document is broken down into three major sections: Introduction, User’s Manual, and Reference Manual.  The Introduction provides a high level review of the Linden Scripting Language (LSL) and how it is used within Linden World.  The User’s Manual provides a more detailed review of the syntax and functionality of LSL and provides sample code.  The Reference Manual provides detailed information on the underlying code and data structures, byte code format, and execution model.  This document assumes that the reader has a working knowledge of programming and is familiar with a high level language like Java or C.

Design Goals of LSL

LSL was designed with the following goals in mind:

 

·Provide a robust method for users to add behavior to objects in Linden World

·Provide a simple interface to exchange scripts and to modify tuning values

·Provide a powerful language for advanced users

·Ensure that user scripts cannot crash a simulator or greatly reduce simulator performance

Description

LSL is a Java-like language incorporating several extensions.  It sticks to the well known C/Java syntactic style, but allows tuning variables to be exposed via a GUI to allow users with no programming knowledge to modify scripts.  Much like faces or textures, this will allow an economy to evolve around well written scripts.

 

Multiple scripts may also be attached to the same object, allowing a style of small, single-function scripts to evolve.  This leads to scripts that perform specific functions (“hover”, “follow”, etc.) and allows them to be combined to form new behaviors.

 

The text of the script is compiled into an executable byte code, much like Java.  This byte code is then run within a virtual machine on the simulator.  Each script receives a time slice of the total simulator time allocated to scripts, so a simulator with many scripts would allow each individual script less time rather than degrading its own performance.  In addition, each script executes within its own chunk of memory, preventing scripts from writing into protected simulator memory or into other scripts, making it much harder for scripts to crash the simulator.

Example – door.lsl

The following LSL code opens a door when the user speaks the magic word.  It handles the concepts of user chats, exposure of global tuning variables, and calls library functions.

 

// exposed global variables accessible via GUI

 

// the phrase the user will use

string  gMagicPhrase = "Shazamm!";

 

// how fast the door opens

float gOpenTime = 1.0;

 

// global variables that aren’t exposed

integer gSteps = 20;                                 // the door moves through 20 steps

vector  gOffset = <0.0, 0.0, 0.10>;           // 2 meters of total motion

 

// states the script can be in

 

// all scripts start in the default state

default

{

    // setup to listen only for magic phrase

    state_entry()

    {

        llSay(0, "To open me, say " + gMagicPhrase);

        // listen on chat channel 0 for the magic phrase from anyone

        llListen(0, "", "", gMagicPhrase); 

    }

   

    // handle chat messages that we’re listening for

    listen(integer channel, string name, key id, string message)

    {

        integer i;

 

        vector basepos = llGetPos();

   

        // loop through the steps, adjusting the door

        for (i = 0; i < gSteps; i++)

        {

            // set the object's position

            llSetPos(basepos +  i*gOffset);

            llSleep(0.1);

        }

 

        // now, flip the offset vector to move us back down

        gOffset *= -1;

    }

}

 

The key elements of this example are:

 

·The default state.  All scripts must have a default state, which is the state that scripts start out in.

·The state_entry and chat event handlers.  LSL uses an event execution model, meaning that events cause specific pieces of code to execute.  In this script, the state_entry event is executed at script start when we enter the default state.

·Library function calls.  Any function that begins with “ll” is a library function call.  In this example, llListen tells the script to listen for the magic words.  If those words are heard, the chat event is executed.

·The overall syntax (bracing and keywords) is very similar to Java/C.
User’s Manual

Overview

LSL is loosely based on Java/C syntax with significant changes as detailed below. 

Program Structure

Below is an example LSL script:

 

// global variable that isn’t exposed

vector gStartPosition;

 

// global functions that can be called from any state

make_physical_and_spin(vector torque)

{

    // double the torque because we want to

    vector double_torque = 2.0*torque;

    llSetTorque(double_torque, FALSE);

}

 

// state sections

// default state – all scripts must have a default state

 

default

{

    // when a state is transitioned to, the state_entry event is raised

    state_entry()

    {

        //  Make physical so it can move

        llSetStatus(STATUS_PHYSICS, TRUE);

        // get the base stating position

        gStartPosition = llGetPos();

        //  Move to 2 meters above the start position

        gStartPosition.z += 2.0;

        llMoveToTarget(gStartPosition, 0.5);

        // transition to spin state

        state SpinState;

    }

 

    // when a state is transitioned out of, the state_exit event is raised

    state_exit()

    {

        // set critical damping to keep us on our stating location, with time constant of 0.5 seconds

        llMoveToTarget(gStartPosition, 0.5);

    }

}

 

 

// SpinState is a user defined state

state SpinState

{

    state_entry()

    {

        // say hello on channel 0

        llSay(0, "Starting to spin");

        // call global function

        make_physical_and_spin(<0.1, 0.1, 0.0>);

    }

}

 

The LSL file is broken up as follows:

Variables

LSL variables are case sensitive, made up of letters, numbers, and underscores, and must start with a letter or underscore.

Global Variables and Functions

Global variables and functions are accessible from anywhere in the file.  Global variables are declared much like Java or C, although only one declaration may be made per line:

 

vector gStartPosition;

 

Global variables may also be initialized if desired, although uninitialized global and local variables are initialized to legal zero values:

 

vector gStartPosition = <10.0,10.0,10.0>;

 

Global functions are also declared much like Java/C, with the exception that no “void” return value exists.  Instead, if no return value is needed, just don’t specify one:

 

make_physical_and_spin(vector torque)

{

    // double the torque because we want to

    vector double_torque = 2.0*torque;

    llSetState(STATUS_PHYSICS, TRUE);

    llApplyTorque(double _torque);

}

Local Variables

Local variables are scoped below their declaration within the block of code they are declared in and may be declared within any block of code.  Thus the following code is legal and will work like C:

 

Integer test_function()

{

    // Test vector that we can use anywhere in the function

    vector test = <1,2,3>;

    integer j;

    for (j = 0; j < 10; j++)

    {

        // This vector is a different variable than the one declared above

        // This IS NOT good coding practice

        vector test = <j, j, j>;

    }

    // this test fails

    if (test == <9,9,9>)

    {

        // never reached

    }

}

States and Event Handlers

All scripts must have a default state, which is the state the script starts in.  States contain event handlers that are triggered by the LSL virtual machine.  States must have at least one event handler, but can choose which handlers to use.  Some handlers, like listen, require that the script call a library function to setup information that determines when the event happens.

 

The example code sets the global variable gStartPosition within the state_entry event handler, which is set when the script begins execution.

 

default

{

    // when a state is transitioned to, the state_entry event is raised

    state_entry()

    {

        // get the base stating position

        gStartPosition = llGetPos();

        // transition to spin state

        state SpinState;

    }

 

    // when a state is transitioned out of, the state_exit event is raised

    state_exit()

    {

        // set critical damping to keep us on our stating location, with time constant of 0.5 seconds

        llMoveToTarget(gStartPosition, 0.5);

    }

}

 

The command state SpinState changes the state to the SpinState state and raises the state_exit event, causing that handler to be called.

 

The user state SpinState works like the default state.

 

state SpinState

{

    state_entry()

    {

        // say hello on channel 0

        llSay(0, gHello);

        // call global function

        make_physical_and_spin(<10.0, 10.0, 0.0>);

    }

}

Comments

LSL uses Java/C++ style single line comments:

 

// Name and Description

Types

LSL supports the following basic types:

·integer

Signed, 32-bit integer value

·float

32-bit floating point value

·string

A sequence of characters

“\” functions as an escape character, so use “\n” to enter a carriage return into a string, “\t” to enter a 4 space tab, “\\” to enter a backslash, “\”” to enter a double quote, and “\” followed by any other character to enter that character.  Note that the C conventions of \ooo and \xhh are not supported.

·key

A unique identifier that can used to reference objects in Linden World

·vector

3 floats that can be acted on together

Members are accessed via .x, .y. or .z.

·rotation

4 floats that represent a rotation

Members are accessed via .x, .y., .z, or .w.

·list

A heterogeneous list of the other data types

Lists are created via comma separated lists of the other data types enclosed by “[“ and “]”.

 

string StringVar = "Hello, Carbon Unit";

list MyList = [ 1234, ZERO_ROTATION, StringVar ];

 

Give this list:

 

[ 1234, <0,0,0,1>, "Hello, Carbon Unit" ]

 

Lists may be combined with other lists or variables to form larger lists:

 

MyList = 3.14159 + MyList;

 

This would give the list:

 

[ 3.14159, 1234, <0,0,0,1>, "Hello, Carbon Unit" ]

 

MyList = MyList + MyList ;

 

[ 3.14159, 1234, <0,0,0,1>, "Hello, Carbon Unit", 3.14159, 1234, <0,0,0,1>, "Hello, Carbon Unit" ]

 

Library function are used to copy data from lists, sort lists, copy/remove sublists.

Arithmetic Operations

LSL supports a wide range of arithmetic operations between its basic types using Java/C syntax.

 

float      foo_float = 4.0;

integer  foo_int = 4;

vector   foo_vector = <1,1,1>;

rotation   foo_rotation = <1,0,0,0>;

 

// scale up vector

foo_vector = foo_int * foo_vector;

 

// rotate vector by rotation

foo_vector = foo_vector * foo_rotation;

 

// mix integer and floats

foo_float = foo_float * foo_int;

Type Conversion

Type conversion can either occur implicitly or explicitly.  Explicit type casts are accomplished using C syntax:

 

float      foo_float = 1.0;

integer  foo_int =(integer)foo_float;

Implicit Type Casting

LSL only supports two implicit type casts: integer to float and string to key.

Explicit Type Casting

LSL supports the following explicit casts:

·Integer to String

·Float to Integer

·Float to String

·Vector to String

·Rotation to String

·Integer to List

·Float to List

·Key to List

·String to List

·Vector to List

·Rotation to List

·String to Integer

·String to Float

·String to Vector

·String to Rotation

Loop Constructs

LSL supports several C/Java loop structures.

for

The LSL for loop operates like the Java/C loop structure except that variables may not be declared within the for command:

 

integer  j;

integer  count = 10;

 

for (j = 0; j < count; j++)

{

    // do stuff here

}

do-while

The LSL do-while loop operates like the Java/C loop structure:

 

integer  j;

integer  count = 10;

 

do

{

    // do stuff here and increment j

} while (j < count);

while

The LSL while loop operates like the Java/C loop structure:

 

integer  j;

integer  count = 10;

 

while (j < count)

{

    // do stuff here and increment j

}

Conditional Statements

LSL supports if and if-else conditional statements.

if

The LSL if statements operates just like the Java/C versions:

 

integer  small = 1;

integer  big = 10;

 

if (small < big)

{

    // we get here!

}

if-else

The LSL if-else statements operates just like the Java/C versions:

 

integer  small = 1;

integer  big = 10;

 

if (small < big)

{

    // we get here!

}

else

{

    // we don’t get here

}

Jumps

LSL supports a jump statement within functions or event handlers.

 

@Label;

 

// do stuff

 

jump Label;

Example Code

New Firework Script

This new firework script work similarly to the original.  Note that this script requires that sounds names “whoosh” and “boom” be in the object it is attached to, as well as textures “smoke” and “spark.”

 

// new and improved firework

 

// global variable for timing when the firework explodes

float gTotalTime = 0.0;

 

// how often do we put out little smoke poofs

float gPoofInterval = 0.1;

 

// what direction are we flying

vector gDirection;

 

// all scripts start in the default state

default

{

    state_entry()

     {

            llSay(0, "Touch me to launch!");

            llSetStatus(STATUS_PHYSICS, TRUE);

     }

    // if an avatar touches us and then let's go this event is triggered

    touch_end(integer num)

    {

        // only launch if we're physical

        if (llGetStatus(STATUS_PHYSICS))

        {

            // we'll use the timer callback to make smoke poofs, fly upwards, and blowup

            //  use a long initial delay for dramatic effect

            llSetTimerEvent(1.0);

           

            // get our up vector and create a strong upwards impulse to pop us upwards

            gDirection = <0.0, 0.0, 1.0> * llGetMass() * 15.0;

            llApplyImpulse(gDirection, TRUE);

            llSetTorque(<0.0,0.0,2.0>, TRUE);

           

            // make a continuous sound of us flying updards

            llLoopSound("whoosh", 2.0);

           

            // make a puff of smoke to show our launch

            llMakeExplosion(20, 1.0, 2, 5.0, 0.2, "smoke", <0.0, 0.0, 0.0>);

        }

    }

   

    // called every gPoofInterval seconds

    timer()

    {

        // again, get our up vector to apply thrust along

        gDirection = <0.0, 0.0, 1.0> * llGetMass() * 20.0 * gTotalTime;

        // also apply a torque to make it rotate along the vertical axis

        llSetForceAndTorque(gDirection, <0.0,0.0,5.0>, TRUE);

        // bump up the time

        gTotalTime += gPoofInterval;

        // do we need to explode?

        if (gTotalTime > 3.0)

        {

            // Turn off the continuous sound

            llStopSound();

            // Make an explosion sound

            llTriggerSound("boom", 2.0);

            // The explosion arguments are number of particles, scale of particles,

            //  speed of particles, lifetime of paricles, how directional the particles are,

            //  with a smaller number being more directional, and the UUID of the texture used

            llMakeExplosion(40, 1.0, 20.0, 2.0, 1.0, "poof", <0.0, 0.0, 0.0>);

            // Kill ourself

            llDie();

        }

        else

        {

            // we'll use the timer callback to make smoke poofs, fly upwards, and blowup

            llSetTimerEvent(gPoofInterval);

            // make a small smoke poof

            llMakeExplosion(10, 1.0, 2, 5.0, 0.2, "smoke", <0.0, 0.0, 0.0>);

        }

    }

}

Gambling Script

This script illustrates how to make a script that reacts to money being given to it and gives money to a user.

 

// A simple gambling script

 

// all scripts start in the default state

default

{

    // tell people what to do

    state_entry()

    {

        // Need to ask owner for permission to debit account

        key owner = llGetOwner();

        llRequestPermissions(owner, PERMISSION_DEBIT);

 

        // The first argument in the llSay library function says what channel to use

        //  Only channel 0 is audible by avatars

        llSay(0, "Give me money!");

    }

   

    // being given money triggers this callback

    money(key name, integer amount)

    {

        // Currently the type cast doesn't bind correctly, so extra parenthesis are needed

        //  to properly typecast in arithmetic expressions

        //  This is also a way to see what your UUID is

        llSay(0, "Thanks " + ((string)name) + " for the " + ((string)amount) + " L$!");

 

        // This gambling script has a 1 in 10 chance of winning but only pays 5 to 1, which

        //  isn't very good odds

        if (llFrand(1.0) > 0.9)

        {

            llSay(0, "You WIN " + ((string)(amount * 5)));

            // the llGiveMoney library call allows you to remotely transfer money to another user

            llGiveMoney(name, amount * 5);

        }

    }

}

The Cannon Scripts

This combination of scripts create a cannonball that explodes when it hits the ground, blocker bricks that explode when cannonballs hit them, a cannon that fires cannon balls, and a fuse that causes the cannon to fire.  The cannonball needs to be saved into your inventory so that its UUID can be used in the cannon script.  Be aware that since the cannonball explodes when in contact with the ground, you’ll need to place it on an object that you’ve dragged into the air.  The cannon, cannon ball, and blocker bricks will need the sound “boom” and the texture “poof” and the fuse will need texture “poof.”  The cannon will also need the object cannon ball in it’s inventory.

 

// cannon script

 

// Global variable that provides for a minimum delay between shots

float   gReloadTime = 1.0;

 

// A global function that creates an explosion, a sound, and then kills itself

die()

{

    // The sound arguments are UUID of the sound, volume of the sound,

    //  whether the sound is continuous or not, and whether to cancel the sound or not

    llTriggerSound("boom", 2.0);

    // The explosion arguments are number of particles, scale of particles,

    //  speed of particles, lifetime of paricles, how directional the particles are,

    //  with a smaller number being more directional, and the UUID of the texture used

    llMakeExplosion(60, 1.0, 10.0, 2.0, 1.0, "poof", <0.0, 0.0, 0.0>);

    llDie();

}

 

// all scripts start in the default state

default

{

    // setup when script first starts running

    state_entry()

    {

        // make sure the object is physical so that the llMoveToTarget library call works

        llSetStatus(STATUS_PHYSICS, TRUE);

        // setup listen callback for chat channel 1 and the text "fire"

        integer num = llListen(1, "","","fire");

        // fix us on the position where we are

        vector pos = llGetPos();

        // the 0.1 in the MoveToTarget call makes the object move there quickly

        llMoveToTarget(pos, 0.1);

    }

   

    // if an avatar moves the cannon, relock to that point

    touch_end(integer num)

    {

        // because only we only be moving to one target at a time, this call replaces the previous one

        vector pos = llGetPos();

        llMoveToTarget(pos, 0.1);

    }

   

    // this listen event will be triggered by chat text of "fire" on channel 1

    listen(integer chan, string name, key id, string text)

    {

        // trigger a sound and make a smoke poof to indicate firing

        llTriggerSound("boom", 2.0);

        llMakeExplosion(10, 1.0, 2.0, 5.0, 0.2, "poof", <0.0, 0.0, 0.0>);

       

        // determine where we're going to fire the cannonball

        rotation rot = llGetRot();

        // extract our "up" direction from our rotation

        vector direction = llRot2Up(rot);

       

        // create a small offset so that the cannonball isn't created inside the cannon

        vector pos = llGetPos();

        pos += direction;

       

        // generate a velocity of 30 meters/second

        direction *= 30.0;

       

        // create the cannonball

        // the llRexObject arguments are the owner's UUID, the object to rez-ed UUID, the position to rez the object,

        //  the velocity of the object, and the rotation of the object

        llRezObject("cannon ball", pos, direction, <0,0,0,1>, 0);

       

        // put the cannon to sleep until reload time is over

        llSleep(gReloadTime);

    }

 

    // if a cannonball hits us, blow up

    collision_start(integer total_num)

    {

        // only blow up if it's a cannonball

        key test = llDetectedKey(0);

 

                        if (test  ==(key)"cannonball")

            die();

    }

}

 

// cannon ball

// A global function that creates an explosion, a sound, and then kills itself

die()

{

    llTriggerSound("boom", 2.0);

    llMakeExplosion(80, 1.0, 13.0, 2.2, 1.0, "poof", <0.0, 0.0, 0.0>);

    llDie();

}

 

// all scripts start in the default state

default

{

    // make sure that we are physical so that we fly through the air when created

    state_entry()

    {

        llSetStatus(STATUS_PHYSICS, TRUE);

    }

 

    // when we hit the ground, explode and die

    land_collision_start(vector pos)

    {

        die();

    }

}

 

// fuse script

float gScale = 1.0;

 

// all scripts start in the default state

default

{

    touch_end(integer total_num)

    {

        llSetTimerEvent(0.2);

        llMakeSmoke(10, 0.2, 3.0, 3.0, 0.10, "poof", <0,0,0>);

        llSleep(0.5);

    }

 

    timer()

    {

        vector scale = llGetScale();

        scale.z = gScale;

        gScale -= 0.05;

        llSetScale(scale);

        llMakeSmoke(2, 0.2, 3.0, 3.0, 0.10, "poof", <0,0,0>);

        if (gScale < 0.2)

        {

            llSay(1, "fire");

            gScale = 1.0;

            scale.z = gScale;

            llSetScale(scale);

            llSetTimerEvent(0.0);

        }

    }

}

 

// blockerbrick

 

// A global function that creates an explosion, a sound, and then kills itself

die()

{

    // The sound arguments are UUID of the sound, volume of the sound,

    //  whether the sound is continuous or not, and whether to cancel the sound or not

    llTriggerSound("boom", 2.0);

    // The explosion arguments are number of particles, scale of particles,

    //  speed of particles, lifetime of paricles, how directional the particles are,

    //  with a smaller number being more directional, and the UUID of the texture used

    llMakeExplosion(20, 1.0, 10.0, 2.0, 1.0, "poof", <0.0, 0.0, 0.0>);

    // Kill ourself

    llDie();

}

 

// all scripts start in the default state

default

{

    // if a cannonball hits us, explode

    collision_start(integer total_num)

    {

        string test = llDetectedName(0);

 

        if (test  == "cannon ball")

            die();

    }

 

}

Reference Manual

Events

The following events may be handled within states.

state_entry()

The state_entry event occurs whenever a new state is entered, including program start, and is always the first event handled. No data is passed to handler.

state_exit()

The state_entry event occurs whenever the state command is used to transition to another state.  It is handled before the new state’s state_entry event.

touch_start(integer total_number)

This event is raised when a user first touches the object the script is attached to.  The number of touching objects is passed to the script.  Information on those objects may be gathered via the llDetected* library functions. 

touch(integer total_number)

This event is raised while a user is touching the object the script is attached to.  The number of touching objects is passed to the script.  Information on those objects may be gathered via the llDetected* library functions. 

touch_end(integer total_number)

This event is raised when a user stops touching the object the script is attached to.  The number of touching objects is passed to the script.  Information on those objects may be gathered via the llDetected* library functions.

collision_start(integer total_number)

This event is raised when another object begins to collide with the object the script is attached to.  The number of detected objects is passed to the script.  Information on those objects may be gathered via the llDetected* library functions. (Collisions are also generated if a user walks into an object.)

collision(integer total_number)

This event is raised while another object is colliding with the object the script is attached to.  The number of detected objects is passed to the script.  Information on those objects may be gathered via the llDetected* library functions. (Collisions are also generated if a user walks into an object.)

collision_end(integer total_number)

This event is raised when another object stops colliding with the object the script is attached to.  The number of detected objects is passed to the script.  Information on those objects may be gathered via the llDetected* library functions. (Collisions are also generated if a user walks into an object.)

land_collision_start(vector position)

This event is raised when the object the script is attached to begins to collide with the ground.

land_collision(vector position)

This event is raised when the object the script is attached to is colliding with the ground.

land_collision_end(vector position)

This event is raised when the object the script is attached to stops colliding with the ground.

timer()

This event is raised at regular intervals set by the llSetTimerEvent library function.

listen(integer channel, string name, key id, string message)

This event is raised whenever a chat message matching the constraints passed in the llListen command is heard.  The name and key of the speaker and the message are passed.  Channel 0 is the public chat channel that all avatars see as chat text.  Channels 1 – 2,147,483,648 are private channels that aren’t sent to avatars but other scripts can listen for.

 

sensor(integer total_number)

This event is raised whenever objects matching the constraints of the llSensor command are detected.  The number of detected objects is passed to the script.    Information on those objects may be gathered via the llDetected* library functions.

no_sensor()

This event is raised when sensors are active (via the llSensor library call) but are not sensing anything.

control(key name, integer levels, integer edges)

Once a script has the ability to grab control inputs from the avatar, this event will be used to pass the commands into the script.

at_target(integer number, vector targetpos, vector ourpos)

When a script comes within a defined range of a target position (defined by llTarget library call) this event is raised.

not_at_target()

When a target is set (via the llTarget library call) but the script is outside the specified range this event is raised.

at_rot_target(integer number, rotation targetrot, rotation ourrot)

When a script comes within a defined angle of a target rotation (defined by llRotTarget library call) this event is raised.

not_at_rot_target()

When a target is set (via the llRotTarget library call) but the script is outside the specified angle this event is raised.

money(key giver, integer amount)

User giver has given an amount of Linden dollars to the object.

email(string time, string address, string subject, string body, integer remaining)

An email sent to the object this script was attached to was waiting on the dataserver.  The remaining tells how many more emails are waiting.

run_time_permissions(integer permissions)

Scripts need permission from either the owner or the avatar they wish to act on before they perform certain functions, such as debiting money from their owner’s account, triggering an animation on an avatar, or capturing control inputs.  The llRequestPermissions library function is used to request these permissions and the various permissions integer constants can be supplied.  The integer returned to this event handler contains the current set of permissions flags, so if permissions == 0 then no permissions are set.

changed(integer changed)

Triggered when various events change the object.  Test change with CHANGED_INVENTORY, CHANGED_COLOR, CHANGED_SHAPE, CHANGED_SCALE, CHANGED_TEXTURE, or CHANGED_LINK.

attach(key attached)

Triggered whenever a object with this script is attached or detached from an avatar.  If it is attached, attached is the key of the avatar it is attached to, otherwise attached == NULL_KEY.

moving_start()

Triggered whenever a object with this script starts moving.

moving_end()

Triggered whenever a object with this script stops moving.

on_rez(integer start_param)

Triggered whenever a object is rez-ed from inventory or by another object.  The start_param is the start parameter passed by llRezObject.

link_message(integer sender_num, integer num, string str, key id)

Triggered when object receives a link message via LLMessageLinked library function call.

object_rez(key id)

Triggered when object rez-es in another object from its inventory.

dataserver(key requested, string data)

Triggered when the requested data is returned to the script.  Data may be requested by the llRequestAgentData, the llRequestInventoryData, and the llGetNotecardLine function calls.

Arithmetic Operations

LSL2 supports many arithmetic operations by default.

Assignment and Comparison

The assignment operator, =, is used by all types.  The equals, ==, and not equals, !=, operators are also used by all types.  The various inequality operators, <, >, <=, >=, are defined for integer and float types.

Integer Arithmetic

LSL2 supports +, -, *, /, %, &&, ||, !, ~, %, | , and ^.  All operations have the same meanings as their C counterparts.

Integer Constants

LSL2 supports the following integer constants:

·Boolean values: TRUE and FALSE

·Status flags (can be or’ed together) for llSetStatus and llGetStatus library calls:

STATUS_PHYSICS controls whether the object can move physically

STATUS_PHANTOM controls whether the object collides or not STATUS_ROTATE_X,

STATUS_ROTATE_Y, and

STATUS_ROTATE_Z control whether the object can rotate around the specific axis or not

STATUS_BLOCK_GRAB controls whether the object can be grabbed STATUS_SANDBOX controls whether the object can cross region boundaries and move more than 20 meters from its creation point

STATUS_DIE_AT_EDGE controls whether the object is returned to the owner’s inventory if it wanders off the edge of the world

·Object type description (can be or’ed together) for sensor library calls: AGENT, ACTIVE, PASSIVE, and SCRIPTED

·Permissions constants (can be or’ed together):

PERMISSION_DEBIT, PERMISSION_TAKE_CONTROLS, PERMISSION_REMAP_CONTROLS, PERMISSION_TRIGGER_ANIMATION, PERMISSION_ATTACH, PERMISSION_RELEASE_OWNERSHIP, PERMISSION_CHANGE_LINKS, PERMISSION_CHANGE_JOINTS, PERMISSION_CHANGE_PERMISSIONS

·Inventory constants used for managing object’s inventory:

INVENTORY_TEXTURE, INVENTORY_SOUND, INVENTORY_OBJECT, INVENTORY_SCRIPT, INVENTORY_LANDMARK, INVENTORY_CLOTHING, INVENTORY_NOTECARD, INVENTORY_BODYPART

·Attachment constants for attaching to avatars via llAttachToAvatar:

ATTACH_CHEST

ATTACH_HEAD

ATTACH_LSHOULDER

ATTACH_RSHOULDER

ATTACH_LHAND

ATTACH_RHAND

ATTACH_LFOOT

ATTACH_RFOOT

ATTACH_BACK

ATTACH_PELVIS

ATTACH_MOUTH

ATTACH_CHIN

ATTACH_LEAR

ATTACH_REAR

ATTACH_LEYE

ATTACH_REYE

ATTACH_NOSE

ATTACH_RUARM

ATTACH_RLARM

ATTACH_LUARM

ATTACH_LLARM

ATTACH_RHIP

ATTACH_RULEG

ATTACH_RLLEG

ATTACH_LHIP         

ATTACH_LULEG

ATTACH_LLLEG

ATTACH_BELLY     

ATTACH_RPEC      

ATTACH_LPEC

·Attachment constants for llModifyLand:

LAND_LEVEL, LAND_RAISE, LAND_LOWER, LAND_SMALL_BRUSH, LAND_MEDIUM_BRUSH, LAND_LARGE_BRUSH

·Link constants for llSetLinkColor, llMessageLinked:

LINK_SET, LINK_ROOT, LINK_ALL_OTHERS, LINK_ALL_CHILDREN

·Control constants for use in llTakeControls and in the control event handler:

CONTROL_FWD Tests for avatar forward control

CONTROL_BACK Tests for avatar back control

CONTROL_LEFT Tests for avatar move left control

CONTROL_RIGHT Tests for avatar move right control

CONTROL_ROT_LEFT Tests for avatar rotate left control

CONTROL_ROT_RIGHT Tests for avatar rotate right control

CONTROL_UP Tests for avatar up control

CONTROL_DOWN Tests for avatar down control

CONTROL_LBUTTON Tests for avatar left button control

CONTROL_ML_LBUTTON Tests for avatar left button control with the avatar in mouse look

·Change constants are passed into the changed event handler:

CHANGED_INVENTORY test for changed object inventory

CHANGED_COLOR tests for changed object color

CHANGED_SHAPE tests for changed object shape (box to cylinder, for example)

CHANGED_SCALE tests for changed object scale

CHANGED_TEXTURE tests for changed object texture or texture offset, scale or rotation

CHANGED_LINK tests for linking of delinking

·List type constants are used to determine the type of list members:

TYPE_INTEGER, TYPE_FLOAT, TYPE_STRING, TYPE_KEY, TYPE_VECTOR, TYPE_ROTATION, TYPE_INVALID

·llGetAgentInfo return values:

AGENT_FLYING if the agent is flying

AGENT_ATTACHMENTS if the agent has attachments

AGENT_SCRIPTED if the agent has scripted attachments

Float Arithmetic

LSL2 supports +, -, *, and /.  All operations have the same meanings as their C counterparts.

Floating Point Constants

LSL2 supports the following floating point constants:

·PI                         3.14159265

·TWO_PI             6.28318530

·PI_BY_TWO                  1.57079633

·DEG_TO_RAD 0.01745329

·RAD_TO_DEG 57.2957795

·SQRT2               1.41421356

Vector Arithmetic

LSL2 supports +, -, *, and %, with * defining the vector dot product and % the vector cross product.  Vectors may also be multiplied by integers and floats to scale them, and rotations to rotate them.

Rotation Arithmetic

LSL2 supports +, -, and *.

String Arithmetic

LSL2 supports + for concatenation.

Key Constant

LSL2 supports one key constant which acts as an invalid key:

·NULL_KEY

Library Function Calls

llSin

float llSin(float theta);

 

Returns the sine of theta radians.

llCos

float llCos(float theta);

 

Returns the cosine of theta radians.

llTan

float llTan(float theta);

 

Returns the tangent of theta radians.

llAtan2

float llAtan2(float y, float x);

 

Returns the arctangent2 of y, x.

llSqrt

float llSqrt(float val);

 

Returns the square root of val.  If val < 0.0 return 0.0 and raise a math runtime error.

llPow

float llSqrt(float base, float exp);

 

Returns base raised to exp.

llAbs

integer llAbs(integer val);

 

Returns the absolute value of val.

llFabs

float llFabs(float val);

 

Returns the absolute value of val.

 

llFrand

float llFrand(float mag);

 

Returns a pseudo-random number between [0, mag).

 

llFloor

integer llFloor(float val);

 

Returns largest integer value <= val.

llCeil

integer llCeil(float val);

 

Returns largest integer value >= val.

llRound

integer llRound(float val);

 

Returns val rounded to the nearest integer.

llVecMag

float llVecMag(vector vec);

 

Returns the magnitude of vec.

llVecNorm

vector llVecNorm(vector vec);

 

Returns vec normalized.

llVecDist

float llVecDist(vector a, vector b);

 

Returns the distance from a to b.

llRot2Euler

vector llRot2Euler(rotation rot);

 

Returns the Euler Angle representation of rot.

llEuler2Rot

rotation llEuler2Rot (vector vec);

 

Returns the rotation represented by Euler Angle vec.

llAxes2Rot

rotation llAxes2Rot (vector fwd, vector left, vector up);

 

Returns the rotation represented by coordinate axes fwd, left, and up.

llRot2Fwd

vector llRot2Fwd (rotation rot);

 

Returns the forward axis represented by rot.

llRot2Left

vector llRot2Left (rotation rot);

 

Returns the left axis represented by rot.

llRot2Up

vector llRot2Up (rotation rot);

 

Returns the up axis represented by rot.

llRotBetween

rotation llRotBetween (vector a, vector b);

 

Returns the rotation needed to rotate a to b.

llWhisper

llWhisper(integer channel, string text);

 

Whisper text on channel.  Channel 0 is the public chat channel that all avatars see as chat text.  Channels 1 – 2,147,483,648 are private channels that aren’t sent to avatars but other scripts can listen for.

llSay

llSay(integer channel, string text);

 

Say text on channel.  Channel 0 is the public chat channel that all avatars see as chat text.  Channels 1 – 2,147,483,648 are private channels that aren’t sent to avatars but other scripts can listen for.

llShout

llShout(integer channel, string text);

 

Shout text on channel.  Channel 0 is the public chat channel that all avatars see as chat text.  Channels 1 – 2,147,483,648 are private channels that aren’t sent to avatars but other scripts can listen for.

 

llListen

integer llListen(integer channel, string name, key id, string msg);

 

Sets a listen event callback for msg on channel from name (name, id and/or msg can be empty) and returns an identifier that can be used to deactivate or remove the listen.  Channel 0 is the public chat channel that all avatars see as chat text.  Channels 1 – 2,147,483,648 are private channels that aren’t sent to avatars but other scripts can listen for.

 

llListenControl

llListenControl(integer number, integer active);

 

Makes a listen event callback active or inactive.

llListenRemove

llListenRemove(integer number);

 

Removes a listen event callback.

llSensor

llSensor(string name, key id, integer type, float range, float arc);

 

Performs a single scan for name and id with type (AGENT, ACTIVE, PASSIVE, and/or SCRIPTED) within range meters and arc radians of forward vector (name and/or id can be empty or 0).  A range of 0.0 does perform a scan.

llSensorRepeat

llSensorRepeat(string name, key id, integer type, float range, float arc, float rate);

 

Sets a callback for name and id with type (AGENT, ACTIVE, PASSIVE, and/or SCRIPTED) within range meters and arc radians of forward vector (name and/or id can be empty or 0) and repeats every rate seconds.  Passing a range of 0.0 cancels the sensor.

llSensorRemove

llSensorRemove();

 

Removes the sensor.

llDetectedName

string llDetectedName(integer number);

 

Returns the name of detected object number (returns empty string if number is not valid sensed object).

llDetectedKey

key llDetectedKey(integer number);

 

Returns the key of detected object number (returns invalid key if number is not valid sensed object).

llDetectedOwner

key llDetectedOwner(integer number);

 

Returns the key of detected object’s owner number (returns invalid key if number is not valid sensed object).

 

integer llDetectedType(integer number);

 

Returns the type (AGENT, ACTIVE, PASSIVE, SCRIPTED) of detected object (returns 0 if number is not valid sensed object).  Note that the return value is a bit field, so comparisons need to be an AND check, ie:

 

            integer type = llDetectedType(0);

            if (type & AGENT)

            {

                        // do stuff

            }

llDetectedPos

vector llDetectedPos(integer number);

 

Returns the position of detected object number (returns <0,0,0> if number is not valid sensed object).

llDetectedVel

vector llDetectedVel(integer number);

 

Returns the velocity of detected object number (returns <0,0,0> if number is not valid sensed object).

llDetectedGrab

vector llDetectedGrab(integer number);

 

Returns the grab offset of detected object number (returns <0,0,0> if number is not valid sensed object).

llDetectedRot

rotation llDetectedRot(integer number);

 

Returns the rotation of detected object number (returns <0,0,0,1> if number is not valid sensed object).

llDetectedLinkNumber

integer llDetectedLinkNumber(integer number);

 

Returns the link position (0 for a non-linked object, 1 for the root of a linked object, 2 for the first child, &c) of the triggered event for touches.

llDie

llDie();

 

Delete the object that the script is attached to.

llGround

float llGround(vector offset);

 

Returns the ground height at the object position + offset.

llCloud

float llCloud(vector offset);

 

Returns the cloud density at the object position + offset.

 

llWind

vector llWind(vector offset);

 

Returns the wind velocity below the object position + offset.

 

llSetStatus

llSetStatus(integer status, integer value);

 

Sets status to value.

llGetStatus

integer llGetStatus(integer status);

 

Gets value of status.

llSetScale

llSetScale(vector scale);

 

Sets the scale.

llGetScale

vector llGetScale(key name);

 

Gets the scale.

llSetColor

llSetColor(vector color, integer face);

 

Sets the color.  If face == ALL_SIDES, set the color to all faces.

llGetColor

vector llGetColor(integer face);

 

Gets the color.

llSetAlpha

llSetAlpha(float alpha, integer face);

 

Sets the alpha.  If face == ALL_SIDES, set the alpha to all faces.

llGetAlpha

float llGetAlpha(integer face);

 

Gets the alpha.

llSetTexture

llSetTexture(string texture, integer face);

 

Sets the texture from object inventory of face.  If face == ALL_SIDES, set the texture to all faces.

llGetTexture

string llGetTexture(integer face);

 

Gets the texture of face if in object inventory.

llScaleTexture

llScaleTexture(float scale_s, float scale_t, integer face);

 

Sets the texture s and t scales of face.  If face == ALL_SIDES, scale the texture to all faces.

llOffsetTexture

llOffsetTexture(float offset_s, float offset_t, integer face);

 

Sets the texture s and t offsets of face.  If face == ALL_SIDES, set the texture offsets for all faces.

llRotateTexture

llRotateTexture(float rot, integer face);

 

Sets the texture rotation of face.  If face == ALL_SIDES, rotate the texture of all faces.

llSetTextureAnim

llSetTextureAnim(integer mode, integer face, integer sizex, integer sizey, float start, float length, float rate);

 

Animates a texture by setting the texture scale and offset.  Mode is a mask, consisting of:

ANIM_ON – texture animation is on.

LOOP – loop the texture animation.

REVERSE – play animation in reverse direction.

PING_PONG – play animation going forwards, then backwards.

SMOOTH – slide in the X direction, instead of playing separate frames.

ROTATE – Animate texture rotation instead.

SCALE – Animate the texture scale instead.

 

Only ONE texture animation can be active at a time.  You can only do traditional animation, ROTATE, or SCALE at a time, you can’t combine masks.

 

In the case of ROTATE or SCALE, sizex and sizey are ignored, and start and length are used as the start and length values of the animation.  For rotation, start and length are in radians.

 

face is which face to animate. If face == ALL_SIDES, all textures on the object are animated.  You can only have one texture animation on an object, calling llSetTextureAnim more than once on an object will reset it.

 

sizex and sizey describe the layout of the frames within the texture.  sizex is how many horizontal frames, sizey is how many vertical frames.

 

start is the frame number to begin the animation on.  Frames are numbered from left to right, top to bottom, starting at 0.

 

length is the number of frames to animate. 0 means to animate all frames after the start frame.

 

rate is the frame rate to animate at. 1.0 means 1 frame per second, 10.0 means 10 frames/second.

llSetPos

llSetPos(vector pos);

 

Sets the position (if the script isn't physical).  If the object is a child, the position is treated as root relative and the linked set is adjusted.

llGetPos

vector llGetPos();

 

Gets the position.

llGetLocalPos

vector llGetLocalPos();

 

Gets the local position of a child object.

llSetRot

llSetRot(rotation rot);

 

Sets the rotation (if the script isn't physical).  If the object is a child, the rotation is treated as root relative and the linked set is adjusted.

llGetRot

rotation llGetRot();

 

Gets the rotation.

llGetLocalRot

rotation llGetLocalRot();

 

Gets the local rotation of a child object.

llSetText

llSetText(string text, vector color, float alpha)

Sets text that floats above object to text, using specified color and alpha.

llSetForce

llSetForce(vector force, integer local);

 

Sets the force, in local coordinates if local == TRUE (if the script is physical).

llGetForce

vector llGetForce();

 

Gets the force (if the script is physical).

llTarget

integer llTarget(vector position, float range);

 

Set positions within range of position as a target and return an ID for the target.

llTargetRemove

llTargetRemove(integer tnumber);

 

Remove target number tnumber.

llRotTarget

integer llRotTarget(rotation rotation, float error);

 

Set rotations within error of rotation as a rotational target and return an ID for the target.

llRotTargetRemove

llRotTargetRemove(integer tnumber);

 

Remove rotational target number tnumber.

llMoveToTarget

llMoveToTarget(vector target, float tau);

 

Critically damp to target in tau seconds (if the script is physical).  Good tau values are greater than 0.2.  A tau of 0.0 stops the critical damping.

llStopMoveToTarget

llMoveToTarget();

 

Stops critically damped motion.

llApplyImpulse

llApplyImpulse(vector force, integer local);

 

Applies the impulse, in local coordinates if local == TRUE (if the script is physical).

llApplyRotationalImpulse

llApplyRotationalImpulse(vector force, integer local);

 

Applies the rotational impulse, in local coordinates if local == TRUE (if the script is physical).

llSetTorque

llSetTorque(vector torque, integer local);

 

Sets the torque, in local coordinates if local == TRUE (if the script is physical).

llGetTorque

vector llGetTorque();

 

Gets the torque (if the script is physical).

llSetForceAndTorque

llSetForceAndTorque(vector force, vector torque, integer local);

 

Sets the force and torque, in local coordinates if local == TRUE (if the script is physical).

llGetVel

vector llGetVel();

 

Gets the velocity.

llGetAccel

vector llGetAccel();

 

Gets the acceleration.

llGetOmega

vector llGetOmega();

 

Gets the omega.

llGetTimeOfDay

float llGetTimeOfDay();

 

Gets the time in seconds since LindenWorld midnight.

llGetWallclock

float llGetWallclock();

 

Gets the time in seconds since simulator timezone midnight.

llGetTime

float llGetTime();

 

Gets the time in seconds since creation.

llResetTime

llResetTime();

 

Sets the time to zero.

llGetAndResetTime

float llGetAndResetTime();

 

Gets the time in seconds since creation and sets the time to zero.

llPlaySound

llPlaySound(key sound, float volume);

 

Plays a sound once, attached to an object (the sound follows object movement). Only one sound may be attached to an object currently, and attaching a new sound (or calling llStopSound will stop the previously attached sound.  A second call to llPlaySound with the same key will not restart the sound, but the new volume will be used, which allows control over the volume of already playing sounds.  To restart the sound from the beginning, call llStopSound() before calling llPlaySound() again.

llLoopSound

llLoopSound(key sound, float volume);

 

Similar to llPlaySound, llLoopSound plays a sound attached to an object, but will continuously loop that sound until llStopSound() or llPlaySound() is called. Only one sound may be attached to an object currently, and a second call to llLoopSound with the same key will not restart the sound, but the new volume will be used, which allows control over the volume of already playing sounds.  Setting the volume to 0 is not the same as calling llStopSound; a sound with 0 volume will continue to loop.  To restart the sound from the beginning, call llStopSound() before calling llLoopSound() again.

 

llTriggerSound

llTriggerSound(key sound, float volume);

 

Plays a transient sound NOT attached to an object (the sound plays from a stationary position located at the center of the object at the time of the trigger.) There is no limit to the number of llTrigger sounds which can be generated by an object, and calling llTriggerSound does not affect the attached sounds created by llPlaySound and llLoopSound.  This is very useful for things like collision noises, explosions, etc.  There is no way to stop or alter the volume of a sound triggered by llTriggerSound. 

llTriggerSoundLimited

llTriggerSoundLimited(string sound, float volume, vector tne, vector bsw);

 

Plays a transient sound NOT attached to an object (the sound plays from a stationary position located at the center of the object at the time of the trigger) with its audible range limited by the axis aligned bounding box defined by tne (top-north-east) and bsw (bottom-south-west) corners.  There is no limit to the number of llTrigger sounds which can be generated by an object, and calling llTriggerSound does not affect the attached sounds created by llPlaySound and llLoopSound.  This is very useful for things like collision noises, explosions, etc.  There is no way to stop or alter the volume of a sound triggered by llTriggerSound. 

llStopSound

llStopSound();

 

Stops a currently playing attached sound (started with llPlaySound or llLoopSound).  Has no effect on sounds started with llTriggerSound 

llPreloadSound

llPreloadSound(string sound);

 

Preloads sound from object inventory on viewers.

llAdjustSoundVolume

llAdjustSoundVolume(float volume);

 

Adjusts the volume of the currently playing attached sound (started with llPlaySound or llLoopSound).  Has no effect on sounds started with llTriggerSound.

llSetSoundQueueing

llSetSoundQueueing(integer queue);

 

Sets whether successive calls to llPlaySound, llLoopSound etc. attached sounds only) interrupt the playing sound (FALSE, the default behavior) or wait until the current playing sound reaches its end (TRUE).  The queue is one level deep.

llLoopSoundMaster

llLoopSoundMaster(key sound, float volume);

 

Behaviour is identical to llLoopSound, with the addition of marking the source as a “Sync Master”, causing “Slave” sounds to sync to it.  If there are multiple masters within a viewer’s interest area, the most audible one (a function of both distance and volume) will win out as the master.  However, the use of multiple masters within a small area is unlikely to produce the desired effect.

llLoopSoundSlave

llLoopSoundSlave(key sound, float volume);

 

Behaviour is identical to llLoopSound, unless there is a “Sync Master” present.  If a Sync Master is already playing the Slave sound will begin playing from the same point the master is in its loop (syncronizing the loop points of both sounds).  If a Master is started when the Slave is already playing, the Slave will skip to the correct position to sync with the Master.

llPlaySoundSlave

llPlaySoundSlave(key sound, float volume);

 

Behaviour is identical to llPlaySound, unless there is a “Sync Master” present.  If a Sync Master is already playing the Slave sound will not be played until the Master hits its loop point and returns to the beginning.  llPlaySoundSlave will play the sound exactly once; if it is desired to have the sound play every time the Master loops, either use llLoopSoundSlave with extra silence padded on the end of the sound or ensure that llPlaySoundSlave is called at least once per loop of the Master.

llGetSubString

string llGetSubString(string src, integer start, integer end);

 

Returns the indicated substring.  Start and end are inclusive, so 0, length – 1 would capture the entire string and 0,0 would capture the first character.  Using negative numbers for start and/or end causes the index to count backwards from the length of the string, so 0,-1 would capture the entire string.  If start is larger than end the sub string is the exclusion of the entries, so 6,4 would give the entire string except for the 5th character.

llDeleteSubString

string llDeleteSubString(string src, integer start, integer end);

 

Removes the indicated substring and returns the result.  Start and end are inclusive, so 0, length – 1 would delete the entire string and 0,0 would delete the first character.  Using negative numbers for start and/or end causes the index to count backwards from the length of the string, so 0,-1 would delete the entire string.  If start is larger than end the sub string is the exclusion of the entries, so 6,4 would delete the entire string except for the 5th character.

llInsertString

string llInsertString(string dst, integer position, string src);

 

Inserts src into dst at position and returns the result.

llToUpper

string llToUpper(string src);

 

Converts src to all upper case and returns the result.

llToLower

string llToLower(string src);

 

Converts src to all lower case and returns the result.

llStringLength

integer llStringLength(string src);

 

Returns the number of characters in the src.

llGiveMoney

llGiveMoney(key destination, integer amount);

 

Transfer amount of money from script owner to destination.  Requires the PERMISSION_DEBIT runtime permission.

llMakeExplosion

llMakeExplosion(integer particles, float scale, float velocity, float lifetime, float arc, string texture, vector offset);

 

Make a round explosion of particles using texture from the object’s inventory.

llMakeFountain

llMakeFountain(integer particles, float scale, float velocity, float lifetime, float arc, integer bounce, string texture, vector offset, float bounce_offset);

 

Make a fountain of particles using texture from the object’s inventory.

llMakeSmoke

llMakeSmoke(integer particles, float scale, float velocity, float lifetime, float arc, string texture, vector offset);

 

Make smoky particles using texture from the object’s inventory.

llMakeFire

llMakeFire(integer particles, float scale, float velocity, float lifetime, float arc, string texture, vector offset);

 

Make fire particles using texture from the object’s inventory.

llRezObject

llRezObject(string inventory, vector pos, vector vel, rotation rot, integer param);

 

Creates object’s inventory object at position pos with velocity vel and rotation rot.

llSetTimerEvent

llSetTimerEvent(float sec);

 

Triggers a timer event every sec seconds.  Passing in 0.0 seconds stops further timer events.

llSleep

llSleep(float sec);

 

Puts script to sleep for sec seconds.

llLookAt

llLookAt(vector target, F32 strength, F32 damping);

 

Cause object name to point it's forward axis towards target.  Good strength values are around ½ the mass of the object and good damping values are less than 1/10th of the strength.  Asymmetrical shapes require smaller damping.  Strength of 0.0 cancels the look at.

llRotLookAt

llLookAt(rotation rot, F32 tau, F32 strength);

 

Cause object name to rotate to rot.  Good strength values are around ½ the mass of the object and good damping values are less than 1/10th of the strength.  Asymmetrical shapes require smaller damping.   Strength of 0.0 cancels the look at.

llStopLookAt

llStopLookAt();

 

Stop causing object name to point at a target.

llCollisionFilter

llCollisionFilter(string name, key id, integer accept);

 

If accept == TRUE, only accept collisions with objects name and id (either is optional), otherwise with objects not name or id.

llTakeControls

llTakeControls(integer controls, integer accept, integer pass_on);

 

If (accept == (controls & input)), send input to object.  If pass_on send to avatar also.

llReleaseControls

llReleaseControls(key avatar);

 

Stop taking inputs from avatar.

llAttachToAvatar

llAttachToAvatar(key avatar, integer attachment);

 

Attach to avatar at point attachment.  Requires the PERMISSION_ATTACH runtime permission.

llDetachFromAvatar

llDetachFromAvatar(key avatar);

 

Drop off of avatar.

llGetOwner

key llGetOwner();

 

Returns the owner of the object.

llInstantMessage

llInstantMessage(key user, string message);

 

IMs message to the user.

llEmail

llEmail(string address, string subject, string message);

 

Sends email to address with subject and message.

llGetNextEmail

llGetNextEmail(string address, string subject);

 

Get the next waiting email with appropriate address and/or subject (if blank they are ignored).

llGetKey

key llGetKey();

 

Get the key for the object the script is attached to.

llSetBuoyancy

llSetBuoyancy(float buoyancy);

 

Set the objects buoyancy (0 is none, < 1.0 sinks, 1.0 floats, > 1.0 rises).

llSetHoverHeight

llSetHoverHeight(float height, integer water, float tau);

 

Critically damps to a height (either above ground or above ground and water if water == TRUE).

llStopHover

llStopHover();

 

Stop hovering to a height.

llMinEventDelay

llMinEventDelay(float delay);

 

Set the minimum time between events being handled.

llStartAnimation

llStartAnimation(string anim);

 

Start animation anim for avatar that owns object.  The following strings are used:

 

“hold_R_bazooka”, “hold_R_handgun”,”hold_R_rifle”

Holds the appropriately shaped weapon in the right hand.  Automatically switches to the aims (below) when user enters mouse look

 “aim_R_bazooka”, “aim_R_handgun”, “aim_R_rifle”

Aims the appropriately shaped weapon along the direction the avatar is looking

“away”

Flops over in "away from keyboard" state

“backflip”

Performs a backflip

“bow”

Bows at waist

“brush”

Brushes dirt from shirt

“clap”

Applauds

“courtbow”

Bows with a courtly flourish

“crouch”

Crouches in place

“crouchwalk”

Walks in place while crouching

“dance1”, “dance2”, “dance3”, “dance4”, “dance5”, “dance6”, “dance7”, “dance8”

Various dance maneuvers

“falldown”

Freefall falling animation

“female_walk”

Walks with hip sway

“fly”

Flies forward

“flyslow”

Flies forward at a less agressive angle

“hello”

Waves

“hold_throw_R”

Hold object in right hand, prepared to throw it

“hover”

Hovers in place

“hover_down”

Pretends to hover straight down

“hover_up”

Pretends to hover straight up

“jump”

Midair jump position

“kick_roundhouse_R”

Roundhouse kick with right leg

“land”

Lands after flying

“prejump”

Prepares to jump

“punch_L”

Punch with left hand

“punch_R”

Punch with right hand

“punch_onetwo”

Punch with one hand then the other

“run”

Runs in place

“salute”

Salutes with right hand

“sit”

Sits on object at knee height

“sit_ground”

Sits down on ground

“slowwalk”

Walks in place slowly

“smoke_idle”

Leans on imaginary prop while holding cigarette

“smoke_inhale”

Leans on imaginary prop and smokes a cigarette

“smoke_throw_down”

Leans on imaginary prop, throws down a cigarette, and stamps it out

“snapshot”

Pantomimes taking a picture

“soft_land”

Stumbles a bit as if landing

“stand”

Stands in place

“standup”

Falls on face and stands up

“stride”

Legs extended as if stepping off of a ledge

“sword_strike_R”

Strike with sword in right hand

“talk”

Head moves as if talking

“target”

Right arm points where avatar is looking (used automatically with aim anims)

“throw_R”

Throws object in right hand

“tryon_shirt”

Turns around and models a new shirt

“turnleft”

Pretends to turn left

“turnright”

Pretends to turn right

“type”

Makes typing motion

“uphillwalk”

Walks uphill in place

“walk”

Walks in place

“whisper”

Whispers behind hand

“whistle”

Whistles with hands in mouth

“yell”

Shouts between cupped hands

llStopAnimation

llStopAnimation(string anim);

 

Stop animation anim for avatar that owns object.

llPointAt

llPointAt(vector pos);

 

Make avatar that owns object point at pos.

llStopPointAt

llStopPointAt();

 

Stop avatar that owns object pointing.

llTargetOmega

llTargetOmega(vector axis, float spinrate, float gain);

 

Attempt to spin at spinrate with strength gain.  A gain of 0.0 cancels the spin.

llGetStartParameter

integer llGetStartParameter();

 

Get the start parameter passed to llRezObject.

llRequestPermissions

integer llRequestPermissions(key avatar, integer perm);

 

Ask avatar to allow the script to do perm (NB: Debit, ownership, link, joint, and permission requests can only go to the object's owner).

llGetPermissionsKey

key llGetPermissionsKey()

 

Return avatar that permissions are enabled for.  NULL_KEY if not enabled.

llGetPermissions

integer llGetPermissions();

 

Return what permissions have been enabled.  To use:

 

integer perm = llGetPermissions();

if ((perm & PERMISSION_DEBIT) == PERMISSION_DEBIT)

{

            // code goes here

}

llGetLinkNumber

integer llGetPermissions();

 

Returns what number in a link set the script is attached to (0 means no link, 1 the root, 2 for first child, &c.

llSetLinkColor

llSetLinkColor(integer linknumber, vector color, integer face);

 

Returns what number in a link set the script is attached to (0 means no link, 1 the root, 2 for first child, &c.).  If face == ALL_SIDES, set the color for all faces.  If linknumber == ALL_SIDES, set color on all objects in link set.

llCreateLink

llCreateLink(key target, integer parent);

 

Attempt to link object script is attached to and target (requires permission PERMISSION_CHANGE_LINKS be set). If parent == TRUE, object script is attached to is the root.

llBreakLink

llBreakLink(integer linknum);

 

Delinks the object with the given link number (requires permission PERMISSION_CHANGE_LINKS be set).

llBreakAllLinks

llBreakAllLinks();

 

Delinks all objects in the link set (requires permission PERMISSION_CHANGE_LINKS be set).

llGetLinkKey

key llGetLinkKey(integer linknum);

 

Get the key of linknumber in link set.

llGetLinkName

string llGetLinkName(integer linknum);

 

Get the name of linknumber in link set.

llGetInventoryNumber

integer llGetInventoryNumber(integer type);

 

Get the number of items of type (INVENTORY_TEXTURE, INVENTORY_SOUND, INVENTORY_OBJECT, INVENTORY_SCRIPT, INVENTORY_LANDMARK, INVENTORY_CLOTHING, INVENTORY_NOTECARD, or INVENTORY_BODYPART) in the object's inventory.

llGetInventoryName

string llGetInventoryName(integer type, integer number);

 

Get the name of the inventory item number of type.

llGiveInventory

llGiveInventory(key destination, string inventory);

 

Give the named inventory item to the keyed avatar or object in the same simulator as the giver. If the recipient is an avatar, the avatar then follows the normal procedure of accepting or denying the offer.  If the recipient is an object, the same permissions apply as if you were dragging inventory onto the object by hand, ie if llAllowInventoryDrop(TRUE) has been called on the object, any other object can pass objects to its inventory.

llRemoveInventory

llRemoveInventory(string inventory);

 

Remove the named inventory item from the object inventory.

llSetScriptState

llSetScriptState(string name, integer run);

 

Control the state of a script on the object.

llGetEnergy

float llGetEnergy();

 

Returns how much energy is in the object as a percentage of maximum.

llSetText

llSetText(string text, vector color, float alpha);

 

Set text floating over object.

llSetText

llSetText(string text, vector color, float alpha);

 

Set text floating over object.

llPassTouches

llPassTouches(integer pass);

 

If pass == TRUE, touches are passed from children on to parents.

llPassCollisions

llPassCollisions(integer pass);

 

If pass == TRUE, collisions (both land and object) are passed from children on to parents.

llRequestAgentData

key llRequestAgentData(key id, integer data);

 

Requests data about agent id.  When data is available the dataserver event will be raised.  The only request currently implemented is request 1, which returns a “1” if the agent is online, “0” otherwise.

llRequestInventoryData

key llRequestInventoryData(string name);

 

Requests data from object's inventory object.  When data is available the dataserver event will be raised.  The only request currently implemented is to request data from landmarks, where the data returned is in the form “<float, float, float>” which can be cast to a vector.  This position is in region local coordinates.

llSetDamage

llSetDamage(float damage);

 

Sets the amount of damage that will be done to an object that this object hits.  Object will be killed.

llTeleportAgentHome

llTeleportAgentHome(key id);

 

Teleport agent on the owner's land to agent’s home location.

llModifyLand

llModifyLand(integer action, integer size);

 

Modify land with action (LAND_LEVEL, LAND_RAISE, LAND_LOWER)\non size (LAND_SMALL_BRUSH, LAND_MEDIUM_BRUSH, LAND_LARGE_BRUSH).

llCollisionSound

llCollisionSound(string impact_sound, float impact_volume);

 

Suppress default collision sounds, replace default impact sounds with impact_sound (empty string to just suppress).

llCollisionSprite

llCollisionSprite(string impact_sprite);

 

Suppress default collision sprites, replace default impact sprite with impact_sprite (empty string to just suppress).

llGetAnimation

string llGetAnimation(key id);

 

Get the currently playing animation for avatar id.

llResetScript

llResetScript();

 

Resets the script.

llMessageLinked

llMessageLinked(integer linknum, integer num, string str, key id);

 

Sends num, str, and id to members of the link set(LINK_SET sends to all objects, LINK_ALL_OTHERS to all other objects, LINK_ALL_CHILDREN to all children.

llPushObject

llPushObject (key id, vector impulse, vector ang_impulse, integer local);

 

Applies impulse and angular impulse to object id.

llPassCollisions

llPassCollisions(integer pass);

 

If pass == TRUE, collisions are passed from children on to parents (default is FALSE).

llGetScriptName

llGetScriptName();

 

Returns the script name.

llGetNumberOfSides

integer llGetNumberOfSides();

 

Returns the number of sides.

llAxisAngle2Rot

rotation llAxisAngle2Rot(vector axis, float angle);

 

Returns the rotation generated angle about axis.

llRot2Axis

vector llRot2Axis(rotation rot);

 

Returns the rotation axis represented by rot.

llRot2Angle

float llRot2Angle(rotation rot);

 

Returns the rotation angle represented by rot.

llAcos

float llAcos(float val);

 

Returns the arccosine in radians of val.

llAsin

float llAsin(float val);

 

Returns the arcsine in radians of val.

llAngleBetween

float llAngleBetween(rotation a, rotation b);

 

Returns angle between rotation a and b.

llGetInventoryKey

key llGetInventoryKey(string name);

 

Returns the key of the inventory name.

llAllowInventoryDrop

llAllowInventoryDrop(integer add);

 

If add == TRUE, users without permissions can still drop inventory items onto object.

llGetSunDirection

vector llGetSunDirection();

 

Returns the sun direction on the simulator.

llGetTextureOffset

vector llGetTextureOffset(integer side)

Returns the texture offset of side in the x and y components of a vector.

llGetTextureScale

vector llGetTextureScale(integer side);

Returns the texture scale of side in the x and y components of a vector.

llGetTextureRot

float llGetTextureRot(integer side);

 

Returns the texture rotation of side;

llSubStringIndex

integer llSubStringIndex(string source, string pattern);

Finds index in source where pattern first appears (returns length of source if not found).

llGetOwnerKey

key llGetOwnerKey(key id);

 

Find the owner of id.

llGetCenterOfMass

vector llGetCenterOfMass();

 

Get the object's center of mass.

llListSort

list llListSort(list src, integer stride, integer ascending).

 

Sort the list into blocks of stride in ascending order if ascending == TRUE.  Note that sort only works between same types.

llGetListLength

integer llGetListLength(list src);

 

Get the number of elements in the list.

llList2Integer

integer llList2Integer(list src, integer index);

 

Copy the integer at index in the list.

llList2Float

float llList2Float(list src, integer index);

 

Copy the float at index in the list.

llList2String

string llList2String(list src, integer index);

Copy the string at index in the list.

llList2Key

key llList2Key(list src, integer index);

 

Copy the key at index in the list.

llList2Vector

vector llList2Vector(list src, integer index);

 

Copy the vector at index in the list.

llList2Rot

rotation llList2Rot(list src, integer index);

 

Copy the rotation at index in the list.

llList2List

list llList2List(list src, integer start, integer end);

 

Copy the slice of the list from start to end from the list.  Start and end are inclusive, so 0, length – 1 would copy the entire list and 0,0 would capture the first list entry.  Using negative numbers for start and/or end causes the index to count backwards from the length of the list, so 0,-1 would capture the entire list.  If start is larger than end the list returned is the exclusion of the entries, so 6,4 would give the entire list except for the 5th entry.

llDeleteSubList

list llDeleteSubList(list src, integer start, integer end);

 

Remove the slice from the list and return the remainder.  Start and end are inclusive, so 0, length – 1 would delete the entire list and 0,0 would delete the first list entry.  Using negative numbers for start and/or end causes the index to count backwards from the length of the list, so 0,-1 would delete the entire list.  If start is larger than end the list deleted is the exclusion of the entries, so 6,4 would delete the entire list except for the 5th list entry.

llGetListEntryType

integer llGetListEntryType(list src, integer index)

 

Returns the type of the index entry in the list\n(TYPE_INTEGER, TYPE_FLOAT, TYPE_STRING, TYPE_KEY, TYPE_VECTOR, TYPE_ROTATION, or TYPE_INVALID if index is off list.

llList2CSV

string llList2CSV(list src);

 

Create a string of comma separated values from list.

llCSV2List

list llCSV2List(string src);

 

Create a list from a string of comma separated values.

llListRandomize

list llListRandomize(list src, integer stride);

 

Returns src randomized into of blocks of size stride.

llList2ListStrided

list llList2ListStrided(list src, integer start, integer end, integer stride);

 

Copy the strided slice of the list from start to end.

llListInsertList

list llListInsertList(list dest, list src, integer pos);

 

Returns the list created by inserting src into dest at pos.

llListFindList

integer llListFindList(list src, list test);

 

Returns the position of the first instance of test in src (-1 if test isn’t in src).

llGetObjectName

string llGetObjectName();

 

Returns the name of the object script is attached to.

llSetObjectName

llSetObjectName(string name);

 

Sets the objects name.

llGetDate

string llGetDate();

 

Gets the date as mm/dd/yyyy.

llEdgeOfWorld

integer llEdgeOfWorld(vector pos, vector dir);

 

Returns TRUE if the line along dir from pos hits the edge of the world in the current simulator and returns FALSE if that edge crosses into another simulator.

llGetAgentInfo

integer llGetAgentInfo(key id);

 

Gets information about agent ID.  Returns AGENT_FLYING, AGENT_ATTACHMENTS, and/or AGENT_SCRIPTED.

llKey2Name

string llKey2Name(key id);

 

If object id is in the simulator, return the name of the object.

llEjectFromLand

llEjectFromLand(key pest)

 

Ejects pest from land that you own.

llParseString2List

list llParseString2List(string src, list separators, list spacers)

 

Breaks src into a list, discarding separators, keeping spacers (separators and spacers must be lists of strings, maximum of 8 each).  So, if you had made the call:

 

 llParseString2List(“Parsethisnow!  I dare:you to.”, [“this“, “!”, “ “], [“:”]);

 

You would get the list:

 

[“Parse”, “now”, “I”, “dare”, “:”, “you”, “to”

llOverMyLand

integer llOverMyLand(key id)

 

Returns TRUE if id is over land owner of object owns, FALSE otherwise.

llGetLandOwnerAt

key llGetLandOwnerAt(vector pos)

 

Returns the key of the land owner, NULL_KEY if public.

llGetNotecardLine

key llGetNotecardLine(string name, integer line)

 

Returns line line of notecard name via the database event.  If the requested line is past the end of the notecard the database event will return the constant EOF.

llGetAgentSize

vector llGetAgentSize(key id)

 

If the agent is in the same sim as the object, returns the size of the avatar.

llSameGroup

integer llSameGroup(key id)

 

Returns TRUE if ID is in the same sim and has the same active group, otherwise FALSE.

llUnSit

llUnSit(key id)

 

lIf agent identified by id is sitting on the object the script is attached to or is over land owned by the objects owner, the agent is forced to stand up.

llGroundSlope

llGroundSlope(vector v)

 

Returns the ground slope below the object position + v.

llGroundNormal

llGroundNormal(vector v)

 

Returns the ground normal below the object position + v.

llGroundContour

llGroundContour(vector v)

 

Returns the ground contour below the object position + v.

.