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

LSL Wiki : script

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are


A script is a Second Life inventory item that contains LSL code. If a script is placed in a prim or object, the script can then control the behavior and appearance of that prim or object, which can cause the prim or object to (among many other things) change color, move, interact with the world, etc. A single prim or object can contain multiple scripts, each one running independently of the others (although they can all have effects on the same prim or object).

A script is edited using the built-in script editor or external alternate editors (via cut-and-paste). To see the source code that makes up a script, if the user has permission to view it, simply double-click on its name and the editing window will open up. Each script can have permissions independent of the permissions of an object it is contained in. To be editable, a script must be modifiable by the user, or it could be shared to a group the user is a member of.


Internally, each script consists of two items: the script's source code, which is compiled into "bytecode" by the client and uploaded to the simulator. This generates the second item, a 16kb memory image which is executed in a virtual machine on the sim and contains the script's bytecode, stack, and heap. This memory basically represents the current status of the script (not to be confused with its state) and is saved/restored when the sim restarts (or when you attach/detach a scripted object).

Each script receives a time slice (portion) 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 (section) of memory, preventing scripts from writing into protected simulator memory or into other scripts (which can include multiple scripts in the same prim or object), making it much harder for them to crash the simulator.

Example Scripts


llGetScriptName - Returns the name of the script that calls the function.
llGetScriptState - Returns TRUE if the script identified by name is running.
llSetScriptState - Changes whether or not the script is running.
llRemoteLoadScriptPin - If permissions and PIN allows, this function will copy a script to a remote object
llSetRemoteScriptAccessPin - Sets the PIN (personal ID number) necessary to remotely load a script.
llScriptDanger - Determines if a position is over land that might disable or delete a script.
llResetScript - Resets all values in a script and restarts it.
llResetOtherScript - Performs llResetScript on a different, named script.
llGetFreeMemory - Returns the amount of free memory in the script, in bytes.


Crash Course | LSL | Memory | Object | Prim | Item
There are 9 comments on this page. [Display comments/form]