summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2026-03-26 09:59:43 -0700
committerRider Linden <rider@lindenlab.com>2026-03-26 09:59:43 -0700
commit4df8fe0138b992d91ee9ca7abe972d41df8df00d (patch)
tree9ce73f591c331259b5ec2f8a339bc929578c12f7
parentccc10aeda7a3db0fd53cb249b24d22049bae1b94 (diff)
Support for metadata and script subtype.
-rw-r--r--indra/llinventory/llinventory.cpp65
-rw-r--r--indra/llinventory/llinventory.h3
-rw-r--r--indra/newview/llpreviewscript.cpp35
3 files changed, 98 insertions, 5 deletions
diff --git a/indra/llinventory/llinventory.cpp b/indra/llinventory/llinventory.cpp
index 3defad8f3b..c83717fef5 100644
--- a/indra/llinventory/llinventory.cpp
+++ b/indra/llinventory/llinventory.cpp
@@ -61,6 +61,8 @@ static const std::string INV_SALE_INFO_LABEL("sale_info");
static const std::string INV_FLAGS_LABEL("flags");
static const std::string INV_CREATION_DATE_LABEL("created_at");
static const std::string INV_TOGGLED_LABEL("toggled");
+static const std::string INV_SCRIPT_LABEL("script");
+static const std::string INV_RUNTIME_LABEL("runtime");
// key used by agent-inventory-service
static const std::string INV_ASSET_TYPE_LABEL_WS("type_default");
@@ -109,6 +111,7 @@ void LLInventoryObject::copyObject(const LLInventoryObject* other)
mName = other->mName;
mThumbnailUUID = other->mThumbnailUUID;
mFavorite = other->mFavorite;
+ mRuntime = other->mRuntime;
}
const LLUUID& LLInventoryObject::getUUID() const
@@ -131,6 +134,11 @@ bool LLInventoryObject::getIsFavorite() const
return mFavorite;
}
+std::string LLInventoryObject::getRuntime() const
+{
+ return mRuntime;
+}
+
const std::string& LLInventoryObject::getName() const
{
return mName;
@@ -190,6 +198,18 @@ void LLInventoryObject::setFavorite(bool favorite)
mFavorite = favorite;
}
+void LLInventoryObject::setRuntime(std::string_view runtime)
+{
+ if (getType() == LLAssetType::AT_LSL_TEXT)
+ {
+ mRuntime = runtime;
+ }
+ else
+ {
+ mRuntime.clear();
+ }
+}
+
void LLInventoryObject::setType(LLAssetType::EType type)
{
mType = type;
@@ -279,6 +299,15 @@ bool LLInventoryObject::importLegacyStream(std::istream& input_stream)
{
setFavorite(false);
}
+
+ if (metadata.has("script") && metadata["script"].has("runtime"))
+ {
+ setRuntime(metadata["script"]["runtime"].asString());
+ }
+ else
+ {
+ setRuntime(std::string());
+ }
}
else if(0 == strcmp("name", keyword))
{
@@ -421,6 +450,7 @@ void LLInventoryItem::copyItem(const LLInventoryItem* other)
mInventoryType = other->mInventoryType;
mFlags = other->mFlags;
mCreationDate = other->mCreationDate;
+ mRuntime = other->mRuntime;
}
// If this is a linked item, then the UUID of the base object is
@@ -784,6 +814,16 @@ bool LLInventoryItem::importLegacyStream(std::istream& input_stream)
{
setFavorite(false);
}
+
+ if (metadata.has("script") && metadata["script"].has("runtime"))
+ {
+ setRuntime(metadata["script"]["runtime"].asString());
+ }
+ else
+ {
+ setRuntime(std::string());
+ }
+
}
else if(0 == strcmp("inv_type", keyword))
{
@@ -949,6 +989,11 @@ void LLInventoryItem::asLLSD( LLSD& sd ) const
sd[INV_FAVORITE_LABEL] = LLSD().with(INV_TOGGLED_LABEL, mFavorite);
}
+ if (!mRuntime.empty())
+ {
+ sd[INV_SCRIPT_LABEL] = LLSD().with(INV_RUNTIME_LABEL, mRuntime);
+ }
+
U32 mask = mPermissions.getMaskBase();
if(((mask & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED)
|| (mAssetUUID.isNull()))
@@ -1052,6 +1097,17 @@ bool LLInventoryItem::fromLLSD(const LLSD& sd, bool is_new)
continue;
}
+ if (i->first == INV_SCRIPT_LABEL)
+ {
+ const LLSD& script_map = i->second;
+ const std::string w = INV_RUNTIME_LABEL;
+ if (script_map.has(w))
+ {
+ mRuntime = script_map[w].asString();
+ }
+ continue;
+ }
+
if (i->first == INV_PERMISSIONS_LABEL)
{
mPermissions.importLLSD(i->second);
@@ -1471,6 +1527,15 @@ bool LLInventoryCategory::importLegacyStream(std::istream& input_stream)
{
setFavorite(false);
}
+ if (metadata.has("script") && metadata["script"].has("runtime"))
+ {
+ setRuntime(metadata["script"]["runtime"].asString());
+ }
+ else
+ {
+ setRuntime(std::string());
+ }
+
}
else
{
diff --git a/indra/llinventory/llinventory.h b/indra/llinventory/llinventory.h
index 58dea83617..ad270f317d 100644
--- a/indra/llinventory/llinventory.h
+++ b/indra/llinventory/llinventory.h
@@ -72,6 +72,7 @@ public:
const LLUUID& getParentUUID() const;
virtual const LLUUID& getThumbnailUUID() const;
virtual bool getIsFavorite() const;
+ virtual std::string getRuntime() const;
virtual const std::string& getName() const;
virtual LLAssetType::EType getType() const;
LLAssetType::EType getActualType() const; // bypasses indirection for linked items
@@ -88,6 +89,7 @@ public:
void setParent(const LLUUID& new_parent);
virtual void setThumbnailUUID(const LLUUID& thumbnail_uuid);
virtual void setFavorite(bool favorite);
+ virtual void setRuntime(std::string_view runtime);
void setType(LLAssetType::EType type);
virtual void setCreationDate(time_t creation_date_utc); // only stored for items
@@ -114,6 +116,7 @@ protected:
LLUUID mParentUUID; // Parent category. Root categories have LLUUID::NULL.
LLUUID mThumbnailUUID;
bool mFavorite;
+ std::string mRuntime;
LLAssetType::EType mType;
std::string mName;
time_t mCreationDate; // seconds from 1/1/1970, UTC
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index da788775f1..536ee73d5e 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