summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2025-03-17 18:56:07 +0200
committerAndrey Lihatskiy <alihatskiy@productengine.com>2025-03-17 19:19:14 +0200
commitfe5d7d41335ca22c8078ddaeb9fe40e6b0d57b6d (patch)
tree27d59622a17022e55ec2fb50430b0e997e8d315a
parenta0e8b5ffc7cea8ce73a4e6a594eef9e87714972d (diff)
#3731 Follow-up: Use SLua defaults only on SLua-enabled regions (#3753)
-rw-r--r--indra/newview/llpanelcontents.cpp133
-rw-r--r--indra/newview/llviewerinventory.cpp52
2 files changed, 102 insertions, 83 deletions
diff --git a/indra/newview/llpanelcontents.cpp b/indra/newview/llpanelcontents.cpp
index e403462f09..e9e48382b4 100644
--- a/indra/newview/llpanelcontents.cpp
+++ b/indra/newview/llpanelcontents.cpp
@@ -198,7 +198,7 @@ void LLPanelContents::onClickNewScript(void *userdata)
{
const bool children_ok = true;
LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getFirstRootObject(children_ok);
- if(object)
+ if (object)
{
LLPermissions perm;
perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null);
@@ -227,78 +227,87 @@ void LLPanelContents::onClickNewScript(void *userdata)
// This temporary workaround should be removed after a server-side fix.
// See https://github.com/secondlife/viewer/issues/3731 for more information.
//
- if (std::string::size_type pos = desc.find("lsl2"); pos != std::string::npos)
+ LLViewerRegion* region = object->getRegion();
+ if (region && region->simulatorFeaturesReceived())
{
- desc.replace(pos, 4, "SLua");
- }
-
- auto scriptCreationCallback = [object](const LLUUID& inv_item)
+ LLSD simulatorFeatures;
+ region->getSimulatorFeatures(simulatorFeatures);
+ if (simulatorFeatures["LuaScriptsEnabled"].asBoolean())
{
- if (!inv_item.isNull())
+ if (std::string::size_type pos = desc.find("lsl2"); pos != std::string::npos)
{
- LLViewerInventoryItem* item = gInventory.getItem(inv_item);
- if (item)
- {
- const std::string hello_lua_script =
- "function state_entry()\n"
- " ll.Say(0, \"Hello, Avatar!\")\n"
- "end\n"
- "\n"
- "function touch_start(total_number)\n"
- " ll.Say(0, \"Touched.\")\n"
- "end\n"
- "\n"
- "-- Simulate the state_entry event\n"
- "state_entry()\n";
+ desc.replace(pos, 4, "SLua");
+ }
- auto scriptUploadFinished = [object, item](LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD response)
+ auto scriptCreationCallback = [object](const LLUUID& inv_item)
+ {
+ if (!inv_item.isNull())
+ {
+ LLViewerInventoryItem* item = gInventory.getItem(inv_item);
+ if (item)
{
- LLPointer<LLViewerInventoryItem> new_script = new LLViewerInventoryItem(item);
- object->saveScript(new_script, true, true);
+ const std::string hello_lua_script =
+ "function state_entry()\n"
+ " ll.Say(0, \"Hello, Avatar!\")\n"
+ "end\n"
+ "\n"
+ "function touch_start(total_number)\n"
+ " ll.Say(0, \"Touched.\")\n"
+ "end\n"
+ "\n"
+ "-- Simulate the state_entry event\n"
+ "state_entry()\n";
- // Delete the temporary item from the user's inventory after rezzing it in the object's inventory
- gInventory.deleteObject(item->getUUID());
- gInventory.notifyObservers();
- };
+ auto scriptUploadFinished = [object, item](LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD response)
+ {
+ LLPointer<LLViewerInventoryItem> new_script = new LLViewerInventoryItem(item);
+ object->saveScript(new_script, true, true);
- std::string url = gAgent.getRegion()->getCapability("UpdateScriptAgent");
- if (!url.empty())
- {
- LLResourceUploadInfo::ptr_t uploadInfo(std::make_shared<LLScriptAssetUpload>(
- item->getUUID(),
- "luau",
- hello_lua_script,
- scriptUploadFinished,
- nullptr));
+ // Delete the temporary item from the user's inventory after rezzing it in the object's inventory
+ gInventory.deleteObject(item->getUUID());
+ gInventory.notifyObservers();
+ };
- LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo);
- }
+ std::string url = gAgent.getRegion()->getCapability("UpdateScriptAgent");
+ if (!url.empty())
+ {
+ LLResourceUploadInfo::ptr_t uploadInfo(std::make_shared<LLScriptAssetUpload>(
+ item->getUUID(),
+ "luau",
+ hello_lua_script,
+ scriptUploadFinished,
+ nullptr));
- gInventory.updateItem(item);
- gInventory.notifyObservers();
- }
- }
- };
- LLPointer<LLBoostFuncInventoryCallback> cb = new LLBoostFuncInventoryCallback(scriptCreationCallback);
+ LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo);
+ }
- LLMessageSystem* msg = gMessageSystem;
- msg->newMessageFast(_PREHASH_CreateInventoryItem);
- msg->nextBlock(_PREHASH_AgentData);
- msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- msg->nextBlock(_PREHASH_InventoryBlock);
- msg->addU32Fast(_PREHASH_CallbackID, gInventoryCallbacks.registerCB(cb));
- msg->addUUIDFast(_PREHASH_FolderID, gInventory.getRootFolderID());
- msg->addUUIDFast(_PREHASH_TransactionID, LLTransactionID::tnull);
- msg->addU32Fast(_PREHASH_NextOwnerMask, PERM_MOVE | PERM_TRANSFER);
- msg->addS8Fast(_PREHASH_Type, LLAssetType::AT_LSL_TEXT);
- msg->addS8Fast(_PREHASH_InvType, LLInventoryType::IT_LSL);
- msg->addU8Fast(_PREHASH_WearableType, NO_INV_SUBTYPE);
- msg->addStringFast(_PREHASH_Name, "New Script");
- msg->addStringFast(_PREHASH_Description, desc);
+ gInventory.updateItem(item);
+ gInventory.notifyObservers();
+ }
+ }
+ };
+ LLPointer<LLBoostFuncInventoryCallback> cb = new LLBoostFuncInventoryCallback(scriptCreationCallback);
- gAgent.sendReliableMessage();
- return;
+ LLMessageSystem* msg = gMessageSystem;
+ msg->newMessageFast(_PREHASH_CreateInventoryItem);
+ msg->nextBlock(_PREHASH_AgentData);
+ msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+ msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+ msg->nextBlock(_PREHASH_InventoryBlock);
+ msg->addU32Fast(_PREHASH_CallbackID, gInventoryCallbacks.registerCB(cb));
+ msg->addUUIDFast(_PREHASH_FolderID, gInventory.getRootFolderID());
+ msg->addUUIDFast(_PREHASH_TransactionID, LLTransactionID::tnull);
+ msg->addU32Fast(_PREHASH_NextOwnerMask, PERM_MOVE | PERM_TRANSFER);
+ msg->addS8Fast(_PREHASH_Type, LLAssetType::AT_LSL_TEXT);
+ msg->addS8Fast(_PREHASH_InvType, LLInventoryType::IT_LSL);
+ msg->addU8Fast(_PREHASH_WearableType, NO_INV_SUBTYPE);
+ msg->addStringFast(_PREHASH_Name, "New Script");
+ msg->addStringFast(_PREHASH_Description, desc);
+
+ gAgent.sendReliableMessage();
+ return;
+ }
+ }
//
// End hack
// --------------------------------------------------------------------------------------------------
diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp
index 7c0143623b..0066d662a3 100644
--- a/indra/newview/llviewerinventory.cpp
+++ b/indra/newview/llviewerinventory.cpp
@@ -1024,29 +1024,39 @@ void create_script_cb(const LLUUID& inv_item)
// This temporary workaround should be removed after a server-side fix.
// See https://github.com/secondlife/viewer/issues/3731 for more information.
//
- const std::string hello_lua_script =
- "function state_entry()\n"
- " ll.Say(0, \"Hello, Avatar!\")\n"
- "end\n"
- "\n"
- "function touch_start(total_number)\n"
- " ll.Say(0, \"Touched.\")\n"
- "end\n"
- "\n"
- "-- Simulate the state_entry event\n"
- "state_entry()\n";
-
- std::string url = gAgent.getRegion()->getCapability("UpdateScriptAgent");
- if (!url.empty())
+ LLViewerRegion* region = gAgent.getRegion();
+ if (region && region->simulatorFeaturesReceived())
{
- LLResourceUploadInfo::ptr_t uploadInfo(std::make_shared<LLScriptAssetUpload>(
- item->getUUID(),
- "luau",
- hello_lua_script,
- nullptr,
- nullptr));
+ LLSD simulatorFeatures;
+ region->getSimulatorFeatures(simulatorFeatures);
+ if (simulatorFeatures["LuaScriptsEnabled"].asBoolean())
+ {
+
+ const std::string hello_lua_script =
+ "function state_entry()\n"
+ " ll.Say(0, \"Hello, Avatar!\")\n"
+ "end\n"
+ "\n"
+ "function touch_start(total_number)\n"
+ " ll.Say(0, \"Touched.\")\n"
+ "end\n"
+ "\n"
+ "-- Simulate the state_entry event\n"
+ "state_entry()\n";
- LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo);
+ std::string url = gAgent.getRegion()->getCapability("UpdateScriptAgent");
+ if (!url.empty())
+ {
+ LLResourceUploadInfo::ptr_t uploadInfo(std::make_shared<LLScriptAssetUpload>(
+ item->getUUID(),
+ "luau",
+ hello_lua_script,
+ nullptr,
+ nullptr));
+
+ LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo);
+ }
+ }
}
//
// End hack