summaryrefslogtreecommitdiff
path: root/indra/newview/scripts
diff options
context:
space:
mode:
authorMaxim Nikolenko <maximnproductengine@lindenlab.com>2024-05-23 22:06:12 +0300
committerGitHub <noreply@github.com>2024-05-23 22:06:12 +0300
commit591a80765c4438f72795230824d2e549bafc592d (patch)
treed913b4083236bf6e4aa55861b52cb57341f0458c /indra/newview/scripts
parent58cf9c5c23c10752b26dcac384b51c85f9407ca6 (diff)
parentc38e71411080af9e03646bbe34f766201d942afd (diff)
Merge pull request #1547 from secondlife/lua-nearby-chat
Add support for sending messages to Nearby chat from Lua script
Diffstat (limited to 'indra/newview/scripts')
-rw-r--r--indra/newview/scripts/lua/LLChat.lua17
-rw-r--r--indra/newview/scripts/lua/test_LLChat.lua18
2 files changed, 35 insertions, 0 deletions
diff --git a/indra/newview/scripts/lua/LLChat.lua b/indra/newview/scripts/lua/LLChat.lua
new file mode 100644
index 0000000000..7db538e837
--- /dev/null
+++ b/indra/newview/scripts/lua/LLChat.lua
@@ -0,0 +1,17 @@
+leap = require 'leap'
+
+local LLChat = {}
+
+function LLChat.sendNearby(msg)
+ leap.send('LLChatBar', {op='sendChat', message=msg})
+end
+
+function LLChat.sendWhisper(msg)
+ leap.send('LLChatBar', {op='sendChat', type='whisper', message=msg})
+end
+
+function LLChat.sendShout(msg)
+ leap.send('LLChatBar', {op='sendChat', type='shout', message=msg})
+end
+
+return LLChat
diff --git a/indra/newview/scripts/lua/test_LLChat.lua b/indra/newview/scripts/lua/test_LLChat.lua
new file mode 100644
index 0000000000..95bd218baa
--- /dev/null
+++ b/indra/newview/scripts/lua/test_LLChat.lua
@@ -0,0 +1,18 @@
+LLChat = require 'LLChat'
+
+function generateRandomWord(length)
+ local alphabet = "abcdefghijklmnopqrstuvwxyz"
+ local word = ""
+ for i = 1, length do
+ local randomIndex = math.random(1, #alphabet)
+ word = word .. alphabet:sub(randomIndex, randomIndex)
+ end
+ return word
+end
+
+local msg = ""
+math.randomseed(os.time())
+for i = 1, math.random(1, 10) do
+ msg = msg .. " ".. generateRandomWord(math.random(1, 8))
+end
+LLChat.sendNearby(msg)