From fe5d7d41335ca22c8078ddaeb9fe40e6b0d57b6d Mon Sep 17 00:00:00 2001 From: Andrey Lihatskiy Date: Mon, 17 Mar 2025 18:56:07 +0200 Subject: #3731 Follow-up: Use SLua defaults only on SLua-enabled regions (#3753) --- indra/newview/llviewerinventory.cpp | 54 ++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 22 deletions(-) (limited to 'indra/newview/llviewerinventory.cpp') 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( - item->getUUID(), - "luau", - hello_lua_script, - nullptr, - nullptr)); - - LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo); + 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"; + + std::string url = gAgent.getRegion()->getCapability("UpdateScriptAgent"); + if (!url.empty()) + { + LLResourceUploadInfo::ptr_t uploadInfo(std::make_shared( + item->getUUID(), + "luau", + hello_lua_script, + nullptr, + nullptr)); + + LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo); + } + } } // // End hack -- cgit v1.3