Support for metadata and script subtype.#5583
Support for metadata and script subtype.#5583Rider-Linden merged 4 commits intoproject/lua_editorfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds viewer-side support for script language subtype (LSL vs Lua) and new script.runtime inventory metadata to pick the correct editor language mode and default compile target when opening scripts.
Changes:
- Update script preview editor to switch language mode (
setLuauLanguage) when the compile target changes. - On inventory script load, derive
is_luafrom inventory subtype and derive compile target fromscript.runtime(with sensible defaults). - Extend inventory model/serialization with a new
mRuntimefield (LLSD + legacy metadata import).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
indra/newview/llpreviewscript.cpp |
Uses subtype/runtime to initialize editor language + compile target; updates compile-target-change handling to set language mode. |
indra/llinventory/llinventory.h |
Adds getRuntime() / setRuntime() APIs and stores runtime string on inventory objects. |
indra/llinventory/llinventory.cpp |
Imports runtime from legacy metadata, includes runtime in LLSD serialization/deserialization, and copies runtime during object/item copy. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| bool is_lua = (mScriptEd->mCompileTarget->getValue().asString() == "luau"); | ||
| mScriptEd->mEditor->setLuauLanguage(is_lua); | ||
| mScriptEd->processKeywords(is_lua); |
There was a problem hiding this comment.
LLPreviewLSL::onCompileTargetChanged() now updates the editor’s language mode via setLuauLanguage(), but LLLiveLSLEditor::onCompileTargetChanged() in the same file still only calls processKeywords(...). If setLuauLanguage() is required for correct parsing/diagnostics (not just highlighting), the live editor path should be updated similarly to keep behavior consistent when changing compile targets.
| if (metadata.has("script") && metadata["script"].has("runtime")) | ||
| { | ||
| setRuntime(metadata["script"]["runtime"].asString()); | ||
| } | ||
| else | ||
| { | ||
| setRuntime(std::string()); | ||
| } |
There was a problem hiding this comment.
In LLInventoryItem::importLegacyStream(), runtime is applied while processing the metadata line. However, the legacy exportLegacyStream() format writes metadata before the type line, so mType may still be unset when setRuntime() runs, and the runtime can be lost. A robust fix is to cache the parsed runtime value from metadata and apply it after the type field has been read (or make setRuntime() independent of current mType during import).
| if (metadata.has("script") && metadata["script"].has("runtime")) | ||
| { | ||
| setRuntime(metadata["script"]["runtime"].asString()); | ||
| } | ||
| else | ||
| { | ||
| setRuntime(std::string()); | ||
| } |
There was a problem hiding this comment.
Runtime is now imported from legacy metadata["script"]["runtime"], but LLInventoryItem::exportLegacyStream() currently only emits a metadata line when a thumbnail is present and does not serialize script.runtime at all. That means mRuntime will not round-trip through the viewer’s legacy inventory cache/export format. Consider extending legacy export metadata to include script.runtime (and emitting metadata when runtime is present even if no thumbnail is set).
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| { | ||
| setRuntime(std::string()); | ||
| } | ||
|
|
There was a problem hiding this comment.
You probably want this in LLInventoryItem::fromLLSD(), not in category.
importLegacyStream is for notecards, asset cache and udp messages, for ecerything else, it's fromLLSD
There was a problem hiding this comment.
Actually. I can remove that altogether here. runtime will never apply to a folder.
Description
Uses script subtype (LSL/lua) and new script.runtime metadata to select correct language parser and default compile target in editor.
Issue #4840
Depends On
https://github.com/secondlife/agent-inventory-service/pull/77
https://github.com/secondlife/server/pull/2414