Copyright © 2007 Linden Lab
The Linden Scripting Language (LSL) is a simple, powerful language used to attach behaviors to the objects found in Second Life. It follows the familiar syntax of a c/Java style language, with an implicit state machine for every script.
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.
This tutorial introduces the reader to the basic features of LSL, how to edit and apply your scripts, and a complete reference for standard linden constants, events, and library functions.
You're probably wondering what you can do with LSL, and how quickly you can do it. We'll start with some simple examples, dissect them, and introduce you the script development process while we're at it.
Continuing a long tradition of getting started by looking at a script that says "Hello", we'll do just that. Though obviously not a particularly useful example on it's own, this example will introduce us to:
Creating a basic script
Script states
Calling functions
Script events
Applying a script to an object
Start by opening your inventory and selecting 'Create|New Script' from the inventory pull down menu. This will create an empty script called 'New Script' in your 'Scripts' folder. Double click on the text or icon of the script to open the script in the built in editor. When you open the script, the viewer will automatically insert a basic skeleton for lsl. It should look like:
default { state_entry() { llSay(0, "Hello, Avatar!"); } touch_start(integer total_number) { llSay(0, "Touched."); } }
A casual inspection of this script reveals that this script probably says 'Hello, Avatar!' when it enters some state, and it says 'Touched.' when it is touched. But since this is also probably the first time you have seen a script we'll dissect this short listing, explaining each segment individually.
All LSL scripts have a simple implicit state machine with one or more states. All scripts must have a default state, so if there is only one state, it will be the 'default' state. When a script is first started or reset, it will start out in the default state.
The default state is declared by placing the default at the root level of the document, and marking the beginning with an open brace '{' and ending with a close brace '}'. Because of it's privileged status, you do not declare that it is fact a state like you normally would with other states.
Every time you enter a state, the script engine will automatically call the state_entry() event and execute the code found there. On state exit, the script engine will automatically call the state_exit() event before calling the next state's state_entry handler. In our example, we call the llSay() function in state_entry() and do not bother to define a state_exit() handler. the state entry and exit handlers are a convenient place to initialize state data and clean up state specific data such as listen event callback.
You can read more about the default state, and how to create and utilize other states in the states chapter.
The language comes with well over 200 built in functions which allow scripts and objects to interact with their environment. All of the built in functions start with 'll'.
The example calls the llSay() function twice, which is used to emit text on the specified channel.
Say text on channel. Channel 0 is the public chat channel that all avatars see as chat text. Channels 1 to 2,147,483,648 are private channels that aren't sent to avatars but other scripts can listen for.
You can define your own functions as long as the name does not conflict with a reserved word, built in constant, or built in function.
There are many events that can be detected in your scripts by declaring a handler. The touch_start() event is raised when a user touches the object through the user interface.
Now that we have seen the default script, and examined it in some detail, it is time to see the script in action. Save the script by clicking on
. During the save process, the editor will save the text of the script and compile the script into bytecode and then save that. When you see message 'Compile successful!' in the preview window, you know the compile and save is done.To test the script you will have to apply it to an object in the world. Create a new object in the world by
in the main world view and selecting . When the wand appears, you can create a simple primitive by in the world. Once the object appears, you can drag your newly created script onto the object to start the script.Soon after dragging the script onto the object, you will see the message Object: Hello Avatar!
Make sure the touch event is working by
on the object. You should see the message Touched printed into the chat history.The built in editor comes with most of the typical features you would expect from a basic text editor. Highlight text with the mouse, or by holding down the shift key while using the arrow keys. You can cut, copy, paste, and delete your selection using the 'Edit' pull down menu or by pressing the usual shortcut key.
Since the built-in editor supports pasting text from the clipboard, you can employ a different editor to edit your scripts, copying them into Second Life when you're ready to save them.
Now that we have seen a very simple script in action, we need to look at the our toolchest for writing scripts. The next set of tools we will consider are the basic building blocks for programming a script, and will be used in every non-trivial script you write.
Commenting your scripts is a good idea, and will help when you update and modify the script, or when you adapt parts of it into other scripts. Unless the meaning is obvious, you should add comments:
at the start of the script to explain the purpose of the script
before every global variable to describe what it holds
before every global function to describe what it does
sprinkled through your script wherever the code solves a problem that took you more than a few minutes to figure out.
LSL uses Java/C++ style single line comments.
// This script toggles a the rotation of an object // g_is_rotating stores the current state of the rotation. TRUE is // rotating, FALSE otherwise. integer g_is_rotating = FALSE; default { // toggle state during the touch handler touch(integer num) { if(g_is_rotating) { // turn off rotation llTargetOmega(<0,0,1>, 0, 0); g_is_rotating = FALSE; } else { // rotate around the positive z axis - up. llTargetOmega(<0,0,1>, 4, 1); g_is_rotating = TRUE; } } }
Most of the common arithmetic operations are supported in lsl, and follow the C/Java syntax.
The most common arithmetic operation is assignment, denoted with the '=' sign. Loosely translated, it means, take what you find on the right hand side of the equal sign and assign it to the left hand side. Any expression that evaluates to a basic type can be used as the right hand side of an assignment, but the left hand side must be a normal variable.
All basic types support assignment '=', equality '==' and inequality '!=' operators.
// variables to hold a information about the target key g_target; vector g_target_postion; float g_target_distance; // function that demonstrates assignment set_globals(key target, vector pos) { g_target = target; g_target_position = pos; // assignment from the return value of a function vector my_pos = llGetPos(); g_target_distance = llVecDist(g_target_position, my_pos); }
Binary arithmetic operators behave like a function call that accepts two parameters of the same type, and then return that type; however, the syntax is slightly different.
Table 3-1. Binary Arithmetic Operators
Operator | Meaning |
---|---|
+ | Addition |
- | Subtraction |
* | Multiplication |
/ | Division |
% | Modulo (remainder) |
^ | Exclusive OR |
<< | Shift Left |
>> | Shift Right |
Where noted, each type may have a special interpretation of a binary arithmetic operator. See the lsl types section for more details.
Table 3-2. Boolean Operators
Operator | Meaning |
---|---|
< | Operator returns TRUE if the left hand side is less than the right hand side. |
> | Operator returns TRUE if the left hand side is greater than the right hand side. |
<= | Operator returns TRUE if the left hand side is less than or equal to the right hand side. |
>= | Operator returns TRUE if the left hand side is greater than or equal to the right hand side. |
&& | Operator returns TRUE if the left hand side and right hand side are both true. |
|| | Operator returns TRUE if either the left hand or right hand side are true. |
! | Unary operator returns the logical negation of the expression to the right. |
Variables, return values, and parameters have type information. LSL provides a small set of basic types that are used throughout the language.
LSL Types
A signed, 32-bit integer value with valid range from -2147483648 to 2147483647.
An IEEE 32-bit floating point value with values ranging from 1.175494351E-38 to 3.402823466E+38.
A unique identifier that can be used to reference objects and agents in Second Life.
3 floats that are used together as a single item. A vector can be used to represent a 3 dimensional position, direction, velocity, force, impulse, or a color. Each component can be accessed via '.x', '.y', and '.z'.
4 floats that are used together as a single item to represent a rotation. This data is interpreted as a quaternion. Each component can be accessed via '.x', '.y', '.z', and '.s'.
A heterogeneous list of the other data types. Lists are created via comma separated values of the other data types enclosed by '[' and ']'.
Yields the list: [ 1234, <0,0,0,1>, "Hello, Carbon Unit" ]Lists can be combined with other lists. For example:
Yields the list: [ 3.14159, 1234, <0,0,0,1>, "Hello, Carbon Unit" ] And similarly, Yields: [ 3.14159, 1234, <0,0,0,1>, "Hello, Carbon Unit", 3.14159, 1234, <0,0,0,1>, "Hello, Carbon Unit" ]Library functions exist used to copy data from lists, sort lists, copy/remove sublists.
Type conversion can either occur implicitly or explicitly. Explicit type casts are accomplished using C syntax:
LSL only supports two implicit type casts: integer to float and string to key. Thus, any place you see a float specified you can supply an integer, and any place you see a key specified, you can supply a string.
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
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:
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:
Global variables may also be initialized if desired, although uninitialized global and local variables are initialized to legal zero values:
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 } }
LSL comes with a complete complement of constructs meant to deal with conditional processing, looping, as well as simply jumping to a different point in the script.
The 'if' statement operates and has the same syntax as the Java/C version.
check_message(string message) { if(message == "open") { open(); } else if(message == "close") { close(); } else { llSay(0, "Unknown command: " + message); } }
The statements between the open and close curly brace are performed if the conditional inside the parentheses evaluates to a non-zero integer. Once a conditional is determined to be true (non-zero), no further processing of 'else' conditionals will be considered. The NULL_KEY constant is counted as FALSE by conditional expressions.
There can be zero or more 'else if' statements, and an optional final 'else' to handle the case when none of the if statements evaluate to a non-zero integer.
The usual set of integer arithmetic and comparison operators are available.
// a function that accepts some information about its environment and // determines the 'best' next step. This kind of code might be // part of a simple box meant to move close to an agent and attach to // them once near. This code sample relies on the standard linden // library functions as well as two other methods not defined here. assess_next_step(integer perm, integer attached, integer balance, float dist) { string msg; if(!attached) { if((perm & PERMISSION_ATTACH) && (dist < 10.0)) { attach(); } else if((dist > 10.0) || ((dist > 20.0) && (balance > 1000))) { move_closer(); } else { llRequestPermissions(llGetOwner(), PERMISSION_ATTACH); } } }
Loops are a basic building block of most useful programming languages, and LSL offers the same loop constructs as found in Java or C.
A for loop is most useful for when you know how many times you need to iterate over an operation. Just like a Java or C for loop, the parentheses have three parts, the initializer, the continuation condition, and the increment. The loop continues while the middle term evaluates to true, and the increment step is performed at the end of every loop.
// move a non-physical block smoothly upward (positive z) the total // distance specified divided into steps discrete moves. move_up(float distance, integer steps) { float step_distance = distance / (float)steps; vector offset = <0.0, 0.0, step_distance>; vector base_pos = llGetPos(); integer i; for(i = 0; i <= steps; ++i) { llSetPos(base_pos + i * offset); llSleep(0.1); } }
The do-while loop construct is most useful when you are sure that you want to perform an operation at least once, but you are not sure how many times you want to loop. The syntax is the same as you would find in a Java or C program. A simple English translation would be 'do the code inside the curly braces and continue doing it if the statement after the while is true.
// output the name of all inventory items attached to this object talk_about_inventory(integer type) { string name; integer i = 0; integer continue = TRUE; do { name = llGetInventoryName(type, i); if(llStringLength(name) > 0) { llSay(0, "Inventory " + (string)i + ": " + name); } else { llSay(0, "No more inventory items"); continue = FALSE; } i++; } while(continue); }
The while loop behaves similarly to the do-while loop, except it allows you to exit the loop without doing a single iteration inside.
A jump is used to move the running script to a new point inside of a function or event handler. You cannot jump into other functions or event handlers. Usually, you will want to use a jump for in situations where the if..else statements would become too cumbersome. For example, you may want to check several preconditions, and exit if any of them are not met.
attach_if_ready(vector target_pos) { // make sure we have permission integer perm = llGetPerm(); if(!(perm & PERMISSION_ATTACH)) { jump early_exit; } // make sure we're 10 or less meters away vector pos = llGetPos() float dist = llVecDist(pos, target_pos); if(dist > 10.0) { jump early_exit; } // make sure we're roughly pointed toward the target. // the calculation of max_cos_theta could be precomputed // as a constant, but is manually computed here to // illustrate the math. float max_cos_theta = llCos(PI / 4.0); vector toward_target = llVecNorm(target_pos - pos); rotation rot = llGetRot(); vector fwd = llRot2Fwd(rot); float cos_theta = toward_target * fwd; if(cos_theta > max_cos_theta) { jump early_exit; } // at this point, we've done all the checks. attach(); @early_exit; }
State change allow you to move through the lsl virtual machine's flexible state machine by transitioning your script to and from user defined states and the default state. You can define your own script state by placing the keyword 'state' before its name and enclosing the event handlers with open and close curly braces ('{' and '}'.) You can invoke the transition to a new state by calling it with the syntax: 'state <statename>'.
default { state_entry() { llSay(0, "I am in the default state"); llSetTimer(1.0); } timer() { state SpinState; } } state SpinState { state_entry() { llSay(0, "I am in SpinState!"); llTargetOmega(<0,0,1>, 4, 1.0); llSetTimer(2.0); } timer() { state default; } state_exit() { llTargetOmega(<0,0,1>, 0, 0.0); } }
All scripts must have a 'default' state, which is the first state entered when the script starts. States contain event handlers that are triggered by the LSL virtual machine. All states must supply at least one event handler - it's not really a state without one.
When state changes, all callback settings are retained and all pending events are cleared.
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 this event handler.
You will usually want to set callbacks for things such as timers and sensor in the state_entry() callback of the state to put your object into a useful condition for that state.
Warning: It is a common mistake to assume that the state_entry() callback is called when you rez an object out of your inventory. When you derez an object into your inventory the current state of the script is saved, so there will not be a call to state_entry() during the rez. If you need to provide startup code every time an object is created, you should create a global function and call it from both state_entry() and the on_rez() callbacks.
// global initialization function. init() { // Set up a listen callback for whoever owns this object. key owner = llGetOwner(); llListen(0, "", owner, ""); } default { state_entry() { init(); } on_rez(integer start_param) { init(); } listen(integer channel, string name, key id, string message) { llSay(0, "Hi " + name + "! You own me."); } }
You will want to provide a state_exit() if you need to clean up any events that you have requested in the current state, but do not expect in the next state.
default { state_entry() { state TimerState; } } state TimerState { state_entry() { // set a timer event for 5 seconds in the future. llSetTimerEvent(5.0); } timer() { llSay(0, "timer"); state ListenState; } state_exit() { // turn off future timer events. llSetTimerEvent(0.0); } } integer g_listen_control; state ListenState { state_entry() { // listen for anything on the public channel g_listen_control = llListen(0, "", NULL_KEY, ""); } listen(integer channel, string name, key id, string message) { llSay(0, "listen"); state TimerState; } state_exit() { // turn off the listener llListenRemove(g_listen_control); } }
The state_exit() handler is not called when an object is being deleted - all callbacks, handlers, sounds, etc, will be cleaned up automatically for you.
A state and a set of global variables can serve the same purpose, and each can be expressed in terms of the other. In general, you should prefer the use of states over global variables since states allow you to immediately assume script state without making comparisons. The less comparisons a script makes, the more regular code statements it can run.
Table 6-1. Trigonometry Functions
Function |
---|
llAbs |
llAcos |
llAsin |
llAtan2 |
llCeil |
llCos |
llFabs |
llFloor |
llFrand |
llPow |
llRound |
llSin |
llSqrt |
llTan |
Table 6-3. Rotation Functions
Function |
---|
llAngleBetween |
llAxes2Rot |
llAxisAngle2Rot |
llEuler2Rot |
llRot2Angle |
llRot2Axis |
llRot2Euler |
llRot2Fwd |
llRot2Left |
llRot2Up |
llRotBetween |
Custom Vehicles can be constructed and controlled using the LSL. This chapter will cover the basics of how vehicles work, the terms used when describing vehicles, and a more thorough examination of the api available.
There are several ways to make scripted objects move themselves around. One way is to turn the object into a "vehicle". This feature is versatile enough to make things that slide, hover, fly, and float. Some of the behaviors that can be enabled are:
deflection of linear and angular velocity to preferred axis of motion
hovering over terrain/water or at a global height
banking on turns
linear and angular motor for push and turning
Each scripted object can have one vehicle behavior that is configurable through the llSetVehicleType, llSetVehicleFloatParam, llSetVehicleVectorParam, llSetVehicleRotationParam, llSetVehicleFlags, and llRemoveVehicleFlags library calls.
These script calls are described in more detail below, but the important thing to notice here is that the vehicle behavior has several parameters that can be adjusted to change how the vehicle handles. Depending on the values chosen the vehicle can veer like a boat in water, or ride like a sled on rails.
Setting the vehicle flags allow you to make exceptions to some default behaviors. Some of these flags only have an effect when certain behaviors are enabled. For example, the VEHICLE_FLAG_HOVER_WATER_ONLY will make the vehicle ignore the height of the terrain, however it only makes a difference if the vehicle is hovering.
Vehicles are a work in progress and will likely experience changes in future versions of Second Life. Some of the details of vehicle behavior may be changed as necessary to ensure stability and user safety. In particular, many of the limits and defaults described in the appendices will probably change and should not be relied upon in the long term.
It is not recommended that you mix vehicle behavior with some of the other script calls that provide impulse and forces to the object, especially llSetBuoyancy, llSetForce, llSetTorque, and llSetHoverHeight.
While the following methods probably don't cause any instabilities, their behavior may conflict with vehicles and cause undesired and/or inconsistent results, so use llLookAt, llRotLookAt, llMoveToTarget, and llTargetOmega at your own risk.
If you think you have found a bug relating to how vehicle's work, one way to submit the problem is to give a copy of the vehicle and script to Andrew Linden with comments or a notecard describing the problem. Please name all submissions "Bugged Vehicle XX" where XX are your Second Life initials. The vehicle and script will be examined at the earliest convenience.
The terms "roll", "pitch", and "yaw" are often used to describe the modes of rotations that can happen to a airplane or boat. They correspond to rotations about the local x-, y-, and z-axis respectively.
z-axis . yaw-axis /|\ | __. y-axis ._ ___| /| pitch-axis _||\ \\ |\. / \|| \_______\_|__\_/_______ | _ _ o o o o o o o |\_ ______\ x-axis // ./_______,----,__________) / roll-axis /_,/ // ./ /__,/
The right-hand-rule, often introduced in beginning physics courses, is used to define the direction of positive rotation about any axis. As an example of how to use the right hand rule, consider a positive rotation about the roll axis. To help visualize how such a rotation would move the airplane, place your right thumb parallel to the plane's roll-axis such that the thumb points in the positive x-direction, then curl the four fingers into a fist. Your fingers will be pointing in the direction that the plane will spin.
.-.--.--.--. __ / / / / _ \ / \ (-(- (- (- ( | _________|______\ axis of \.\._\._\._) | | / rotation | \:__,---. \|/ | | + positive \ .,_.___.' rotation \_ ^ `.__,/ | / | |
Many of the parameters that control a vehicle's behavior are of the form: VEHICLE_BEHAVIOR_TIMESCALE. A behavior's "timescale" can usually be understood as the time for the behavior to push, twist, or otherwise affect the vehicle such that the difference between what it is doing, and what it is supposed to be doing, has been reduced to 1/e of what it was, where "e" is the natural exponent (approximately 2.718281828). In other words, it is the timescale for exponential decay toward full compliance to the desired behavior. When you want the vehicle to be very responsive use a short timescale of one second or less, and if you want to disable a behavior then set the timescale to a very large number like 300 (5 minutes) or more. Note, for stability reasons, there is usually a limit to how small a timescale is allowed to be, and is usually on the order of a tenth of a second. Setting a timescale to zero is safe and is always equivalent to setting it to its minimum. Any feature with a timescale can be effectively disabled by setting the timescale so large that it would take them all day to have any effect.
Before any vehicle parameters can be set the vehicle behavior must first be enabled. It is enabled by calling llSetVehicleType with any VEHICLE_TYPE_*, except VEHICLE_TYPE_NONE which will disable the vehicle. See the vehicle type constants section for currently available types. More types will be available soon.
Setting the vehicle type is necessary for enabling the vehicle behavior and sets all of the parameters to its default values. For each vehicle type listed we provide the corresponding equivalent code in long format. Is is important to realize that the defaults are not the optimal settings for any of these vehicle types and that they will definitely be changed in the future. Do not rely on these values to be constant until specified.
Should you want to make a unique or experimental vehicle you will still have to enable the vehicle behavior with one of the default types first, after which you will be able to change any of the parameters or flags within the allowed ranges.
Setting the vehicle type does not automatically take controls or otherwise move the object. However should you enable the vehicle behavior while the object is free to move and parked on a hill then it may start to slide away.
We're looking for new and better default vehicle types. If you think you've found a set of parameters that make a better car, boat, or any other default type of vehicle then you may submit your proposed list of settings to Andrew Linden via a script or notecard.
A common feature of real vehicles is their tendency to move along "preferred axes of motion". That is, due to their wheels, wings, shape, or method of propulsion they tend to push or redirect themselves along axes that are static in the vehicle's local frame. This general feature defines a class of vehicles and included in this category a common dart is a "vehicle": it has fins in the back such that if it were to tumble in the air it would eventually align itself to move point-forward -- we'll call this alignment effect angular deflection.
A wheeled craft exhibits a different effect: when a skateboard is pushed in some direction it will tend to redirect the resultant motion along that which it is free to roll -- we'll call this effect linear deflection.
So a typical Second Life vehicle is an object that exhibits linear and/or angular deflection along the "preferential axes of motion". The default preferential axes of motion are the local x- (at), y- (left), and z- (up) axes of the local frame of the vehicle's root primitive. The deflection behaviors relate to the x-axis (at): linear deflection will tend to rotate its velocity until it points along it's positive local x-axis while the angular deflection will tend to reorient the vehicle such that it's x-axis points in the direction that it is moving. The other axes are relevant to vehicle behaviors that are described later, such as the vertical attractor which tries to keep a vehicle's local z-axis pointed toward the world z-axis (up). The vehicle axes can be rotated relative to the object's actual local axes by using the VEHICLE_REFERENCE_FRAME parameter, however that is an advanced feature and is covered in detail in a later section of these documents.
Depending on the vehicle it might be desirable to have lots of linear and/or angular deflection or not. The speed of the deflections are controlled by setting the relevant parameters using the llSetVehicleFloatParam script call. Each variety of deflection has a "timescale" parameter that determines how quickly a full deflection happens. Basically the timescale it the time coefficient for exponential decay toward full deflection. So, a vehicle that deflects quickly should have a small timescale. For instance, a typical dart might have a angular deflection timescale of a couple of seconds but a linear deflection of several seconds; it will tend to reorient itself before it changes direction. To set the deflection timescales of a dart you might use the lines below:
llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 2.0); llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 6.0);
Each variety of deflection has an "efficiency" parameter that is a slider between 0.0 and 1.0. Unlike the other efficiency parameters of other vehicle behaviors, the deflection efficiencies do not slide between "bouncy" and "damped", but instead slide from "no deflection whatsoever" (0.0) to "maximum deflection" (1.0). That is, they behave much like the deflection timescales, however they are normalized to the range between 0.0 and 1.0.
Once enabled, a vehicle can be pushed and rotated by external forces and/or from script calls such as llApplyImpulse, however linear and angular motors have been built in to make motion smoother and easier to control. Their directions can be set using the llSetVehicleVectorParam call. For example, to make the vehicle try to move at 5 meters/second along its local x-axis (the default look-at direction) you would put the following line in your script:
The motor strength is not the full story, since you can also control how fast the motor engages (VEHICLE_LINEAR_MOTOR_TIMESCALE) and there is a parameter that causes the motor's effectiveness to decay over time (VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE).
Steering the vehicle involves setting the VEHICLE_ANGULAR_MOTOR_DIRECTION and related parameters. It is also possible to set some flags that allow the angular motor slave to your camera view when in mouselook.
For more details about the vehicle motors read the sections on the linear and angular motors below.
The parameters that control the linear motor are:
VEHICLE_LINEAR_MOTOR_DIRECTION
A vector. It is the velocity (meters/sec) that the vehicle will try to attain. It points in the vehicle's local frame, and has a maximum length of 40.
VEHICLE_LINEAR_MOTOR_OFFSET
A vector. It is the offset point from the vehicle's center of mass at which the linear motor's impulse is applied. This allows the linear motor to also cause rotational torque. It is in the vehicle's local frame and its maximum length is 100 meters! No need to worry about stability -- if the vehicle starts to spin too fast (greater than about 4*PI radians per second) then angular velocity damping will kick in. The reason the offset is allowed to be so large is so that it can compete with the other vehicle behaviors such as angular deflection and the vertical attractor. Some of the other vehicle behaviors may drastically reduce the effective torque from the linear motor offset, in which case a longer leverage arm may help.
VEHICLE_LINEAR_MOTOR_TIMESCALE
A float. Determines how long it takes for the motor to push the vehicle to full speed. Its minimum value is approximately 0.06 seconds.
VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE
A float. The effectiveness of the motor will exponentially decay over this timescale, but the effectiveness will be reset whenever the motor's value is explicitly set. The maximum value of this decay timescale is 120 seconds, and this timescale is always in effect.
The flags that affect the linear motor are:
VEHICLE_FLAG_LIMIT_MOTOR_UP
Useful for "ground vehicles". Setting this flag will clamp the z-component of the linear motor (in world frame) to prevent it from defeating gravity.
Setting the motor speed is not enough to enable all interesting vehicles. For example, some will want a car that immediately gets up to the speed they want, while others will want a boat that slowly climbs up to its maximum velocity. To control this effect the VEHICLE_LINEAR_MOTOR_TIMESCALE parameter can be used. Basically the "timescale" of a motor is the time constant for the vehicle to exponentially accelerate toward its full speed.
What would happen if you were to accidentally set the vehicle's linear velocity to maximum possible speed and then let go? It would run away and never stop, right? Not necessarily: an automatic "motor decay" has been built in such that all motors will gradually decrease their effectiveness after being set.
Each time the linear motor's vector is set its "grip" immediately starts to decay exponentially with a timescale determined by the VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, such that after enough time the motor ceases to have any effect. This decay timescale serves two purposes. First, since it cannot be set longer than 120 seconds, and is always enabled it guarantees that a vehicle will not push itself about forever in the absence of active control (from keyboard commands or some logic loop in the script). Second, it can be used to push some vehicles around using a simple impulse model. That is, rather than setting the motor "on" or "off" depending on whether a particular key is pressed "down" or "up" the decay timescale can be set short and the motor can be set "on" whenever the key transitions from "up" to "down" and allowed to automatically decay.
Since the motor's effectiveness is reset whenever the motor's vector is set, then setting it to a vector of length zero is different from allowing it to decay completely. The first case will cause the vehicle to try to reach zero velocity, while the second will leave the motor impotent.
The two motor timescales have very similar names, but have different effects, so try not to get them confused. VEHICLE_LINEAR_MOTOR_TIMESCALE is the time for motor to "win", and VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE is the time for the motor's "effectiveness" to decay toward zero. If you set one when you think you are changing the other you will have frustrating results. Also, if the motor's decay timescale is shorter than the regular timescale, then the effective magnitude of the motor vector will be diminished.
The parameters that control the angular motor are:
VEHICLE_ANGULAR_MOTOR_DIRECTION
A vector. It is the angular velocity (radians/sec) that the vehicle will try to rotate. It points in the vehicle's local frame, and has a maximum value of 4*PI (two revolutions per second).
VEHICLE_ANGULAR_MOTOR_TIMESCALE
A float. Determines how long it takes for the motor to spin the vehicle to full speed. Its minimum value is approximately 0.06 seconds.
VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE
A float. The effectiveness of the motor will exponentially decay over this timescale, but the effectiveness will be reset whenever the motor's value is explicitly set. The maximum value of this decay timescale is 120 seconds, and this timescale is always in effect.
Like the linear motor the angular motor can be set explicitly, and has magnitude/direction, a timescale, and a decay timescale.
When it comes to actually steering a vehicle there are several ways to do it. One way would be for the script to grab keyboard input and to explicitly turn the motor on/off based on which keys are pressed. When steering this way you probably don't want it to turn very far or for very long. One way to do it using the angular motor would be to leave the decay timescale long, enable a significant amount of angular friction (to quickly slow the vehicle down when the motor is turned off) then set the angular motor to a large vector on a key press, and set it to zero when the key is released. That has the effect of making the vehicle unresponsive to external collisions, due to the angular friction.
Another way to do it is to set the VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE to a short value and push the vehicle about with a more impulsive method that sets the motor fast on a key press down (and optionally setting the motor to zero on a key up) relying on the automatic exponential decay of the motor's effectiveness rather than a constant angular friction.
Finally, it may be possible to discard the angular motor entirely and use the VEHICLE_LINEAR_MOTOR_OFFSET. Whenever the offset has a component that is perpendicular to the direction of the linear motor the vehicle will rotate as it travels. Note, with the incorrect values for offset and strength the linear motor effect can easily cause the vehicle to tumble and spin uncontrollably, so experiement with small offsets first!.
Setting the angular motor to zero magnitude is different from allowing it to decay. When the motor completely decays it no longer affects the motion of the vehicle, however setting it to zero will reset the "grip" of the vehicle and will make the vehicle try to achieve zero angular velocity.
Many real vehicles bank (roll about their forward axis) to effect a turn, such as motorcycles and airplanes. To make it easier to build banking vehicles there is banking behavior available which can be controlled by setting other parameters and is described in more detail here.
It is also possible to make a vehicle turn in response to changing the camera view (right now this only works in mouselook).
The vehicle can be instructed to rotate its forward axis to point in the same direction as the camera view. This is achieved by setting some flags that change how the VEHICLE_ANGULAR_MOTOR_DIRECTION is interpreted. When used properly this feature has the advantage of being able to provide simple and stable steering that is resilient to bad render frame rates on the client.
The flags that affect the angular motor are:
VEHICLE_FLAG_MOUSELOOK_STEER
Steer the vehicle using the mouse. Use this flag to make the angular motor try to make the vehicle turn such that its local x-axis points in the same direction as the client-side camera.
VEHICLE_FLAG_MOUSELOOK_BANK
Same as above, but relies on banking. It remaps left-right motions of the client camera (also known as "yaw") to rotations about the vehicle's local x-axis (also known as "roll").
VEHICLE_FLAG_CAMERA_DECOUPLED
Makes mouselook camera rotate independently of the vehicle. By default the client mouselook camera will rotate about with the vehicle, however when this flag is set the camera direction is independent of the vehicle's rotation.
When using the VEHICLE_FLAG_MOUSELOOK_STEER (or VEHICLE_FLAG_MOUSELOOK_BANK) the meaning of the VEHICLE_ANGULAR_MOTOR_DIRECTION parameter subtly changes. Instead of representing the "angular velocity" of the motor the components of the parameter scale the "measured angular velocity" (as determined by the rotation between the client's camera view direction and the forward-axis of the vehicle) to compute the "final angular velocity". That is, suppose you set the angular motor to <0, 0, 5>, then moved the camera view to be PI/4 radians to the left of the vehicle's forward axis, and down PI/8 toward the ground. The measured angular velocity would be <0, -PI/8, PI/4> radians/second, but the final velocity would be <0, 0, 5*PI/4>... the vehicle will turn left, but will not dip its nose down. Thus, by setting a component of the VEHICLE_ANGULAR_MOTOR_DIRECTION to zero, one can negate the pitch or yaw response of the motor, or even scale one to be much more responsive than the other.
The VEHICLE_ANGULAR_MOTOR_TIMESCALE still has an effect when using mouselook control, and scales the global responsiveness of the angular motor. The VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, on the other hand, is ignored when using mouselook controls.
Some vehicles, like boats, should always keep their up-side up. This can be done by enabling the "vertical attractor" behavior that springs the vehicle's local z-axis to the world z-axis (a.k.a. "up"). To take advantage of this feature you would set the VEHICLE_VERTICAL_ATTRACTION_TIMESCALE to control the period of the spring frequency, and then set the VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY to control the damping. An efficiency of 0.0 will cause the spring to wobble around its equilibrium, while an efficiency of 1.0 will cause the spring to reach it's equilibrium with exponential decay.
llSetVehicleVectorParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 4.0); llSetVehicleVectorParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.5);
The vertical attractor is disabled by setting its timescale to anything larger than 300 seconds.
Note that by default the vertical attractor will prevent the vehicle from diving and climbing. So, if you wanted to make a airplane you would probably want to unlock the attractor around the pitch axis by setting the VEHICLE_FLAG_LIMIT_ROLL_ONLY bit:
The vertical attractor feature must be enabled in order for the banking behavior to function. The way banking works is this: a rotation around the vehicle's roll-axis will produce a angular velocity around the yaw-axis, causing the vehicle to turn. The magnitude of the yaw effect will be proportional to the VEHICLE_BANKING_EFFICIENCY, the angle of the roll rotation, and sometimes the vehicle's velocity along it's preferred axis of motion.
The VEHICLE_BANKING_EFFICIENCY can vary between -1 and +1. When it's positive then any positive rotation (by the right-hand rule) about the roll-axis will effect a (negative) torque around the yaw-axis, making it turn to the right -- that is the vehicle will lean into the turn, which is how real airplanes and motorcycle's work. Negating the banking coefficient will make it so that the vehicle leans to the outside of the turn (not very "physical" but might allow interesting vehicles so why not?).
The VEHICLE_BANKING_MIX is a fake (i.e. non-physical) parameter that is useful for making banking vehicles do what you want rather than what the laws of physics allow. For example, consider a real motorcycle... it must be moving forward in order for it to turn while banking, however video-game motorcycles are often configured to turn in place when at a dead stop -- because they're often easier to control that way using the limited interface of the keyboard or game controller. The VEHICLE_BANKING_MIX enables combinations of both realistic and non-realistic banking by functioning as a slider between a banking that is correspondingly totally static (0.0) and totally dynamic (1.0). By "static" we mean that the banking effect depends only on the vehicle's rotation about it's roll-axis compared to "dynamic" where the banking is also proportional to it's velocity along it's roll-axis. Finding the best value of the "mixture" will probably require trial and error.
The time it takes for the banking behavior to defeat a pre-existing angular velocity about the world z-axis is determined by the VEHICLE_BANKING_TIMESCALE. So if you want the vehicle to bank quickly then give it a banking timescale of about a second or less, otherwise you can make a sluggish vehicle by giving it a timescale of several seconds.
VEHICLE_LINEAR_FRICTION_TIMESCALE is a vector parameter that defines the timescales for the vehicle to come to a complete stop along the three local axes of the vehicle's reference frame. The timescale along each axis is independent of the others. For example, a sliding ground car would probably have very little friction along its x- and z-axes (so it can easily slide forward and fall down) while there would usually significant friction along its y-axis:
Remember that a longer timescale corresponds to a weaker friction, hence to effectively disable all linear friction you would set all of the timescales to large values.
Setting the linear friction as a scalar is allowed, and has the effect of setting all of the timescales to the same value. Both code snippets below are equivalent, and both make friction negligible:
// set all linear friction timescales to 1000 llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <1000, 1000, 1000>);
// same as above, but fewer characters llSetVehicleFloatParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, 1000);
VEHICLE_ANGULAR_FRICTION_TIMESCALE is also a vector parameter that defines the timescales for the vehicle to stop rotating about the x-, y-, and z-axes, and are set and disabled in the same way as the linear friction.
The vehicle has a built-in buoyancy feature that is independent of the llSetBuoyancy call. It is recommended that the two buoyancies do not mix! To make a vehicle buoyant, set the VEHICLE_BUOYANCY parameter to something between -1.0 (extra gravity) to 1.0 (full anti-gravity).
The buoyancy behavior is independent of hover, however in order for hover to work without a large offset of the VEHICLE_HOVER_HEIGHT, the VEHICLE_BUOYANCY should be set to 1.0.
It is not recommended that you mix vehicle buoyancy with the llSetBuoyancy script call. It would probably cause the object to fly up into space.
The hover behavior is enabled by setting the VEHICLE_HOVER_TIMESCALE to a value less than 300 seconds; larger timescales totally disable it. Most vehicles will work best with short hover timescales of a few seconds or less. The shorter the timescale, the faster the vehicle will slave to is target height. Note, that if the values of VEHICLE_LINEAR_FRICTION_TIMESCALE may affect the speed of the hover.
Hover is independent of buoyancy, however the VEHICLE_BUOYANCY should be set to 1.0, otherwise the vehicle will not lift itself off of the ground until the VEHICLE_HOVER_HEIGHT is made large enough to counter the acceleration of gravity, and the vehicle will never float all the way to its target height.
The VEHICLE_HOVER_EFFICIENCY can be thought of as a slider between bouncy (0.0) and smoothed (1.0). When in the bouncy range the vehicle will tend to hover a little lower than its target height and the VEHICLE_HOVER_TIMESCALE will be approximately the oscillation period of the bounce (the real period will tend to be a little longer than the timescale).
For performance reasons, until improvements are made to the Second Life physics engine the vehicles can only hover over the terrain and water, so they will not be able to hover above objects made out of primitives, such as bridges and houses. By default the hover behavior will float over terrain and water, however this can be changed by setting some flags:
If you wanted to make a boat you should set the VEHICLE_HOVER_WATER_ONLY flag, or if you wanted to drive a hover tank under water you would use the VEHICLE_HOVER_TERRAIN_ONLY flag instead. Finally, if you wanted to make a submarine or a balloon you would use the VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT. Note that the flags are independent of each other and that setting two contradictory flags will have undefined behavior. The flags are set using the script call llSetVehicleFlags().
The VEHICLE_HOVER_HEIGHT determines how high the vehicle will hover over the terrain and/or water, or the global height, and has a maximum value of 100 meters. Note that for hovering purposes the "center" of the vehicle is its "center of mass" which is not always obvious to the untrained eye, and it changes when avatar's sit on the vehicle.
The vehicle relies on the x- (at), y- (left), and z- (up) axes in order to figure out which way it prefers to move and which end is up. By default these axes are identical to the local axes of the root primitive of the object, however this means that the vehicle's root primitive must, by default, be oriented to agree with the designed at, left, and up axes of the vehicle. But, what if the vehicle object was already pre-built with the root primitive in some non-trivial orientation relative to where the vehicle as a whole should move? This is where the VEHICLE_REFERENCE_FRAME parameter becomes useful; the vehicle's axes can be arbitrarily reoriented by setting this parameter.
As an example, suppose you had built a rocket out of a big cylinder, a cone for the nose, and some stretched cut boxes for the fins, then linked them all together with the cylinder as the root primitive. Ideally the rocket would move nose-first, however the cylinder's axis of symmetry is its local z-axis while the default "at-axis" of the vehicle, the axis it will want to deflect to forward under angular deflection, is the local x-axis and points out from the curved surface of the cylinder. The script code below will rotate the vehicle's axes such that the local z-axis becomes the "at-axis" and the local negative x-axis becomes the "up-axis":
// rotate the vehicle frame -PI/2 about the local y-axis (left-axis) rotation rot = llEuler2Rot(0, PI/2, 0); llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, rot);
Another example of how the reference frame parameter could be used is to consider flying craft that uses the vertical attractor for stability during flying but wants to use VTOL (vertical takeoff and landing). During flight the craft's dorsal axis should point up, but during landing its nose-axis should be up. To land the vehicle: while the vertical attractor is in effect, rotate the existing VEHICLE_REFERENCE_FRAME by +PI/2 about the left-axis, then the vehicle will pitch up such that it's nose points toward the sky. The vehicle could be allowed to fall to the landing pad under friction, or a decreasing hover effect.
Complete listing of the Linden Library function calls available in lsl.
Adjusts the volume of the currently playing attached sound started with llPlaySound or llLoopSound. This function Has no effect on sounds started with llTriggerSound.
If add
== TRUE, users that do no have
object modify permissions can still drop inventory items onto
object.
Applies the impulse
in local
coordinates if local
== TRUE. Otherwise the
impulse is applied in global coordinates. This function only works
on physical objects.
Applies a rotational impulse
force in
local coordinates if local
==
TRUE. Otherwise the impulse is applied in global coordinates. This
function only works on physical objects.
Attach to avatar
at point attachment
.
Requires the PERMISSION_ATTACH runtime
permission.
If an avatar is sitting on the sit target, return the avatar's key, NULL_KEY otherwise. This only will detect avatars sitting on sit targets defined with llSitTarget.
Converts a Base 64 string to a conventional string. If the conversion creates any unprintable characters, they are converted to spaces.
Delinks all objects in the link set. Requires the permission PERMISSION_CHANGE_LINKS be set.
Delinks the object with the given
link
number. Requires permission PERMISSION_CHANGE_LINKS
be set.
If accept
== TRUE, only accept
collisions with objects name
and
id
, otherwise with objects not
name
or id
. Specify
an empty string or NULL_KEY to
not filter on the corresponding parameter.
Suppress default collision sounds, replace default impact
sounds with impact_sound
found in the
object inventory. Supply an empty string to suppress collision
sounds.
Suppress default collision sprites, replace default impact
sprite with impact_sprite
found in the
object inventory. Supply an empty string to just suppress.
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.
Remove the slice from the list and return the remainder.
The 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.
Removes the indicated substring and returns the result. The
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.
Returns the grab offset of detected object
number
. Returns <0,0,0> if number is
not valid sensed object.
Returns the key of detected object
number
. Returns NULL_KEY if number is not valid sensed
object.
Returns the link position of the triggered event for touches. 0 for a non-linked object, 1 for the root of a linked object, 2 for the first child, etc.
Returns the name of detected object
number
. Returns empty string if
number
is not valid sensed object.
Returns the key of detected number
object's owner. Returns invalid key if
number
is not valid sensed object.
Returns the position of detected object
number
. Returns <0,0,0> if
number
is not valid sensed object.
Returns the rotation of detected object
number
. Returns <0,0,0,1> if
number
is not valid sensed object).
Returns the type (AGENT, ACTIVE, PASSIVE, SCRIPTED) of
detected object number
. Returns 0 if
number
is not valid sensed object. Note
that number
is a bitfield, so comparisons
need to be a bitwise and check. eg:
Returns the velocity of detected object
number
. Returns <0,0,0> if
number
is not valid sensed object.
Opens a "notify box" in the top-right corner of the given avatar's screen displaying the message. Up to twelve buttons can be specified in a list of strings. When the player clicks a button, the name of the button is chatted on the specified channel. Channels work just like llSay(), so channel 0 can be heard by everyone. The chat originates at the object's position, not the avatar's position. e.g.
Returns the string that is the URL escaped version of url
,
replacing spaces with %20 etc.
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.
Returns information about the given agent
id
. Returns a bitfield of agent info constants.
If the agent id
is in the same sim as
the object, returns the size of the avatar.
Returns the alpha of the given
face
. If face
is
ALL_SIDES the value returned is
the mean average of all faces.
Returns the seconds of elapsed time from an internal timer associated with the script. The timer is reset to zero during the call. The timer is also reset on rez, simulator restart, script reset, and in calls to llResetTime. Use llSetTimerEvent if you want a reliable timing mechanism.
Returns the bounding box around object
(including any linked prims)
relative to the root prim. Returned value is a list of the form:
[ (vector) min_corner, (vector) max_corner ]
Returns the color of face
as a vector
of red, green, and blue values between 0 and 1. If
face
is ALL_SIDES the color returned is the
mean average of each channel.
Get the name of the inventory item
number
of type
. Use
the inventory constants to
specify the type
.
Get the number of items of type
in
the object inventory. Use the inventory constants to specify
the type
.
Returns the requested permission mask
for the
specified inventory item. See Permission Mask Constants
for more information. Example usage:
Returns the type of the inventory
name
. INVENTORY_NONE is returned if no
inventory matching name
is found. Use the inventory constants to compare
against the return value.
Returns what link number in a link set the for the object which has this script. 0 means no link, 1 the root, 2 for first child, etc.
Returns the mass of the object in Kilograms. Most materials in Second Life are less dense than their first life counterparts, so the returned mass may be less than you might expect.
Returns the mass of the object specified by id
in Kilograms. Most materials
in Second Life are less dense than their first life counterparts,
so the returned mass may be less than you might expect.
Get the next waiting email with appropriate
address
and/or
subject
. If the parameters are blank, they
are not used for filtering.
This function fetches line number
line
of notecard
name
and returns the data through the dataserver event. The line count
starts at zero. If the requested line is past the end of the
notecard the dataserver
event will return the constant EOF string. The key returned by
this function is a unique identifier which will be supplied to the
dataserver event in the
requested
parameter.
This function reads the number of lines in notecard name
and returns this information through the dataserver event.
The key returned by this function is a unique identifier which will be supplied to the
dataserver event in the requested
parameter. You will need to cast the returned string to an integer.
Returns the requested permission mask
for the root object the
task is attached to. See Permission Mask Constants
for more information. Example usage:
Returns avatar that has enabled permissions. Returns NULL_KEY if not enabled.
Get primitive parameters specified in parameters
. The
parameters
are identical to the rules of llSetPrimitiveParams, and the returned list is ordered as such. Most requested parameters do not require a value to be associated, except for texture-related requests (PRIM_TEXTURE, PRIM_COLOR, and PRIM_BUMP_SHINY) which require a side number to be specified as well.
Valid parameters can be found in the Primitive Constants.
Here is a simple example:
[PRIM_TYPE_BOX, PRIM_HOLE_DEFAULT, <0, 1, 0>, 0.0, <0, 0, 0>, <1, 1, 0>, <0, 0, 0>, // PRIM_TYPE PRIM_MATERIAL_WOOD, // PRIM_MATERIAL 0, <1, 1, 1>, 1.0, // PRIM_COLOR (ALL_SIDES specified, so all 6 sides returned) 1, <1, 0, 0>, 0.5, 2, <0, 0, 1>, 1.0, 3, <0, 1, 0>, 1.0, 4, <0, 0, 0>, 0.5, 5, <1, 1, 1>, 1.0, <37.341, 195.283, 31.239>] // PRIM_POSITION
Returns the global position of the root object of the object the script is attached to.
Returns the global rotation of the root object of the object the script is attached to.
Returns the start parameter passed to llRezObject or llRezAtRoot. If the object was created from agent inventory, this function returns 0.
Returns the indicated substring from
src
. The 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.
Returns the seconds of elapsed time from an internal timer associated with the script. The timer is reset on rez, simulator restart, script reset, and in calls to llGetAndResetTime or llResetTime. Use llSetTimerEvent if you want a reliable timing mechanism.
Returns the time in seconds since simulator timezone midnight. Currently this is PST.
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 has been called with TRUE, any other object can pass objects to its inventory.
Give the list of named inventory items 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. The offered inventory is then
placed in a folder named category
in the
recipients inventory. If the recipient is an object, the same
permissions apply as if you were dragging inventory onto the
object by hand, ie if llAllowInventoryDrop has
been called with TRUE, any other object can pass objects to its
inventory.If the recipient is an object, the
category
parameter is ignored.
Transfer amount
from the script owner
to destination
. This call will fail if
PERMISSION_DEBIT has not
been set.
Critically damps to height
if within
height
* 0.5 of
level
. The height
is above ground level if water
is FALSE or
above the higher of land and water if water
is TRUE.
Returns the slice of the list from
start
to end
from
the list src
as a new list. The
start
and end
parameters 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.
Returns the position of the first instance of
test
in src
. Returns
-1 if test
is not in
src
.
Returns src
randomized into blocks of
size stride
. If the length of
src
divided by
stride
is non-zero, this function does
not randomize the list.
Returns the list created by replacing the segment of dest
from
start
to end
with src
.
Returns src
sorted into blocks of
stride
in ascending order if
ascending
is TRUE. Note that sort only works in
the head of each sort block is the same type.
Sets a listen event callback for msg
on channel
from name
and returns an identifier that can be used to deactivate or remove
the listen. The name
,
id
and/or msg
parameters can be blank to indicate not to filter on that
argument. Channel 0 is the public chat channel that all avatars
see as chat text. Channels 1 to 2,147,483,648 are hidden channels
that are not sent to avatars.
Make a listen event callback active or inactive. Pass in the
value returned from llListen
to the number
parameter to specify which
event you are controlling. Use boolean values to specify
active
.
Removes a listen event callback. Pass in the value returned
from llListen to the
number
parameter to specify which event you
are removing.
Displays a dialog to user avatar_id
with message
offering to
go to the web page at url
. If the user clicks the
"Go to page" button, their default web browser is launched and
directed to url
.
The url
must begin with "http:" or
"https:", other protocols are not currently supported.
The dialog box shows the name of the object's
owner so that abuse (e.g. spamming) can be easily reported.
This function has a 10 second implicit sleep.
Cause object to point the forward axis toward
target
. Good
strength
values are around half the mass of
the object and good damping
values are less
than 1/10th of the
strength
. Asymmetrical shapes require
smaller damping
. A
strength
of 0.0 cancels the look at.
Similar to llPlaySound, this function 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 at a time. A second call to
llLoopSound with the same key will not restart the sound, but the
new volume will be used. This 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.
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. The use of multiple masters within a small area is unlikely to produce the desired effect.
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 synchronizing the loop points of both sounds. If a Sync Master is started when the Slave is already playing, the Slave will skip to the correct position to sync with the Master.
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.
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.
llMakeFountain
(integer particles, float scale, float velocity, float lifetime, float arc, string texture, vector offset);
Make a fountain of particles using
texture
from the object's inventory.
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.
Performs a RSA Data Security, Inc. MD5 Message-Digest
Algorithm on str
with
nonce
. The function returns the digest as a
32 character hex string. The digest is computed on the string in
the following format:
Sends num
,
str
, and id
to
members of the link set. The linknum
parameter is either the linked number available through llGetLinkNumber or a link constant.
Modify land with action
on
size
area. The parameters can be chosen
from the land constants.
Critically damp to position 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.
Sets the texture s and t offsets of
face
. If face
is
ALL_SIDES this
function sets the texture offsets for all faces.
Creates a channel to listen for XML-RPC calls. Will trigger a remote_data event with type = REMOTE_DATA_CHANNEL and a channel id once it is available.
Controls the playback of movies and other multimedia resources on a land parcel.
command
can be one of
PARCEL_MEDIA_COMMAND_STOP,
PARCEL_MEDIA_COMMAND_PAUSE,
PARCEL_MEDIA_COMMAND_PLAY,
PARCEL_MEDIA_COMMAND_LOOP,
PARCEL_MEDIA_COMMAND_TEXTURE,
PARCEL_MEDIA_COMMAND_URL,
PARCEL_MEDIA_COMMAND_TYPE,
PARCEL_MEDIA_COMMAND_DESC,
PARCEL_MEDIA_COMMAND_SIZE,
PARCEL_MEDIA_COMMAND_TIME,
PARCEL_MEDIA_COMMAND_AGENT,
PARCEL_MEDIA_COMMAND_UNLOAD, or
PARCEL_MEDIA_COMMAND_AUTO_ALIGN.
You are allowed one movie (or "media" resource) per land parcel. The movie will be played by replacing a texture on an object with the movie. Users will only see the movie when they are standing on your land parcel. Otherwise they will see the static texture.
Most of the QuickTime media formats are supported including:
QuickTime movies (.mov)
Streamable stored QuickTime movies (.mov)
Real time QuickTime streams (rtsp://)
MPEG4 movies (.mp4, .mpeg4) (simple profile only)
QuickTime VR scenes and objects (.mov)
Flash movies (.swf) (only non-interative, version 5 and earlier
and many others from http://www.apple.com/quicktime/products/qt/specifications.html
You can set up a movie for playback as follows:
First, select a texture from your inventory to be the static texture. It should not be a common texture -- a test pattern would be better than the default plywood.
Apply that texture to an object.
Right click on your land and select "About Land..."
Under "Options" use the GUI to select the static texture.
Enter the URL of your movie or media stream.
Create objects you want to click on for PLAY, STOP, PAUSE and LOOP (play forever)
Attach the following script (or similar) to each.
default { touch_start ( integer total_number ) { // This will play the current movie for all agents in the parcel. llParcelMediaCommandList( [PARCEL_MEDIA_COMMAND_LOOP] ); } }
float START_TIME = 30.0; float RUN_LENGTH = 10.0; default { state_entry() { llParcelMediaCommandList( [ PARCEL_MEDIA_COMMAND_URL, "http://enter_your.url/here", PARCEL_MEDIA_COMMAND_TEXTURE, (key) llGetTexture(0) ] ); } touch_start(integer num_detected) { llParcelMediaCommandList( [ PARCEL_MEDIA_COMMAND_AGENT, llDetectedKey(0), PARCEL_MEDIA_COMMAND_TIME, START_TIME, PARCEL_MEDIA_COMMAND_PLAY ] ); list Info = llParcelMediaQuery([PARCEL_MEDIA_COMMAND_URL, PARCEL_MEDIA_COMMAND_TEXTURE]); llSay(0, "Playing '" + llList2String(Info, 0) + "' on texture '" + (string)llList2Key(Info, 1) + "' for agent " + llDetectedName(0)); llSetTimerEvent(RUN_LENGTH); } timer() { llParcelMediaCommandList( [ PARCEL_MEDIA_COMMAND_STOP ] ); llSetTimerEvent(0.0); } }
Controls the playback of movies and other multimedia resources on a land parcel.
command
can be one of
PARCEL_MEDIA_COMMAND_TEXTURE or
PARCEL_MEDIA_COMMAND_URL.
This allows you to query the texture or url for media on the parcel. See llParcelMediaCommandList for an example of usage.
Breaks src
into a list, discarding
anything in separators
, keeping any entry
in spacers
. The
separators
and
spacers
must be lists of strings with a
maximum of 8 entries each. So, if you had made the call:
Breaks src
into a list, discarding
anything in separators
, keeping any entry
in spacers
. Any resulting null values
are kept. The separators
and
spacers
must be lists of strings with a
maximum of 8 entries each. So, if you had made the call:
Makes a particle system based on the parameter list. The
parameters
are specified as an ordered list
of parameter and value. Valid parameters and their expected values
can be found in the particle system
constants. Here is a simple example:
If pass
is TRUE, land and object collisions
are passed from children on to parents.
Plays a sound once. The sound will be attached to an object
and follow object movement. Only one sound may be attached to an
object at a time, and attaching a new sound or calling llStopSound will stop the
previously attached sound. A second call to llPlaySound with the
same sound
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.
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.
Send an XML-RPC reply to message_id on channel with payload of string sdata.
If an object using remote data channels changes regions, you must call this function to reregister the remote data channels. You do not need to make this call if your object does not change regions or use remote data channels.
If the owner of the object this script is attached can modify target
, it has the correct pin
and the objects are in the same region, copy script name
onto target
, if running
== TRUE, start the script with param
. If name
already exists on target
, it is replaced.
Sets the vehicle flags
to
FALSE. Valid parameters can be found in the vehicle flags constants
section.
This function requests data about agent
id
. If and when the information is
collected, the dataserver
event is called with the returned key returned from this function
passed in the requested
parameter. See the
agent data constants for
details about valid values of data
and what
each will return in the dataserver event.
Requests data from object inventory item
name
. When data is available the dataserver event will be raised
with the key returned from this function in the
requested
parameter. 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 of the region the script call is made
(possible even resulting in negative values). So, to
convert this value into a global position, just add the result of
llGetRegionCorner.
Ask avatar
to allow the script to do
perm
. The perm
parameter should be a permission
constant. Multiple permissions can be requested
simultaneously by or'ing the constants together. Many of the
permissions requests can only go to object owner. This call will
not stop script execution - if the specified avatar grants the
requested permissions, the run_time_permissions
event will be called.
This function requests data about simulator
sim_name
. When the information is
collected, the dataserver
event is called with the returned key returned from this function
passed in the requested
parameter. See the
simulator data constants for
details about valid values of data
and what
each will return in the dataserver event.
Creates object's inventory
object at
position pos
with velocity
vel
and rotation
rot
. The last selected root object's location
in a multi-object selection will be placed at pos
.
All other objects in a selection will be created relative to the last
selected root's position, taking rot
into account.
The param
value
will be available to the newly created object in the on_rez event or through the llGetStartParameter
library function. The vel
parameter is
ignored if the rezzed object is not physical.
Creates object's inventory
object at
position pos
with velocity
vel
and rotation
rot
. The param
value
will be available to the newly created object in the on_rez event or through the llGetStartParameter
library function. The vel
parameter is
ignored if the rezzed object is not physical.
Cause object to rotate to rot
. Good
strength
values are around half the mass of
the object and good damping
values are less
than 1/10th of the
strength
. Asymmetrical shapes require
smaller damping
. A
strength
of 0.0 cancels the look at.
Set object rotation within error
of
rotation
as a rotational target and return
an integer number for the target. The number can be used in llRotTargetRemove.
Sets the texture rotation of face
to
radians
. If face
ALL_SIDES, rotate the
texture of all faces.
Returns TRUE if the
object or agent id
is in the same simulator
and has the same active group as this object. Otherwise, returns
FALSE.
Say text
on
channel
. Channel 0 is the public chat
channel that all avatars see as chat text. Channels 1 to
2,147,483,648 are private channels that are not sent to avatars
but other scripts can listen for through the llListen api.
Sets the texture s and t scales of
face
to scale_s
and
scale_t
respectively. If face is ALL_SIDES, scale the texture
to all faces.
Returns true if pos is over public land, land that doesn't allow everyone to edit and build, or land that doesn't allow outside scripts.
Send an XML-RPC request to dest through channel with payload of channel (in a string), integer idata and string sdata. An XML-RPC reply will trigger a remote_data event with type = REMOTE_DATA_REPLY. The call returns a message_id that can be used to identify XML-RPC replies.
Performs a single scan for name
and
id
with type
within
range
meters and arc
radians of forward vector. Specifying a blank name or NULL_KEY id will not filter results for
any particular name or id. A range of 0.0 does not perform a
scan. Range is limited to 96.0. The type
parameter should be an object type constant value. If anything is found
during the scan, a sensor event is triggered. A maximum
of 16 items are passed to this event. If nothing is found during the scan, a
no sensor event is triggered instead.
Performs a single scan for name
and
id
with type
within
range
meters and arc
radians of forward vector and repeats every
rate
seconds. Specifying a blank name or
NULL_KEY id will not filter
results for any particular name or id. A range of 0.0 cancels the
scan. Range is limited to 96.0. The type
parameter should be an object type constant
value. If anything is found during the scan, a sensor
event is triggered. A maximum of 16 items are passed to this event. If nothing is found
during the scan, a no sensor event is triggered instead.
Sets the alpha value for face
. If
face is ALL_SIDES, set
the alpha to all faces. The alpha
value is
interpreted as an opacity percentage - 1.0 is fully opaque, and
0.2 is mostly transparent. This api will clamp
alpha
values less 0.1 to .1 and greater
than 1.0 to 1.
Set the object buoyancy. A value of 0 is none, less than 1.0 sinks, 1.0 floats, and greater than 1.0 rises.
Sets the amount of damage that will be done to an object that this object hits. This object will be destroyed on damaging another object.
If the object is physical, this function sets the
force
. The vector is in local coordinates if
local is TRUE, global if
FALSE.
If the object is physical, this function sets the
force
and
torque
. The vectors are in local coordinates
if local is TRUE, global if
FALSE.
Critically damps to a height. The height is above ground and
water if water
is TRUE.
Sets the alpha
of a prim in the link set.
The linknum
parameter is either the linked number available through llGetLinkNumber or a link constant.
If face
is
ALL_SIDES, set the alpha
of all faces.
Sets the color
of a prim in the link set.
The linknum
parameter is either the linked number available through llGetLinkNumber or a link constant.
If face
is
ALL_SIDES, set the color
of all faces.
Sets the primitive parameters of a prim in the link set.
The linknum
parameter is either the linked number available through llGetLinkNumber or a link constant.
The rules
list is identical to that of
llSetPrimitiveParams.
Sets the texture
of a prim in the link set.
The linknum
parameter is either the linked number available through llGetLinkNumber or a link constant.
If face
is
ALL_SIDES, set the texture
of all faces.
If the object is not physical, this function sets the rotation of a child prim relative to the root prim, and the linked set is adjusted.
Sets the streaming audio URL for the parcel where the object
is currently located. The url
must be an
http streaming source of mp3 or ogg data.
Sets the default pay price and optionally the quick pay buttons for the 'Pay' window when someone pays this object. See also Pay Button Constants.
If the object is not physical, this function sets the position in region coordinates. If the object is a child, the position is treated as root relative and the linked set is adjusted.
Set primitive parameters based on rules
. The
rules
are specified as an ordered list
of parameter and value(s). Valid parameters and their expected values
can be found in the Primitive Constants.
Here is a simple example:
If pin is set to a non-zero number, the task will accept remote script loads via llRemoteLoadScriptPin if it passes in the correct pin. Otherwise, llRemoteLoadScriptPin is ignored.
If the object is not physical, this function sets the rotation. If the object is a child, the position is treated as root relative and the linked set is adjusted.
Sets whether successive calls to llPlaySound, llLoopSound, etc., (attached sounds) interrupt the playing sound. The default for objects is FALSE. Setting this value to TRUE will make the sound wait until the current playing sound reaches its end. The queue is one level deep.
Sets the texture
from object
inventory of face
. If face is ALL_SIDES, set the texture to
all faces.
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. The mode is a mask of texture animation constants. You can only have one texture animation on an object, calling llSetTextureAnim more than once on an object will reset it.
You can only do one traditional animation, ROTATE or SCALE at a time, you
cannot 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.
The face
specified which face to
animate. If face
is ALL_SIDES, all textures on the
object are animated.
The sizex
and
sizey
describe the layout of the frames
within the texture. sizex
specifies how
many horizontal frames and 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 per second, etc.
Sets the timer event to
be triggered every sec
seconds. Passing in
0.0 stops further timer
events.
If the object is physical, this function sets the
torque
. The vector is in local coordinates
if local is TRUE, global if
FALSE.
Sets the vehicle flags
to TRUE. Valid
parameters can be found in the vehicle flags constants
section.
Sets the vehicle floating point parameter
param_name
to
param_value
. Valid parameters and their
expected values can be found in the vehicle parameter
constants section.
Activates the vehicle action and choose vehicle
type
. Valid types and an explanation of
their characteristics can be found in the vehicle type constants
section.
Sets the vehicle rotation parameter
param_name
to
param_value
. Valid parameters can be found
in the vehicle parameter
constants section.
Sets the vehicle vector parameter
param_name
to
param_value
. Valid parameters can be found
in the vehicle parameter
constants section.
Shout text
on
channel
. Channel 0 is the public chat
channel that all avatars see as chat text. Channels 1 to
2,147,483,648 are private channels that are not sent to avatars
but other scripts can listen for through the llListen api.
Set the sit location for this object. If
offset
== ZERO_VECTOR
clear the sit target.
Returns the square root of val
. If
val
is less than 0.0, this function returns
0.0 and raises a math runtime error.
This function starts animation anim
for the avatar that owns the object.
Valid strings for anim
Holds the appropriately shaped weapon in the right hand. Automatically switches to the aims (below) when user enters mouse look
Aims the appropriately shaped weapon along the direction the avatar is looking.
Flops over in "away from keyboard" state.
Performs a backflip.
Bows at waist.
Brushes dirt from shirt.
Applauds.
Bows with a courtly flourish.
Crouches in place.
Walks in place while crouching.
Various dance maneuvers.
Freefall falling animation.
Walks with hip sway.
Flies forward.
Flies forward at a less aggressive angle.
Waves.
Hold object in right hand, prepared to throw it.
Hovers in place.
Pretends to hover straight down.
Pretends to hover straight up.
Midair jump position.
Roundhouse kick with right leg.
Lands after flying.
Prepares to jump.
Punch with left hand.
Punch with right hand.
Punch with one hand then the other.
Runs in place.
Salutes with right hand.
Sits on object at knee height.
Sits down on ground.
Walks in place slowly.
Leans on imaginary prop while holding cigarette.
Leans on imaginary prop and smokes a cigarette.
Leans on imaginary prop, throws down a cigarette, and stamps it out.
Pantomimes taking a picture.
Stumbles a bit as if landing.
Stands in place.
Falls on face and stands up.
Legs extended as if stepping off of a ledge.
Strike with sword in right hand.
Head moves as if talking.
Throws object in right hand.
Turns around and models a new shirt.
Pretends to turn left.
Pretends to turn right.
Makes typing motion.
Walks uphill in place.
Walks in place.
Whispers behind hand.
Whistles with hands in mouth.
Shouts between cupped hands.
Stops a currently playing attached sound started with llPlaySound or llLoopSound. Has no effect on sounds started with llTriggerSound.
Finds index in source where pattern first appears. Returns -1 if no match is found.
If (accept
==
(controls
& input)), send input to
object. If the boolean pass_on
is TRUE, also send input to
avatar.
Set object position within range
of
position
as a target and returns an integer
ID for the target.
Attempt to spin at spinrate
with
strength gain
on
axis
. A spinrate
of
0.0 cancels the spin. This function works in object local
coordinates for child objects and works in world coordinates for
root objects.
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 triggered 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 this function.
Plays a transient sound NOT attached to an object with its
audible range limited by the axis aligned bounding box define by
tne
(top-north-eash) and
bsw
(bottom-south-west). 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
triggered 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 this
function.
Returns the string that is the URL unescaped version of url
,
replacing %20 with spaces etc.
If 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.
When detect = TRUE, this makes the entire link set the script is attached to phantom but if another object interpenetrates it, it will get a collision_start event. When an object stops interpenetrating, a collision_end event is generated. While the other is interpenetrating, collision events are NOT generated. The script must be applied to the root object of the link set to get the collision events. Collision filters work normally.
Whisper text
on
channel
. Channel 0 is the public chat
channel that all avatars see as chat text. Channels 1 to
2,147,483,648 are private channels that are not sent to avatars
but other scripts can listen for through the llListen api.
Performs an exclusive or on two Base 64 strings and returns
a Base 64 string. The s2
parameter repeats if
it is shorter than s1
.
Every state must have at least one handler. You can choose to handle an event by defining one of the reserved event handlers named here.
This event is triggered when a script comes within a defined angle of a target rotation. The range is set by a call to llRotTarget.
This event is triggered when a script comes within a defined range from a target position. The range and position are set by a call to llTarget.
This event is 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 is NULL_KEY.
Triggered when various events change the object. The
changed
will be a bitfield of change constants.
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.)
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.)
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.)
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. The levels
and
edges
are bitfields of control constants.
This event is triggered when the requested data is returned to the script. Data may be requested by the llRequestAgentData, the llRequestSimulatorData, the llRequestInventoryData, and the llGetNotecardLine function calls.
This event is triggered when an email sent to this script
arrives. The remaining
tells how many more
emails are known as still pending.
This event is raised when the object the script is attached to is colliding with the ground.
This event is raised when the object the script is attached to stops colliding with the ground.
This event is raised when the object the script is attached to begins to collide with the ground.
Triggered when object receives a link message via llMessageLinked library function call.
This event is raised whenever a chat message matching the
constraints passed in the llListen
command is heard. The name
and
id
of the speaker as well as the
message
are passed in as parameters.
Channel 0 is the public chat channel that all avatars see as chat
text. Channels 1 through 2,147,483,648 are private channels that
are not sent to avatars but other scripts can listen on those
channels.
This event is triggered when user
giver
has given an
amount
of Linden dollars to the
object.
This event is raised when sensors are active (via the llSensor library call) but are not sensing anything.
When a target is set via the llRotTarget library call, but the script is outside the specified angle this event is raised.
When a target is set via the llTarget library call, but the script is outside the specified range this event is raised.
Triggered when object rezzes another object from its
inventory via the llRezObject api. The
id
is the globally unique key for the
object.
Triggered whenever a object is rezzed from inventory or by
another object. The start_param
is the
parameter passed in from the call to llRezObject or llRezAtRoot.
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
equal 0 then no permissions are
set.
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 in the total_number
parameter. A maximum of 16 objects are passed to this event.
Information on those objects may be gathered via the
llDetected* library
functions.
The state_entry event occurs whenever a new state is entered, including program start, and is always the first event handled.
The state_exit event occurs whenever the state command is used to transition to another state. It is handled before the new state's state_entry event.
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 in the total_number
parameter. Information on those objects may be gathered via the
llDetected* library
functions.
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 in the total_number
parameter. Information on those objects may be gathered via the
llDetected* library
functions.
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 in the total_number
parameter. Information on those objects may be gathered via the
llDetected* library
functions.
This event is raised when a user creates an XML-RPC
channel via llOpenRemoteDataChannel,
a remote XML-RPC server replies to a llSendRemoteData,
or a remote XML-RPC client sends in an XML-RPC request. In the open case,
type
= REMOTE_DATA_CHANNEL, channel
= NULL_KEY,
message_id
= NULL_KEY, sender
is an empty string,
ival
= 0, and sval
is an empty string. In the reply case,
type
= REMOTE_DATA_REPLY, channel
is set to the channel that the request was sent on,
message_id
is set to the id of the message, sender
is an empty string,
ival
= 0, and sval
is a string. In the remote request case,
type
= REMOTE_DATA_REQUEST, channel
is set to the channel that sent the message,
message_id
is set to the id of the message, sender
is set by the sender,
ival
is an integer, and sval
is a string.
parameter.
To ease scripting, many useful constants are defined by LSL.
The boolean constants represent the values for TRUE and FALSE. LSL represents booleans as integer values 1 and 0 respectively. Since there is no boolean type these constants act as a scripting aid usually employed for testing variables which conceptually represent boolean values.
TRUE
FALSE
The status constants are used in the llSetStatus and llGetStatus library calls. These constants can be bitwise or'ed together when calling the library functions to set the same value to more than one status flag
Status Constants
Controls whether the object moves physically. This controls the same flag that the ui checkbox for 'Physical' controls. The default is FALSE.
Controls whether the object collides or not. Setting the value to TRUE makes the object non-colliding with all objects. It is a good idea to use this for most objects that move or rotate, but are non-physical. It is also useful for simulating volumetric lighting. The default is FALSE.
Controls whether the object can physically rotate around the specific axis or not. This flag has no meaning for non-physical objects. Set the value to FALSE to disable rotation around that axis. The default is TRUE for a physical object.
A useful example to think about when visualizing the effect is a 'sit-and-spin' device. They spin around the Z axis (up) but not around the X or Y axis.
Controls whether the object can be grabbed. A grab is the default action when in third person, and is available as the 'hand' tool in build mode. This is useful for physical objects that you don't want other people to be able to trivially disturb. The default if FALSE
Controls whether the object can cross region boundaries and move more than 20 meters from its creation point. The default if FALSE.
Controls whether the object is returned to the owner's inventory if it wanders off the edge of the world. It is useful to set this status TRUE for things like bullets or rockets. The default is TRUE
These constants can be combined using the binary '|' operator and are used in the llSensor and related calls.
Object Type Constants
Objects in world that are agents.
Objects in world that are running a script or currently physically moving.
Static in-world objects.
Scripted in-world objects.
The permission constants are used for passing values to llRequestPermissions, determining the value of llGetPermissions, and explicitly passed to the run_time_permissions event. For many of the basic library functions to work, a specific permission must be enabled. The permission constants can be or'ed together to be used in conjunction.
Permission Constants
If this permission is enabled, the object can successfully call llGiveMoney to debit the owner's account.
If this permission enabled, the object can successfully call the llTakeControls library call.
(not yet implemented)
If this permission is enabled, the object can successfully call llStartAnimation for the avatar that owns this object.
If this permission is enabled, the object can successfully call llAttachToAvatar to attach to the given avatar.
(not yet implemented)
If this permission is enabled, the object can successfully call llCreateLink, llBreakLink, and llBreakAllLinks to change links to other objects.
(not yet implemented)
(not yet implemented)
These constants can be used to refer to a specific inventory type in calls to llGetInventoryNumber and llGetInventoryName. They are also returned by llGetInventoryType.
Inventory Constants
Each constant refers to the named type of inventory.
These constants can be used in llSetPayPrice
Pay Price Constants
Do not show this quick pay button.
Use the default value for this quick pay button.
These constants are used to refer to attachment points in calls to llAttachToAvatar.
Attachment Constants
Attach to the avatar chest.
Attach to the avatar head.
Attach to the avatar left shoulder.
Attach to the avatar right shoulder.
Attach to the avatar left hand.
Attach to the avatar right hand.
Attach to the avatar left foot.
Attach to the avatar right foot.
Attach to the avatar back.
Attach to the avatar pelvis.
Attach to the avatar mouth.
Attach to the avatar chin.
Attach to the avatar left ear.
Attach to the avatar right ear.
Attach to the avatar left eye.
Attach to the avatar right eye.
Attach to the avatar nose.
Attach to the avatar right upper arm.
Attach to the avatar right lower arm.
Attach to the avatar left upper arm.
Attach to the avatar left lower arm.
Attach to the avatar right hip.
Attach to the avatar right upper leg.
Attach to the avatar right lower leg.
Attach to the avatar left hip.
Attach to the avatar lower upper leg.
Attach to the avatar lower left leg.
Attach to the avatar belly.
Attach to the avatar right pectoral.
Attach to the avatar left pectoral.
These constants are only used in calls to llModifyLand. The constants are equivalent to the similarly labelled user interface elements for editing land in the viewer.
Land Constants
Action to make the land flat and level.
Action to raise the land.
Action to lower the land.
Action to smooth the land.
Action to push the land toward a pseudo-random heightfield.
Action to push the land toward the original shape from when it was first terraformed.
Use a small brush size.
Use a medium brush size.
Use a large brush size.
These constants are used in calls to llSetLinkColor and llMessageLinked.
Link Constants
This targets every object in the linked set.
This targets the root of the linked set.
This targets every object in the linked set except the object with the script.
This targets every object except the root in the linked set.
This targets the object making the call only.
These constants are used in llTakeControls as well as the control event handler.
Control Constants
Test for the avatar move forward control.
Test for the avatar move back control.
Test for the avatar move left control.
Test for the avatar move right control.
Test for the avatar rotate left control.
Test for the avatar rotate right control.
Test for the avatar move up control.
Test for the avatar move down control.
Test for the avatar left button control.
Test for the avatar left button control while in mouse look.
These constants are used in the changed event handler.
Change Constants
The object inventory has changed.
The object inventory has changed because an item was added through the llAllowInventoryDrop interface.
The object color has changed.
The object shape has changed, eg, a box to a cylinder
The object scale has changed.
The texture offset, scale rotation, or simply the object texture has changed.
The object has linked or its links were broken.
The object has changed regions.
The object has been teleported.
These constants are used to determine the variable type stored in a heterogeneous list. The value returned from llGetListEntryType can be used for comparison against these constants.
Type Constants
The list entry is an integer.
The list entry is a float.
The list entry is a string.
The list entry is a key.
The list entry is a vector.
The list entry is a rotation.
The list entry is invalid.
Each of these constants represents a bit in the integer returned from the llGetAgentInfo function and can be used in an expression to determine the specified information about an agent.
Agent Info Constants
The agent is flying.
The agent has attachments.
The agent has scripted attachments.
The agent is sitting.
The agent is sitting on an object.
The agent is walking.
The agent is in the air.
The agent is in mouselook.
The agent is away (AFK).
The agent is typing.
The agent is crouching.
These constants are used in the llSetTextureAnim api to control the animation mode.
Texture Animation Constants
Texture animation is on.
Loop the texture animation.
Play animation in reverse direction.
play animation going forwards, then backwards.
slide in the X direction, instead of playing separate frames.
Animate texture rotation.
Animate the texture scale.
These constants are used in calls to the llParticleSystem api to specify parameters.
Particle System Parameters
Each particle that is emitted by the particle system is simulated based on the following flags. To use multiple flags, bitwise or (|) them together.
PSYS_PART_FLAGS Values
Interpolate both the color and alpha from the start value to the end value.
Interpolate the particle scale from the start value to the end value.
Particles have their velocity damped towards the wind velocity.
Particles bounce off of a plane at the object's Z height.
The particle position is relative to the source object's position.
The particle orientation is rotated so the vertical axis faces towards the particle velocity.
The particle heads towards the location of the target object as defined by PSYS_SRC_TARGET_KEY.
The particle glows.
(not implemented)
(not implemented)
(not implemented)
The pattern which is used to generate particles. Use one of the following values:
PSYS_SRC_PATTERN Values
Drop particles at the source position.
Shoot particles out in all directions, using the burst parameters.
Shoot particles across a 2 dimensional area defined by the arc created from PSYS_SRC_OUTERANGLE. There will be an open area defined by PSYS_SRC_INNERANGLE within the larger arc.
Shoot particles out in a 3 dimensional cone with an outer arc of PSYS_SRC_OUTERANGLE and an inner open area defined by PSYS_SRC_INNERANGLE.
a vector <r,g,b> which determines the starting color of the object.
a float which determines the starting alpha of the object.
a vector <r, g, b> which determines the ending color of the object.
a float which determines the ending alpha of the object.
a vector <sx, sy, z>, which is the starting size of the particle billboard in meters (z is ignored).
a vector <sx, sy, z>, which is the ending size of the particle billboard in meters (z is ignored).
age in seconds of a particle at which it dies.
a vector <x, y, z> which is the acceleration to apply on particles.
an asset name for the texture to use for the particles.
how often to release a particle burst (float seconds).
specifies the inner angle of the arc created by the PSYS_SRC_PATTERN_ANGLE or PSYS_SRC_PATTERN_ANGLE_CONE source pattern. The area specified will not have particles in it..
specifies the outer angle of the arc created by the PSYS_SRC_PATTERN_ANGLE or PSYS_SRC_PATTERN_ANGLE_CONE source pattern. The area between the outer and inner angle will be filled with particles..
how many particles to release in a burst.
what distance from the center of the object to create the particles.
minimum speed that a particle should be moving.
maximum speed that a particle should be moving.
how long this particle system should last, 0.0 means forever.
the key of a target object to move towards if PSYS_PART_TARGET_POS_MASK is enabled.
Sets the angular velocity to rotate the axis that SRC_PATTERN_ANGLE and SRC_PATTERN_ANGLE_CONE use..
These constants are used in calls to the llRequestAgentData api to collect information about an agent which will be provided in the dataserver event.
Agent Data Constants
"1" for online "0" for offline.
The name of the agent.
The date the agent was born returned in ISO 8601 format of YYYY-MM-DD.
Returns the agent ratings as a comma separated string of six integers. They are:
Positive rated behavior
Negative rated behavior
Positive rated appearance
Negative rated appearance
Positive rated building
Negative rated building
LSL provides a small collection of floating point constants for use in float arithmetic. These constants are usually employed while performing trigonometric calculations, but are sometimes useful for other applications such as specifying arc radians to sensor or particle system functions.
Float Constants
3.14159265 - The radians of a hemicircle.
6.28318530 - The radians of a circle.
1.57079633 - The radians of a quarter circle.
0.01745329 - Number of radians per degree. You can use this to convert degrees to radians by multiplying the degrees by this number.
57.2957795 - Number of degrees per radian. You can use this number to convert radians to degrees by multiplying the radians by this number.
1.41421356 - The square root of 2.
There is one uncategorized integer constant which is used in some of the texturing and coloring api: ALL_SIDES
There is one uncategorized string constant which is used in the dataserver event: EOF
There is only one vector constant which acts as a zero vector: ZERO_VECTOR = <0,0,0>.
There is only one rotation constant which acts as a zero rotation: ZERO_ROTATION = <0,0,0,1>.
These constants are used in calls to the llRequestSimulatorData api to collect information about a simulator which will be provided in the dataserver event.
Simulator Data Constants
The global position of the simulator. Cast the value to a vector.
The status of the simulator. Currently, this may be one of the following:
up
down
stopping
starting
crashed
Parameters
A vector of timescales for exponential decay of the vehicle's linear velocity along its preferred axes of motion (at, left, up). Range = [0.07, inf) seconds for each element of the vector.
A vector of timescales for exponential decay of the vehicle's angular velocity about its preferred axes of motion (at, left, up). Range = [0.07, inf) seconds for each element of the vector.
The direction and magnitude (in preferred frame) of the vehicle's linear motor. The vehicle will accelerate (or decelerate if necessary) to match its velocity to its motor. Range of magnitude = [0, 30] meters/second.
The offset point from the vehicle's center of mass at which the linear motor's impulse is applied. This allows the linear motor to also cause rotational torque. Range of magnitude = [0, 100] meters.
The timescale for exponential approach to full linear motor velocity.
The timescale for exponential decay of the linear motor's magnitude.
The direction and magnitude (in preferred frame) of the vehicle's angular motor.The vehicle will accelerate (or decelerate if necessary) to match its velocity to its motor.
The timescale for exponential approach to full angular motor velocity.
The timescale for exponential decay of the angular motor's magnitude.
The height (above the terrain or water, or global) at which the vehicle will try to hover.
A slider between minimum (0.0 = bouncy) and maximum (1.0 = fast as possible) damped motion of the hover behavior.
The period of bounce (or timescale of exponential approach, depending on the hover efficiency) for the vehicle to hover to the proper height.
A slider between minimum (0.0) and maximum anti-gravity (1.0).
A slider between minimum (0.0) and maximum (1.0) deflection of linear velocity. That is, it's a simple scalar for modulating the strength of linear deflection.
The timescale for exponential success of linear deflection. It is another way to specify how much time it takes for the vehicle's linear velocity to be redirected to it's preferred axis of motion.
A slider between minimum (0.0) and maximum (1.0) deflection of angular orientation. That is, it's a simple scalar for modulating the strength of angular deflection such that the vehicle's preferred axis of motion points toward it's real velocity.
The timescale for exponential success of angular deflection. It's another way to specify the strength of the vehicle's tendency to reorient itself so that it's preferred axis of motion agrees with it's true velocity.
A slider between minimum (0.0 = wobbly) and maximum (1.0 = firm as possible) stability of the vehicle to keep itself upright.
The period of wobble, or timescale for exponential approach, of the vehicle to rotate such that it's preferred "up" axis is oriented along the world's "up" axis.
A slider between anti (-1.0), none (0.0), and maximum (1.0) banking strength.
A slider between static (0.0) and dynamic (1.0) banking. "Static" means the banking scales only with the angle of roll, whereas "dynamic" is a term that also scales with the vehicle's linear speed.
The timescale for banking to exponentially approach it's maximum effect. This is another way to scale the strength of the banking effect, however it affects the term that is proportional to the difference between what the banking behavior is trying to do, and what the vehicle is actually doing.
A rotation of the vehicle's preferred axes of motion and orientation (at, left, up) with respect to the vehicle's local frame (x, y, z).
Flags
This flag prevents linear deflection parallel to world z-axis. This is useful for preventing ground vehicles with large linear deflection, like bumper cars, from climbing their linear deflection into the sky.
For vehicles with vertical attractor that want to be able to climb/dive, for instance, airplanes that want to use the banking feature.
Ignore terrain height when hovering.
Ignore water height when hovering.
Hover at global height instead of height above ground or water.
Hover doesn't push down. Use this flag for hovering vehicles that should be able to jump above their hover height.
Prevents ground vehicles from motoring into the sky. This flag has a subtle effect when used with conjunction with banking: the strength of the banking will decay when the vehicle no longer experiences collisions. The decay timescale is the same as VEHICLE_BANKING_TIMESCALE . This is to help prevent ground vehicles from steering when they are in mid jump.
Steer the vehicle using the mouse. Use this flag to make the angular motor try to make the vehicle turn such that its local x-axis points in the same direction as the client-side camera.
Same as above, but relies on banking. It remaps left-right motions of the client camera (also known as "yaw") to rotations about the vehicle's local x-axis.
Makes mouselook camera rotate independently of the vehicle. By default the client mouselook camera will rotate about with the vehicle, however when this flag is set the camera direction is independent of the vehicle's rotation.
Types
Simple vehicle that bumps along the ground, and likes to move along it's local x-axis.
// most friction for left-right, least for up-down llSetVehicleVectorParam( VEHICLE_LINEAR_FRICTION_TIMESCALE, <30, 1, 1000> ); // no angular friction llSetVehicleVectorParam( VEHICLE_ANGULAR_FRICTION_TIMESCALE, <1000, 1000, 1000> ); // no linear motor llSetVehicleVectorParam( VEHICLE_LINEAR_MOTOR_DIRECTION, <0, 0, 0> ); llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_TIMESCALE, 1000 ); llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 120 ); // no angular motor llSetVehicleVectorParam( VEHICLE_ANGULAR_MOTOR_DIRECTION, <0, 0, 0> ); llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_TIMESCALE, 1000 ); llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 120 ); // no hover (but with timescale of 10 sec if enabled) llSetVehicleFloatParam( VEHICLE_HOVER_HEIGHT, 0 ); llSetVehicleFloatParam( VEHICLE_HOVER_EFFICIENCY, 10 ); llSetVehicleFloatParam( VEHICLE_HOVER_TIMESCALE, 10 ); llSetVehicleFloatParam( VEHICLE_BUOYANCY, 0 ); // maximum linear deflection with timescale of 1 second llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 1 ); llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 1 ); // no angular deflection llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0 ); llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 10 ); // no vertical attractor (doesn't mind flipping over) llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 1 ); llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 1000 ); // no banking llSetVehicleFloatParam( VEHICLE_BANKING_EFFICIENCY, 0 ); llSetVehicleFloatParam( VEHICLE_BANKING_MIX, 1 ); llSetVehicleFloatParam( VEHICLE_BANKING_TIMESCALE, 10 ); // default rotation of local frame llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME, <0, 0, 0, 1> ); // remove these flags llRemoveVehicleFlags( VEHICLE_FLAG_HOVER_WATER_ONLY | VEHICLE_FLAG_HOVER_TERRAIN_ONLY | VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT | VEHICLE_FLAG_HOVER_UP_ONLY ); // set these flags (the limit_roll flag will have no effect // until banking is enabled, if ever) llSetVehicleFlags( VEHICLE_FLAG_NO_DEFLECTION_UP | VEHICLE_FLAG_LIMIT_ROLL_ONLY | VEHICLE_FLAG_LIMIT_MOTOR_UP );
Another vehicle that bounces along the ground but needs the motors to be driven from external controls or timer events.
// most friction for left-right, least for up-down llSetVehicleVectorParam( VEHICLE_LINEAR_FRICTION_TIMESCALE, <100, 2, 1000> ); // no angular friction llSetVehicleVectorParam( VEHICLE_ANGULAR_FRICTION_TIMESCALE, <1000, 1000, 1000> ); // linear motor wins after about a second, decays after about a minute llSetVehicleVectorParam( VEHICLE_LINEAR_MOTOR_DIRECTION, <0, 0, 0> ); llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_TIMESCALE, 1 ); llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 60 ); // angular motor wins after a second, decays in less time than that llSetVehicleVectorParam( VEHICLE_ANGULAR_MOTOR_DIRECTION, <0, 0, 0> ); llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_TIMESCALE, 1 ); llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 0.8 ); // no hover llSetVehicleFloatParam( VEHICLE_HOVER_HEIGHT, 0 ); llSetVehicleFloatParam( VEHICLE_HOVER_EFFICIENCY, 0 ); llSetVehicleFloatParam( VEHICLE_HOVER_TIMESCALE, 1000 ); llSetVehicleFloatParam( VEHICLE_BUOYANCY, 0 ); // maximum linear deflection with timescale of 2 seconds llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 1 ); llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 2 ); // no angular deflection llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0 ); llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 10 ); // critically damped vertical attractor llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 1 ); llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 10 ); // weak negative critically damped banking llSetVehicleFloatParam( VEHICLE_BANKING_EFFICIENCY, -0.2 ); llSetVehicleFloatParam( VEHICLE_BANKING_MIX, 1 ); llSetVehicleFloatParam( VEHICLE_BANKING_TIMESCALE, 1 ); // default rotation of local frame llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME, <0, 0, 0, 1> ); // remove these flags llRemoveVehicleFlags( VEHICLE_FLAG_HOVER_WATER_ONLY | VEHICLE_FLAG_HOVER_TERRAIN_ONLY | VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT); // set these flags llSetVehicleFlags( VEHICLE_FLAG_NO_DEFLECTION_UP | VEHICLE_FLAG_LIMIT_ROLL_ONLY | VEHICLE_FLAG_HOVER_UP_ONLY | VEHICLE_FLAG_LIMIT_MOTOR_UP );
Hovers over water with lots of friction and some angular deflection.
// least for forward-back, most friction for up-down llSetVehicleVectorParam( VEHICLE_LINEAR_FRICTION_TIMESCALE, <10, 3, 2> ); // uniform angular friction (setting it as a scalar rather than a vector) llSetVehicleFloatParam( VEHICLE_ANGULAR_FRICTION_TIMESCALE, 10 ); // linear motor wins after about five seconds, decays after about a minute llSetVehicleVectorParam( VEHICLE_LINEAR_MOTOR_DIRECTION, <0, 0, 0> ); llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_TIMESCALE, 5 ); llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 60 ); // angular motor wins after four seconds, decays in same amount of time llSetVehicleVectorParam( VEHICLE_ANGULAR_MOTOR_DIRECTION, <0, 0, 0> ); llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_TIMESCALE, 4 ); llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 4 ); // hover llSetVehicleFloatParam( VEHICLE_HOVER_HEIGHT, 0 ); llSetVehicleFloatParam( VEHICLE_HOVER_EFFICIENCY, 0.5 ); llSetVehicleFloatParam( VEHICLE_HOVER_TIMESCALE, 2.0 ); llSetVehicleFloatParam( VEHICLE_BUOYANCY, 1 ); // halfway linear deflection with timescale of 3 seconds llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.5 ); llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 3 ); // angular deflection llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.5 ); llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 5 ); // somewhat bouncy vertical attractor llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.5 ); llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 5 ); // weak negative damped banking llSetVehicleFloatParam( VEHICLE_BANKING_EFFICIENCY, -0.3 ); llSetVehicleFloatParam( VEHICLE_BANKING_MIX, 0.8 ); llSetVehicleFloatParam( VEHICLE_BANKING_TIMESCALE, 1 ); // default rotation of local frame llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME, <0, 0, 0, 1> ); // remove these flags llRemoveVehicleFlags( VEHICLE_FLAG_HOVER_TERRAIN_ONLY | VEHICLE_FLAG_LIMIT_ROLL_ONLY | VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT); // set these flags llSetVehicleFlags( VEHICLE_FLAG_NO_DEFLECTION_UP | VEHICLE_FLAG_HOVER_WATER_ONLY | VEHICLE_FLAG_HOVER_UP_ONLY | VEHICLE_FLAG_LIMIT_MOTOR_UP );
Uses linear deflection for lift, no hover, and banking to turn.
// very little friction along forward-back axis llSetVehicleVectorParam( VEHICLE_LINEAR_FRICTION_TIMESCALE, <200, 10, 5> ); // uniform angular friction llSetVehicleFloatParam( VEHICLE_ANGULAR_FRICTION_TIMESCALE, 20 ); // linear motor llSetVehicleVectorParam( VEHICLE_LINEAR_MOTOR_DIRECTION, <0, 0, 0> ); llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_TIMESCALE, 2 ); llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 60 ); // angular motor llSetVehicleVectorParam( VEHICLE_ANGULAR_MOTOR_DIRECTION, <0, 0, 0> ); llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_TIMESCALE, 4 ); llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 8 ); // no hover llSetVehicleFloatParam( VEHICLE_HOVER_HEIGHT, 0 ); llSetVehicleFloatParam( VEHICLE_HOVER_EFFICIENCY, 0.5 ); llSetVehicleFloatParam( VEHICLE_HOVER_TIMESCALE, 1000 ); llSetVehicleFloatParam( VEHICLE_BUOYANCY, 0 ); // linear deflection llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.5 ); llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 0.5 ); // angular deflection llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 1.0 ); llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 2.0 ); // vertical attractor llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.9 ); llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 2 ); // banking llSetVehicleFloatParam( VEHICLE_BANKING_EFFICIENCY, 1 ); llSetVehicleFloatParam( VEHICLE_BANKING_MIX, 0.7 ); llSetVehicleFloatParam( VEHICLE_BANKING_TIMESCALE, 2 ); // default rotation of local frame llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME, <0, 0, 0, 1> ); // remove these flags llRemoveVehicleFlags( VEHICLE_FLAG_NO_DEFLECTION_UP | VEHICLE_FLAG_HOVER_WATER_ONLY | VEHICLE_FLAG_HOVER_TERRAIN_ONLY | VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT | VEHICLE_FLAG_HOVER_UP_ONLY | VEHICLE_FLAG_LIMIT_MOTOR_UP ); // set these flags llSetVehicleFlags( VEHICLE_FLAG_LIMIT_ROLL_ONLY );
Hover, and friction, but no deflection.
// uniform linear friction llSetVehicleFloatParam( VEHICLE_LINEAR_FRICTION_TIMESCALE, 5 ); // uniform angular friction llSetVehicleFloatParam( VEHICLE_ANGULAR_FRICTION_TIMESCALE, 10 ); // linear motor llSetVehicleVectorParam( VEHICLE_LINEAR_MOTOR_DIRECTION, <0, 0, 0> ); llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_TIMESCALE, 5 ); llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 60 ); // angular motor llSetVehicleVectorParam( VEHICLE_ANGULAR_MOTOR_DIRECTION, <0, 0, 0> ); llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_TIMESCALE, 6 ); llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 10 ); // hover llSetVehicleFloatParam( VEHICLE_HOVER_HEIGHT, 5 ); llSetVehicleFloatParam( VEHICLE_HOVER_EFFICIENCY, 0.8 ); llSetVehicleFloatParam( VEHICLE_HOVER_TIMESCALE, 10 ); llSetVehicleFloatParam( VEHICLE_BUOYANCY, 1 ); // no linear deflection llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0 ); llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 5 ); // no angular deflection llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0 ); llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 5 ); // no vertical attractor llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 1 ); llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 1000 ); // no banking llSetVehicleFloatParam( VEHICLE_BANKING_EFFICIENCY, 0 ); llSetVehicleFloatParam( VEHICLE_BANKING_MIX, 0.7 ); llSetVehicleFloatParam( VEHICLE_BANKING_TIMESCALE, 5 ); // default rotation of local frame llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME, <0, 0, 0, 1> ); // remove all flags llRemoveVehicleFlags( VEHICLE_FLAG_NO_DEFLECTION_UP | VEHICLE_FLAG_HOVER_WATER_ONLY | VEHICLE_FLAG_LIMIT_ROLL_ONLY | VEHICLE_FLAG_HOVER_TERRAIN_ONLY | VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT | VEHICLE_FLAG_HOVER_UP_ONLY | VEHICLE_FLAG_LIMIT_MOTOR_UP );
These constants are used in calls to the llSetPrimitiveParams and llGetPrimitiveParams api to specify parameters.
Primitive Parameters
This allows the various primitive shape parameters to be controlled. PRIM_TYPE must be followed by appropriate arguments based on which type is selected.
PRIM_TYPE Values
Sets the primitive to a box, followed by integer hole shape, vector cut, float hollow, vector twist, vector top size, and vector top shear.
Sets the primitive to a cylinder, followed by integer hole shape, vector cut, float hollow, vector twist, vector top size, and vector top shear.
Sets the primitive to a prism, followed by integer hole shape, vector cut, float hollow, vector twist, vector top size, and vector top shear.
Sets the primitive to a sphere, followed by integer hole shape, vector cut, float hollow, vector twist, and vector dimple.
Sets the primitive to a torus, followed by integer hole shape, vector cut, float hollow, vector twist, vector hole size, vector top shear, vector advanced cut, vector taper, float revolutions, float radius offset, and float skew.
Sets the primitive to a tube, followed by integer hole shape, vector cut, float hollow, vector twist, vector hole size, vector top shear, vector advanced cut, vector taper, float revolutions, float radius offset, and float skew.
Sets the primitive to a ring, followed by integer hole shape, vector cut, float hollow, vector twist, vector hole size, vector top shear, vector advanced cut, vector taper, float revolutions, float radius offset, and float skew.
Choose hole shape from one of PRIM_HOLE_DEFAULT, PRIM_HOLE_CIRCLE, PRIM_HOLE_SQUARE, or PRIM_HOLE_TRIANGLE.
Choose material from one of PRIM_MATERIAL_STONE, PRIM_MATERIAL_METAL, PRIM_MATERIAL_GLASS, PRIM_MATERIAL_WOOD, PRIM_MATERIAL_FLESH, PRIM_MATERIAL_PLASTIC, PRIM_MATERIAL_RUBBER, or PRIM_MATERIAL_LIGHT.
Set physics to TRUE or FALSE.
Set temporary on rez to TRUE or FALSE.
Set phantom to TRUE or FALSE.
Sets the position with a vector.
Sets the size with a vector.
Sets the rotation with a rotation.
Followed by an integer face, key id, vector repeats, vector offsets, and float rotation in radians.
Followed by an integer face, vector color, and float alpha.
Followed by an integer face, one of PRIM_SHINY_NONE, PRIM_SHINY_LOW, PRIM_SHINY_MEDIUM, or PRIM_SHINY_HIGH, and one of PRIM_BUMP_NONE, PRIM_BUMP_BRIGHT, PRIM_BUMP_DARK, PRIM_BUMP_WOOD, PRIM_BUMP_BARK, PRIM_BUMP_BRICKS, PRIM_BUMP_CHECKER, PRIM_BUMP_CONCRETE, PRIM_BUMP_TILE, PRIM_BUMP_STONE, PRIM_BUMP_DISKS, PRIM_BUMP_GRAVEL, PRIM_BUMP_BLOBS, PRIM_BUMP_SIDING, PRIM_BUMP_LARGETILE, PRIM_BUMP_STUCCO, PRIM_BUMP_SUCTION, or PRIM_BUMP_WEAVE.
Followed by an integer face and a float glow value (in range 0.0 to 1.0).
These constants are passed to the remote_data event: REMOTE_DATA_CHANNEL, REMOTE_DATA_REQUEST, and REMOTE_DATA_REPLY.
These MASK_* constants are used as arguments to llGetObjectPermMask and llGetInventoryPermMask. These functions return combinations of PERM_* constants.
Mask and Permission Constants
Specifies base permissions. These permissions are identical to owner permissions except in the case that the object is locked. When an object is locked, owner permissions are stripped of move/modify rights (thus, the 'locking'). On unlock, owner permissions revert back to base permissions.
Specifies owner permissions. These are never more permissive than base permissions.
Specifies group permissions. These are never more permissive than owner permissions.
Specifies everyone permissions. These are never more permissive than owner permissions.
Specifies next owner permissions. These are never more permissive than base permissions.
Set if movement is allowed.
Set if modification is allowed.
Set if copying is allowed.
Set if transfers are allowed.
This is returned if all other PERM_* are set.
These constants are passed to the llParcelMediaCommand to control playback of movies and other multimedia within a land parcel.
Parcel Media Constants
Stop the media stream and go back to the first frame.
Pause the media stream (stop playing but stay on current frame).
Start the media stream playing from the current frame and stop when the end is reached.
Used to get or set the parcel's media looping variable.
Use this to get or set the parcel's media texture.
Used to get or set the parcel's media url.
Used to get or set the parcel's media mimetype.
Used to get or set the parcel's media description.
Used to get or set the parcel's media pixel size.
Move a media stream to a specific time.
Applies the media command to the specified agent only.
Completely unloads the movie and restores the original texture.
Sets the parcel option 'Auto scale content'.
This command has been depricated in favor of the PARCEL_MEDIA_COMMAND_LOOP_SET above.
These constants are passed to llSetClickAction to define default behavior when a resident clicks upon a prim.
Click Action Constants
Disables the click action for this prim.
Sets the click-action behavior of this prim to touch.
Sets the click-action behavior of this prim to sit.
Sets the click-action behavior of this prim to buy.
Sets the click-action behavior of this prim to pay.
Sets the click-action behavior of this prim to open.
Sets the click-action behavior of this prim to play.
Sets the click-action behavior of this prim to open-media.
Sets the click-action behavior of this prim to sit.
Sets the click-action behavior of this prim to sit.