summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2025-11-25 04:53:48 +0200
committerAndrey Lihatskiy <alihatskiy@productengine.com>2025-11-25 04:53:48 +0200
commit44143786ad54d7ebfee6442a92f1c49ff570e94a (patch)
tree84b608c835ae276dbd037e2fe1376ffb5631b742
parent8fb3e99ce01316bcd2e54e3770773a4fdc6f46ec (diff)
parent2c3ce8fb8ce3967d957e13d48627b45dd32f0e00 (diff)
Merge branch 'project/lua_editor' into marchcat/slua-linux
-rw-r--r--indra/llcorehttp/llwebsocketmgr.cpp26
-rw-r--r--indra/newview/app_settings/types_lua_default.xml88
-rw-r--r--indra/newview/llpanelcontents.cpp27
-rw-r--r--indra/newview/llviewerinventory.cpp28
4 files changed, 136 insertions, 33 deletions
diff --git a/indra/llcorehttp/llwebsocketmgr.cpp b/indra/llcorehttp/llwebsocketmgr.cpp
index addd108b71..ea87d1e07e 100644
--- a/indra/llcorehttp/llwebsocketmgr.cpp
+++ b/indra/llcorehttp/llwebsocketmgr.cpp
@@ -208,15 +208,29 @@ struct Server_impl
void init()
{
mServer.init_asio();
- if (mLocalOnly)
+ try {
+ if (mLocalOnly)
+ {
+ std::stringstream port_str;
+ port_str << mPort;
+ mServer.listen("127.0.0.1", port_str.str());
+ }
+ else
+ {
+ mServer.listen(mPort);
+ }
+ }
+ catch (const websocketpp::exception& e)
{
- std::stringstream port_str;
- port_str << mPort;
- mServer.listen("127.0.0.1", port_str.str());
+ LL_WARNS("WebSocket") << "WebSocket server listen exception: " << e.what() << LL_ENDL;
}
- else
+ catch (const std::exception& e)
+ {
+ LL_WARNS("WebSocket") << "WebSocket server listen std::exception: " << e.what() << LL_ENDL;
+ }
+ catch (...)
{
- mServer.listen(mPort);
+ LL_WARNS("WebSocket") << "WebSocket server listen unknown exception" << LL_ENDL;
}
}
diff --git a/indra/newview/app_settings/types_lua_default.xml b/indra/newview/app_settings/types_lua_default.xml
index 370d8a7823..6b90804ab3 100644
--- a/indra/newview/app_settings/types_lua_default.xml
+++ b/indra/newview/app_settings/types_lua_default.xml
@@ -252,6 +252,59 @@
</map>
<map>
<key>name</key>
+ <string>once</string>
+ <key>parameters</key>
+ <array>
+ <map>
+ <key>name</key>
+ <string>self</string>
+ </map>
+ <map>
+ <key>name</key>
+ <string>eventName</string>
+ <key>type</key>
+ <string>DetectedEventName</string>
+ </map>
+ <map>
+ <key>name</key>
+ <string>handler</string>
+ <key>type</key>
+ <string>DetectedEventHandler</string>
+ </map>
+ </array>
+ <key>returnType</key>
+ <string>EventHandler</string>
+ <key>overloads</key>
+ <array>
+ <map>
+ <key>name</key>
+ <string>once</string>
+ <key>parameters</key>
+ <array>
+ <map>
+ <key>name</key>
+ <string>self</string>
+ </map>
+ <map>
+ <key>name</key>
+ <string>eventName</string>
+ <key>type</key>
+ <string>NonDetectedEventName</string>
+ </map>
+ <map>
+ <key>name</key>
+ <string>handler</string>
+ <key>type</key>
+ <string>EventHandler</string>
+ </map>
+ </array>
+ <key>returnType</key>
+ <string>EventHandler</string>
+ </map>
+ </array>
+ </map>
+ <map>
+ <key>name</key>
<string>off</string>
<key>parameters</key>
<array>
@@ -261,6 +314,12 @@
</map>
<map>
<key>name</key>
+ <string>eventName</string>
+ <key>type</key>
+ <string>EventName</string>
+ </map>
+ <map>
+ <key>name</key>
<string>handler</string>
<key>type</key>
<string>EventHandler</string>
@@ -911,6 +970,35 @@
</map>
<map>
<key>name</key>
+ <string>vector</string>
+ <key>parameters</key>
+ <array>
+ <map>
+ <key>name</key>
+ <string>x</string>
+ <key>type</key>
+ <string>number</string>
+ </map>
+ <map>
+ <key>name</key>
+ <string>y</string>
+ <key>type</key>
+ <string>number</string>
+ </map>
+ <map>
+ <key>name</key>
+ <string>z</string>
+ <key>type</key>
+ <string>number</string>
+ </map>
+ </array>
+ <key>returnType</key>
+ <string>vector</string>
+ <key>comment</key>
+ <string>Creates a vector from x,y,z</string>
+ </map>
+ <map>
+ <key>name</key>
<string>quaternion</string>
<key>parameters</key>
<array>
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));