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
Comments [Hide comments/form]
Not clear yet is what happens with multiple script files in a single object? Are they effectively appended one to the next? When you reset one are you resetting all for the same object?

Also reference resetting.
-- ZenoConcord (2005-05-03 16:20:52)
As far as I know, multiple scripts in a prim/object do not affect one another and, essentially, act independently. However, I've noticed some problems with certain functions I don't recall specifically at this time.
-- EepQuirk (2005-05-04 11:15:36)
dataserver functions, and scripts with the same inventory key will result in interesting side effects.
-- BlindWanderer (2005-05-05 02:38:33)
I like how you use the term "interesting" :D

That's like saying "Getting shot with a blow-dart produces interesting side effects".
-- KeknehvPsaltery (2005-06-17 16:09:57)
lol, good analogy Keknehv, but how could scripts have the same inventory key?
-- SchitsoMonkey (2005-07-23 23:53:06)
The problem is repeatable by following these steps:
1. Create a folder in your avatar's inventory.
2. Copy a script into that folder.
3. Copy the same script multiple times into that folder.
4. Drag the folder into the contents of an object.
The object should relabel the scripts sequentially, however, the scripts' bytecode and sourcecode will still have identical keys.
Attempting to "Recompile all scripts in selection" will not recompile the newly-dropped scripts - in order to make them all run, you have to open each in the script text editor, change it a little, check the running checkbox, and hit compile.
-- ChristopherOmega (2005-08-15 13:59:02)
See communications.
-- ChristopherOmega (2006-04-04 10:05:27)
That link to the no-copy/no-mod explanation is broken...
-- VirusCollector (2006-10-01 11:49:16)
Yay! I've been noticed!
-- VirusCollector (2006-10-04 18:53:54)