diff options
| author | Rider Linden <rider@lindenlab.com> | 2026-03-30 14:12:22 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-30 14:12:22 -0700 |
| commit | f209affdfdf271098843ba400d7a75b00f827233 (patch) | |
| tree | 2c7aef88a74ccb7392035ca8d19ae156911c4891 /indra/newview/llpreviewscript.cpp | |
| parent | c9dcd5b2dce0566731ab4ccd8892e5da146807f3 (diff) | |
| parent | e36c7403e49bf19e6122e61768c6d0cb83272b3b (diff) | |
Merge pull request #5583 from secondlife/rider/script_metadata
Support for metadata and script subtype.
Diffstat (limited to 'indra/newview/llpreviewscript.cpp')
| -rw-r--r-- | indra/newview/llpreviewscript.cpp | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index da788775f1..31909116c7 100644 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -521,7 +521,6 @@ bool LLScriptEdCore::postBuild() "menu_lsl_font_size.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); getChild<LLMenuButton>("font_btn")->setMenu(context_menu, LLMenuButton::MP_BOTTOM_LEFT, true); - bool lua_scripts_enabled = have_lua_enabled(LLUUID::null); mCompileTarget = getChild<LLComboBox>("compile_target"); if (LLScrollListItem* luau_item = mCompileTarget->findItemByValue("luau")) @@ -2058,7 +2057,9 @@ void LLPreviewLSL::saveIfNeeded(bool sync /*= true*/) void LLPreviewLSL::onCompileTargetChanged() { - mScriptEd->processKeywords(mScriptEd->mCompileTarget->getValue().asString() == "luau"); + bool is_lua = (mScriptEd->mCompileTarget->getValue().asString() == "luau"); + mScriptEd->mEditor->setLuauLanguage(is_lua); + mScriptEd->processKeywords(is_lua); } // static @@ -2087,6 +2088,8 @@ void LLPreviewLSL::onLoadComplete(const LLUUID& asset_uuid, LLAssetType::EType t std::string script_name = DEFAULT_SCRIPT_NAME; LLInventoryItem* item = gInventory.getItem(*item_uuid); bool is_modifiable = false; + std::string compile_target; + bool is_lua = false; if (item) { if (!item->getName().empty()) @@ -2097,16 +2100,38 @@ void LLPreviewLSL::onLoadComplete(const LLUUID& asset_uuid, LLAssetType::EType t { is_modifiable = true; } + + // subtype is the language that the script is written in, + // runtime is the VM that the script is running on. + // LSL scripts have 3 possible runtimes: "lsl2", "mono", and "luau". + // Lua scripts have 1 runtime: "luau". + U8 subtype = item->getInventorySubType(); + std::string runtime = item->getRuntime(); + + is_lua = (subtype == SST_LUA); + if (!is_lua && (runtime == "luau")) + { // an lsl script executing on the luau runtime + compile_target = "lsl-luau"; + } + else + { // otherwise, use the runtime as the compile target + // (this may be blank if the script has never been compiled) + compile_target = runtime; + } } + + if (compile_target.empty()) + { + compile_target = is_lua ? "luau" : "mono"; + } + preview->mScriptEd->setScriptName(script_name); preview->mScriptEd->setEnableEditing(is_modifiable); preview->mScriptEd->setAssetID(asset_uuid); preview->mAssetStatus = PREVIEW_ASSET_LOADED; - // Temporary hack to determine if the script is LSL or SLua when loaded from the inventory. - bool is_lua = is_lua_script(std::string(buffer.begin(), buffer.end())); + preview->mScriptEd->mCompileTarget->setValue(compile_target); preview->mScriptEd->mEditor->setLuauLanguage(is_lua); - preview->mScriptEd->mCompileTarget->setValue(is_lua ? "luau" : "lsl-luau"); preview->mScriptEd->processKeywords(is_lua); } else @@ -2714,8 +2739,9 @@ void LLLiveLSLEditor::onCompileTargetChanged() { mScriptEd->mCompileTarget->setEnabled(have_script_upload_cap(mObjectUUID)); mScriptEd->enableSave(getIsModifiable()); - - mScriptEd->processKeywords(mScriptEd->mCompileTarget->getValue().asString() == "luau"); + bool is_lua = mScriptEd->mCompileTarget->getValue().asString() == "luau"; + mScriptEd->mEditor->setLuauLanguage(is_lua); + mScriptEd->processKeywords(is_lua); } void LLLiveLSLEditor::setAssociatedExperience( LLHandle<LLLiveLSLEditor> editor, const LLSD& experience ) |
