summaryrefslogtreecommitdiff
path: root/indra/newview/llviewerinventory.cpp
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2025-03-17 13:22:27 +0200
committerAndrey Lihatskiy <alihatskiy@productengine.com>2025-03-17 13:22:27 +0200
commita0e8b5ffc7cea8ce73a4e6a594eef9e87714972d (patch)
treed43b5727eba3779768f07bf1eacb5af9e6aca8bc /indra/newview/llviewerinventory.cpp
parentda0a819d64514cad17cf306c3ebe2ac79db8283a (diff)
#3731 Temporary viewer-side workaround to create SLua scripts by default
Diffstat (limited to 'indra/newview/llviewerinventory.cpp')
-rw-r--r--indra/newview/llviewerinventory.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp
index e2022cae37..7c0143623b 100644
--- a/indra/newview/llviewerinventory.cpp
+++ b/indra/newview/llviewerinventory.cpp
@@ -71,6 +71,7 @@
#include "llclipboard.h"
#include "llhttpretrypolicy.h"
#include "llsettingsvo.h"
+#include "llviewerassetupload.h"
// do-nothing ops for use in callbacks.
void no_op_inventory_func(const LLUUID&) {}
@@ -1014,6 +1015,43 @@ void create_script_cb(const LLUUID& inv_item)
LLViewerInventoryItem* item = gInventory.getItem(inv_item);
if (item)
{
+ // ------------------------------------------------------------------------------------
+ // Begin hack
+ //
+ // The current state of the server doesn't allow specifying a default script template,
+ // so we have to update its code immediately after creation instead.
+ //
+ // 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())
+ {
+ LLResourceUploadInfo::ptr_t uploadInfo(std::make_shared<LLScriptAssetUpload>(
+ item->getUUID(),
+ "luau",
+ hello_lua_script,
+ nullptr,
+ nullptr));
+
+ LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo);
+ }
+ //
+ // End hack
+ // ------------------------------------------------------------------------------------
+
set_default_permissions(item, "Scripts");
// item was just created, update even if permissions did not changed