Don't click here unless you want to be banned.

LSL Wiki : QuickReferenceGuide

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl435.us.archive.org

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:
type name;
or
type name = value;


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
AGENT 1
ACTIVE 2
PASSIVE 4
SCRIPTED 8

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:

Event: Triggered:
at_rot_target when a rotational target set with llRotTarget is reached
at_target when a target set with llTarget is reached
attach when an object attaches or detaches from agent
changed when certain aspects of the object are changed (inventory, color, shape, scale, texture, link)
collision while task is colliding with another task
collision_end when task stops colliding with another task or stops being penetrated while llVolumeDetect is set
collision_start when task starts colliding with another task or starts being penetrated while llVolumeDetect is set
control when one of the controls taken with llTakeControls is pressed/held/released
dataserver when task receives asynchronous data
email when task receives email
land_collision when task is colliding with land
land_collision_end when task stops colliding with land
land_collision_start when task starts colliding with land
link_message when task receives a link message sent via llMessageLinked
listen when task is within hearing range of chat matching the critera set in llListen
money when money is given to task
moving_end when task stops moving
moving_start when task begins moving
no_sensor when llSensor or llSensorRepeat results in no targets sensed
not_at_rot_target when a rotational target set with llRotTarget is not yet reached
not_at_target when a target set with llTarget is not yet reached
object_rez when task rezzes in another task using llRezObject
on_rez when task is rezzed (from inventory or another task)
remote_data any kind of XML-RPC communication (New in 1.3)
run_time_permissions when an agent grants run-time permissions to task that were requested via llRequestPermissions
sensor Result of llSensor or llSensorRepeat functions
state_entry on any transition into the state and on startup
state_exit on any state transition out of the state
timer in intervals set by llSetTimerEvent
touch while agent is clicking on task
touch_end when agent stops clicking on task
touch_start when agent first clicks on task


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.

llBreakLink (integer linknum) Delinks the object with the given linknumber linknum (requires permission PERMISSION_CHANGE_LINKS be set).
llBreakAllLinks () Delinks all objects in the link set (requires permission PERMISSION_CHANGE_LINKS be set)
llCreateLink(key target, integer parent) Attempts to link the object containing the script and target (requires that permission PERMISSION_CHANGE_LINKS be set).
llDetectedLinkNumber
llGetLinkKey
llGetLinkName
integer llGetLinkNumber() Returns what number in a link set the script is attached to (0 means no link, 1 the root/parent, 2 for first child, etc).
llGetNumberOfPrims
llMessageLinked
llPassCollisions
llPassTouches
llSetLinkAlpha
llSetLinkColor

Events

link_message

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
There is no comment on this page. [Display comments/form]