Quick Reference Guide to LSL
(Barely begun. All of this info may be found elsewhere in more complete form.)
Operators
Operation (Listed by order of execution) | Description |
() [] . | Parentheses, Square Brackets and Dot Operator |
! ~ ++ -- | NOT, One's Compliment, Increment, Decrement |
* / % | Multiply, Divide, Modulus |
+ - | Addition and Subtraction |
<< >> | Left Shift, Right Shift |
< <= > >= | Less Than, Less Than Or Equal To, Greater Than, Greater Than or Equal To |
== != | Comparison Equal, Comparison Not Equal |
& | Bitwise AND |
^ | Bitwise XOR |
| | Bitwise OR |
&& | Comparison AND |
|| | Comparison OR |
= += -= *= /= %= | Value functions |
Flow Control
if (condition) { statements } else { statements }
while (condition) { statements }
do (condition) while { statements }
for (initialization; test; update) { statements }
jump label; ... @label
return simple-value // from function or event handler
state name { ... } // define the named state handler
state name; // change to named state
UserDefinedFunctions:
type functionName(type parameter1, type parameter2, ... type parameterN) { statements }
Types
float, integer, key, list, rotation, string, vector
Variables
Declaration:
or
Constants
PI TWO_PI PI_BY_TWO (pi / 2)
DEG_TO_RAD RAD_TO_DEG SQRT2 (square root of 2)
TRUE FALSE
NULL_KEY (empty
key, sometimes treated as string)
EOF (returned in the
dataserver event for last line of
notecard)
ZERO_ROTATION (<0,0,0,1>)
ZERO_VECTOR (<0,0,0>)
Object Types
States
Events
LSL is an
event-driven language.
Scripts can provide
event-handlers, like
moving_end or
touch_start. If a script provides a handler for an
event, and an
event of this type occurs, the
simulator will add this
event to the script's
event queue. The script's
event handlers will then be called in the order the
events are queued in (
FIFO). According to Cory
Linden, the
event queue can hold up to 64
events.
Changing
states clears the
event queue.
Different states can have different
event handlers. Be wary of
bugs though.
The
function llMinEventDelay may be of some use in coordinating
events.
LSL
events in alphabetical order:
Built-in Functions
-
Agent/Avatar
A
user's presence in Second Life is represented by two entities: an
agent, which is a
client's presence within a
simulator, and an
avatar, which is the visual representation of an
agent that people see and interact with.
-- Agent Functions:
llAddToLandPassList (key agent, float hours) | Adds agent to the land pass list for the specified number of hours. |
llEjectFromLand (key pest) | Ejects pest from land that you own. |
integer llGiveMoney (key destination, integer amount) | Transfer amount of Linden Dollars from script owner to destination. Requires PERMISSION_DEBIT |
llInstantMessage (key user, string message) | Sends an IM to user containing message. |
llRequestAgentData (key id, integer data) | This function requests information of type data (DATA_ONLINE, DATA_NAME, DATA_BORN, DATA_RATING) about agent id. |
integer (key id) | Returns TRUE if the agent/object associated with id has the same active group (and is currently in the same simulator) as the object the script is attached to. FALSE otherwise. |
llSetSitText (string text) | Replaces "Sit Here" in the object's PieMenu with text. |
llSetTouchText (string text) | Replaces "Touch" in the object's PieMenu with text. |
llTeleportAgentHome (key id) | If the scripted object is over owner's land, teleports agent id immediately to that agent's home location, with no confirmation. |
-- Agent Events:
dataserver Triggered by llRequestAgentData.
money Triggered by paying an object.
-- Agent & Avatar Functions:
llAvatarOnSitTarget
llGetAgentInfo
llGetPermissions
llGetPermissionsKey
llKey2Name
llReleaseControls
llRequestPermissions
llSetCameraAtOffset
llSetCameraEyeOffset
llSitTarget
llTakeControls
llUnSit
-- Agent & Avatar Events:
control
run_time_permissions
changed Triggered by sit.
-- Avatar Functions:
llAttachToAvatar
llDetachFromAvatar
llGetAgentSize
llGetAnimation
llGetAnimationList
llGetAttached
llPointAt
llStartAnimation
llStopAnimation
llStopPointAt
-- Avatar Events:
attach
-
Communications
-
Collisions
-
Dataserver
-
Detection
-
Dynamics (movement/physics)
-
Inventory
-
Links
Up to 255
prims can be linked into a single
object. One is the
parent and the rest are
children.
Events
Constants
(Used by the functions
llMessageLinked,
llSetLinkAlpha, and
llSetLinkColor.)
Constant | Value | Description |
LINK_ROOT | 1 | Modifies the root prim in an (but not in a single prim, which is 0) |
LINK_SET | -1 | Modifies all prims in the object. |
LINK_ALL_OTHERS | -2 | Modifies all other prims in the object besides the prim the function is in. |
LINK_ALL_CHILDREN | -3 | Modifies all child prims in the object. |
LINK_THIS | -4 | Modifies the prim the script is in. |
-
Lists
-
Math
-
Particles
-
Primitives
-
Sensors
-
Sounds
-
Strings
-
Targets
-
Textures
-
Time
-
Transformation:
Rotation/
Scaling/
Translation
-
Vehicles
-
World