diff options
| author | Harold Cindy <120691094+HaroldCindy@users.noreply.github.com> | 2025-11-20 19:33:12 -0800 |
|---|---|---|
| committer | Harold Cindy <120691094+HaroldCindy@users.noreply.github.com> | 2025-11-20 20:54:29 -0800 |
| commit | e153d784607b2944ff5a444e8674fe5953597a15 (patch) | |
| tree | e5768ef9ebc795cd88d7cb436a5708cad8d6dab3 /indra | |
| parent | 4e54ea87bb9e4fc1bf2c1a92327047b9ce2e3a54 (diff) | |
Change the default script for SLua
Diffstat (limited to 'indra')
| -rw-r--r-- | indra/newview/llpanelcontents.cpp | 27 | ||||
| -rw-r--r-- | indra/newview/llviewerinventory.cpp | 28 |
2 files changed, 28 insertions, 27 deletions
diff --git a/indra/newview/llpanelcontents.cpp b/indra/newview/llpanelcontents.cpp index 07c7b586fc..bc99899c27 100644 --- a/indra/newview/llpanelcontents.cpp +++ b/indra/newview/llpanelcontents.cpp @@ -221,6 +221,19 @@ void LLPanelContents::clearContents() // Static functions // +// See below comment in `onClickNewScript()` about this hack :( +static const std::string DEFAULT_SLUA_SCRIPT = R"( +function LLEvents.touch_start(detected) + ll.Say(0, "Touched.") +end + +local function main() + print("Hello, Avatar!") +end + +main() +)"; + // static void LLPanelContents::onClickNewScript(void *userdata) { @@ -274,18 +287,6 @@ void LLPanelContents::onClickNewScript(void *userdata) 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"; - auto scriptUploadFinished = [object, item](LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD response) { LLPointer<LLViewerInventoryItem> new_script = new LLViewerInventoryItem(item); @@ -312,7 +313,7 @@ void LLPanelContents::onClickNewScript(void *userdata) LLResourceUploadInfo::ptr_t uploadInfo(std::make_shared<LLScriptAssetUpload>( item->getUUID(), "luau", - hello_lua_script, + DEFAULT_SLUA_SCRIPT, scriptUploadFinished, nullptr)); diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 0954e4adcd..0e63c69916 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -1016,6 +1016,19 @@ void set_default_permissions(LLViewerInventoryItem* item, std::string perm_type) } } +// See below comment in `create_script_cb()` about this hack :( +static const std::string DEFAULT_SLUA_SCRIPT = R"( +function LLEvents.touch_start(detected) + ll.Say(0, "Touched.") +end + +local function main() + print("Hello, Avatar!") +end + +main() +)"; + void create_script_cb(const LLUUID& inv_item) { if (!inv_item.isNull()) @@ -1039,26 +1052,13 @@ void create_script_cb(const LLUUID& inv_item) 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<LLScriptAssetUpload>( item->getUUID(), "luau", - hello_lua_script, + DEFAULT_SLUA_SCRIPT, nullptr, nullptr)); |
