Skip to content

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.

The Compiler dropdown at the bottom of the editor has four entries.1

LabelValue sentMeaning
LSL on Mono (recommended)monoLSL source compiled for the Mono runtime
LSL Legacylsl2LSL source compiled for the original LSO runtime
LSL on Lualsl-luauLSL source compiled for the Luau runtime
LualuauSLua 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 target with 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 luau shows LSL on Lua. A script that has never been compiled has no runtime, and the viewer then guesses: source containing default { 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

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.

  • The gutter and the “Line, Column” status count from 0 for LSL and from 1 for Lua8
  • The region replies with compiled plus an errors array; 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_CHANNEL and the Script Warning/Error window. See Errors

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.

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.

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 ExternalEditor setting, or failing that the LL_SCRIPT_EDITOR environment 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 .luau for 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>.log beside 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

  1. Viewer 746d768339: newview/skins/default/xui/en/panel_script_ed.xml:244-259; newview/llpreviewscript.cpp:134-155; newview/llpreviewscript.cpp:556-564 ↩ ↩2

  2. Viewer 746d768339: newview/llviewerassetupload.cpp:834-846 ↩

  3. Viewer 746d768339: newview/llpreviewscript.cpp:2131-2157; newview/llpreviewscript.cpp:158-169 ↩

  4. Viewer 746d768339: newview/llpreviewscript.cpp:2750-2776 ↩

  5. Viewer 746d768339: newview/llpanelcontents.cpp:150-171; newview/llpanelcontents.cpp:300-306; newview/llviewerinventory.cpp:1789-1800 ↩

  6. Viewer 746d768339: newview/skins/default/xui/en/menu_viewer.xml:1362-1404; newview/llcompilequeue.cpp:386-392; newview/llcompilequeue.cpp:481-497 ↩

  7. Viewer 746d768339: newview/skins/default/xui/en/panel_script_ed.xml:170-180 ↩

  8. Viewer 746d768339: newview/llscripteditor.cpp:321; newview/llpreviewscript.cpp:780-790 ↩

  9. 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 ↩

  10. 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 ↩

  11. Viewer 746d768339: newview/llpreviewscript.cpp:87-125; newview/llpreviewscript.cpp:891-906; newview/app_settings/settings.xml:4174-4184 ↩

  12. Viewer 746d768339: newview/llsyntaxid.cpp:44-53; newview/llsyntaxid.cpp:90-121; newview/llsyntaxid.cpp:287-293 ↩

  13. Viewer 746d768339: llui/llkeywords.cpp:355; llui/llkeywords.cpp:361-370 ↩

  14. Viewer 746d768339: newview/skins/default/xui/en/panel_script_ed.xml:230-234; newview/llpreviewscript.cpp:1144-1245 ↩

  15. 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 ↩

  16. 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 ↩

  17. Viewer 746d768339: newview/llpreviewscript.cpp:1190-1213; newview/llpreviewscript.cpp:1626-1639 ↩

  18. Viewer 746d768339: newview/llpreviewscript.cpp:1649-1701 ↩

  19. 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 ↩

  20. 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 ↩