Script editor
The script editor is part of the viewer, not the simulator. It holds the source text, sends it to the region to compile when you save, and shows what comes back. Everything on this page is viewer behaviour as of the Second Life Viewer 26.5 release; third-party viewers may differ, and nothing here says how the simulator compiles or runs the script.
Compiler targets
Section titled “Compiler targets”The Compiler dropdown at the bottom of the editor has four entries.1
| Label | Value sent | Meaning |
|---|---|---|
| LSL on Mono (recommended) | mono | LSL source compiled for the Mono runtime |
| LSL Legacy | lsl2 | LSL source compiled for the original LSO runtime |
| LSL on Lua | lsl-luau | LSL source compiled for the Luau runtime |
| Lua | luau | SLua source, see LSL vs SLua |
- The two Lua entries are only enabled when the region’s simulator features report
LuaScriptsEnabled; elsewhere they are greyed out1 - The chosen value is sent as
targetwith every save, both for scripts in your inventory and for scripts in an object; object saves also carry the running flag and the associated Experience2 - When a script opens, the dropdown shows the runtime recorded in the script’s inventory metadata; an LSL script recorded as running on
luaushows LSL on Lua. A script that has never been compiled has no runtime, and the viewer then guesses: source containingdefault {is treated as LSL on Mono, anything else as Lua3 - For a script in an object the simulator’s reply to the running-state query overrides that guess with its own Mono, Luau and Luau-language flags4
New scripts default to Lua on Lua-enabled regions. The New Script button in the Build tool’s Content tab is a flyout with LSL and Lua entries; it selects Lua whenever the region reports LuaScriptsEnabled, and a new LSL script from it is created with the mono VM. A new script created in your inventory is also requested as Lua on such regions, and the server picks the matching default script.5 If you want LSL, choose it explicitly.
Build > Scripts also offers bulk recompiles of every script in the selected objects: Recompile LSL Scripts (Mono), (Legacy LSL) and (LSL on Lua), and Recompile Lua Scripts. The queue skips scripts you cannot both copy and modify, and scripts whose source language does not match the target, so an LSL script is never sent to the Lua compiler.6
Source size
Section titled “Source size”The editor’s text control accepts at most 262,144 characters (256 KB) of source.7 This is a viewer limit on the source text; it is separate from the script’s memory limit, which applies to the compiled script. See Limits.
Line numbers and compile errors
Section titled “Line numbers and compile errors”- The gutter and the “Line, Column” status count from 0 for LSL and from 1 for Lua8
- The region replies with
compiledplus anerrorsarray; the editor prints “Compile successful!” or lists each error, and selecting an entry moves the cursor to its row and column. A save that never reached the compiler shows “File upload failed:” and the reason9 - Run-time errors do not appear in the editor; they go to
DEBUG_CHANNELand the Script Warning/Error window. See Errors
Keyword help
Section titled “Keyword help”Help > Keyword Help… opens the LSL REFERENCE window (LUA REFERENCE for a Lua script), an embedded browser with a keyword list and a Follow cursor checkbox. With it ticked (the ScriptHelpFollowsCursor setting, default off) the window follows the keyword under the cursor; otherwise it stays on the keyword you picked.10
The page it loads is the LSLHelpURL setting with [LSL_STRING] replaced by the keyword; the default is https://wiki.secondlife.com/wiki/[LSL_STRING], and an empty keyword opens LSL_Portal. In a Lua script ll.GetOwner is mapped to llGetOwner before substitution, Luau library symbols (math., string., table. and so on) go to the Luau library reference, and other Lua symbols to the wiki’s Lua page.11 Because the substitution is flat, the setting can only point at a site where one URL pattern serves functions, events and constants alike; lsl.dev keeps them under /functions/, /events/ and /constants/, so it cannot be set as the target directly.
Syntax highlighting and tooltips
Section titled “Syntax highlighting and tooltips”Highlighting, the keyword list and the hover tooltips come from LLSD keyword files. The viewer ships keywords_lsl_default.xml and keywords_lua_default.xml, and when the region’s simulator features include an LSLSyntaxId it fetches current definitions from the region’s ScriptDefinitions capability (falling back to the older LSLSyntax capability), caching them by that id. A region may omit the file for a language it does not support, in which case the previous definitions are kept.12 In practice a new function gets highlighting and a tooltip once the region you are on publishes definitions that include it.
A function’s tooltip is its signature followed by Energy: (omitted when the definition gives a negative energy) and, when the definition has one, Sleep:, then its description; constants show their type and value.13 The sleep is the forced delay the simulator adds after the call, as listed on each function page here.
External editors
Section titled “External editors”Edit… below the compiler dropdown hands the script to another program.14 Set it up under Preferences > Advanced > Script Development, which opens the SCRIPT DEVELOPMENT SETTINGS window.15
- The command comes from the
ExternalEditorsetting, or failing that theLL_SCRIPT_EDITORenvironment variable, with"%s"standing for the file; with neither set the viewer falls back to the operating system’s open handler for the file16 - The viewer writes
sl_script_<name>_<hash>.lsl(or.luaufor a Lua script) in the system temp directory and watches it; saving in the external editor reloads the text into the viewer’s editor, and you still save and compile from the viewer17 - Compile errors from a script open externally are also written to
<file>.logbeside the temp file, one per line with a timestamp header18
The same window configures a WebSocket JSON-RPC server for editor plug-ins such as the VS Code extension. ExternalWebsocketSyncEnable is on by default, listening on port 9020 for local connections only; with ExternalWebsocketForwardDebug (also on by default) the viewer forwards the script’s llOwnerSay output and DEBUG_CHANNEL errors to the connected editor.19 A VS Code Tight Integration checkbox is meant to make Edit… launch VS Code through the code command with a vscode:// URI instead of writing a temp file. In this release the editor tests a differently named setting (ExternalWebsocketSyncTightIntegration) that the checkbox does not set, so Edit… takes the temp-file path regardless.20
Reference
Section titled “Reference”- Script memory and limits, Errors, LSL vs SLua
- Limits, Scripts, Experiences
DEBUG_CHANNEL,llOwnerSay
Footnotes
Section titled “Footnotes”-
Viewer
746d768339:newview/skins/default/xui/en/panel_script_ed.xml:244-259;newview/llpreviewscript.cpp:134-155;newview/llpreviewscript.cpp:556-564↩ ↩2 -
Viewer
746d768339:newview/llviewerassetupload.cpp:834-846↩ -
Viewer
746d768339:newview/llpreviewscript.cpp:2131-2157;newview/llpreviewscript.cpp:158-169↩ -
Viewer
746d768339:newview/llpreviewscript.cpp:2750-2776↩ -
Viewer
746d768339:newview/llpanelcontents.cpp:150-171;newview/llpanelcontents.cpp:300-306;newview/llviewerinventory.cpp:1789-1800↩ -
Viewer
746d768339:newview/skins/default/xui/en/menu_viewer.xml:1362-1404;newview/llcompilequeue.cpp:386-392;newview/llcompilequeue.cpp:481-497↩ -
Viewer
746d768339:newview/skins/default/xui/en/panel_script_ed.xml:170-180↩ -
Viewer
746d768339:newview/llscripteditor.cpp:321;newview/llpreviewscript.cpp:780-790↩ -
Viewer
746d768339:newview/llpreviewscript.cpp:1993-2001;newview/llpreviewscript.cpp:2020-2024;newview/llpreviewscript.cpp:535;newview/llpreviewscript.cpp:1253-1273;newview/skins/default/xui/en/strings.xml:2681-2684↩ -
Viewer
746d768339:newview/skins/default/xui/en/panel_script_ed.xml:136-145;newview/skins/default/xui/en/floater_lsl_guide.xml:19-24;newview/llpreviewscript.cpp:1001-1048;newview/llpreviewscript.cpp:815-818;newview/app_settings/settings.xml:10692-10701↩ -
Viewer
746d768339:newview/llpreviewscript.cpp:87-125;newview/llpreviewscript.cpp:891-906;newview/app_settings/settings.xml:4174-4184↩ -
Viewer
746d768339:newview/llsyntaxid.cpp:44-53;newview/llsyntaxid.cpp:90-121;newview/llsyntaxid.cpp:287-293↩ -
Viewer
746d768339:llui/llkeywords.cpp:355;llui/llkeywords.cpp:361-370↩ -
Viewer
746d768339:newview/skins/default/xui/en/panel_script_ed.xml:230-234;newview/llpreviewscript.cpp:1144-1245↩ -
Viewer
746d768339:newview/skins/default/xui/en/panel_preferences_advanced.xml:228-235;newview/llfloaterpreference.cpp:1932-1935;newview/skins/default/xui/en/floater_scripting_settings.xml:9↩ -
Viewer
746d768339:newview/llexternaleditor.cpp:37-57;newview/llpreviewscript.cpp:1215-1234;newview/app_settings/settings.xml:14157-14167;newview/skins/default/xui/en/strings.xml:4052-4057↩ -
Viewer
746d768339:newview/llpreviewscript.cpp:1190-1213;newview/llpreviewscript.cpp:1626-1639↩ -
Viewer
746d768339:newview/llpreviewscript.cpp:1649-1701↩ -
Viewer
746d768339:newview/app_settings/settings.xml:14168-14200;newview/app_settings/settings.xml:14212-14222;newview/llscripteditorws.cpp:291-295;newview/llfloaterimnearbychathandler.cpp:567-582↩ -
Viewer
746d768339:newview/skins/default/xui/en/floater_scripting_settings.xml:85-91;newview/app_settings/settings.xml:14201-14211;newview/llscripteditorws.cpp:297-301;newview/llpreviewscript.cpp:1163-1166;newview/llscripteditorws.cpp:383-410↩