Skip to content
lsl.devlsl.devLSL Dev

Scripts

This page is about the script itself rather than what it does in the world: how it starts and resets, how it learns the parameters it was rezzed with, how it controls other scripts in the same prim or loads scripts into other prims, and how much memory it uses. The events that drive a script are covered under Events, and its timer and clocks under Time.

Concepts for scripts

Script functions and events

eventstate_entry()
eventstate_exit()
eventon_rez(integer start_param)
voidllResetScript()
voidllResetOtherScript(string script)
integerllGetStartParameter()
stringllGetStartString()
stringllGetScriptName()
voidllSetScriptState(string script, integer running)
integerllGetScriptState(string script)
voidllRemoteLoadScriptPin(key target, string script, integer pin, integer running, integer start_param)
voidllSetRemoteScriptAccessPin(integer pin)
integerllGetUsedMemory()
integerllGetFreeMemory()
integerllGetMemoryLimit()
integerllSetMemoryLimit(integer limit)
voidllScriptProfiler(integer flags)
integerllGetSPMaxMemory()

Scripts as inventory items

Scripts are items in a prim’s inventory. Listing, giving and removing them is covered under Inventory.

Script functions in detail

eventstate_entry()
Triggered whenever a new state is entered, including at script start. It is always the first event handled
eventstate_exit()
Triggered when the state command moves out of the current state, before the new state’s state_entry
eventon_rez(integer start_param)
Triggered when the object is rezzed, with start_param from the rezzing call. Also triggers on attachments at login or when attached from inventory
voidllResetScript()
Resets the script
voidllResetOtherScript(string script)
Resets script name in the prim. If the script is not running, this call has no effect
integerllGetStartParameter()
Returns the start parameter passed to the object when it was rezzed, or 0 if an agent rezzed it
stringllGetStartString()
Returns the string passed to the root prim with REZ_PARAM_STRING in llRezObjectWithParams, or an empty string if an agent rezzed it
stringllGetScriptName()
Returns the name of the script that called this function
voidllSetScriptState(string script, integer running)
Set the running state of the script name. The script stops when its time slice ends, so a script stopping itself may run a little further
integerllGetScriptState(string script)
Returns TRUE if the named script in the prim is running
voidllRemoteLoadScriptPin(key target, string script, integer pin, integer running, integer start_param)
Copy script name into target and set to running with a start_param only if target’s PIN matches pin. Only works if the script owner can modify target; a script of the same name there is silently replaced
voidllSetRemoteScriptAccessPin(integer pin)
Sets this prim’s PIN for llRemoteLoadScriptPin. A PIN of 0 disables remote loading
integerllGetUsedMemory()
Returns the bytes of memory the script uses. Does not require llScriptProfiler
integerllGetFreeMemory()
Returns the free bytes between the script’s current use and its memory limit
integerllGetMemoryLimit()
Get the maximum memory a script can use
integerllSetMemoryLimit(integer limit)
Request limit bytes to be reserved for this script. The limit cannot be set lower than the memory already in use. Returns TRUE on success
voidllScriptProfiler(integer flags)
Enables or disables the scripts profiling state, with PROFILE_SCRIPT_MEMORY or PROFILE_NONE
integerllGetSPMaxMemory()
Returns the peak memory in bytes used while the profiler was last active

Additional

Constant groups ScriptProfileMode 2

See also Feature EventsFeature TimeFeature InventoryCategory ScriptPage state

Adapted from the Second Life Wiki pages LlResetScript (revision 1216200, 2024-02-16), LlResetOtherScript (revision 1194467, 2015-01-22), LlSetScriptState (revision 1194424, 2015-01-22), LlRemoteLoadScriptPin (revision 1208255, 2019-04-02), LlSetMemoryLimit (revision 1194459, 2015-01-22), LlGetMemoryLimit (revision 1194206, 2015-01-22), LlScriptProfiler (revision 1196004, 2015-03-31), LlGetUsedMemory (revision 1218635, 2026-02-18), LlGetFreeMemory (revision 1218634, 2026-02-18) and LlGetScriptName (revision 1194254, 2015-01-22), including the transcluded Template:LSL Function/inventory (revision 1191151, 2014-06-07), Template:Issues/SVC-1853 (revision 1155886, 2011-10-18), Template:LSL Function/boolean (revision 1185613, 2013-12-24), Template:Issues/SVC-3321 (revision 118342, 2008-10-26), Template:LSL Function/give (revision 1212353, 2022-09-24) and Template:Issues/SVC-388 (revision 955732, 2010-07-03); history, by Second Life Wiki contributors, under CC BY-SA 3.0. Last wiki edit: .