summaryrefslogtreecommitdiff
path: root/indra/newview/scripts/lua
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-05-24 11:12:11 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-05-24 11:12:11 -0400
commit9d9ecb2462e559057a2fc226bd6e7c90f5eb6c61 (patch)
tree2e31025a7b9299e473e80599d96ab5ec1c5f6739 /indra/newview/scripts/lua
parente2f179b9edebca1557ce3f774781bb9b9350b781 (diff)
parent30da8853c88e755ac5c0836f3952d16d501d3502 (diff)
Merge branch 'release/luau-scripting' into lua-timers
Diffstat (limited to 'indra/newview/scripts/lua')
-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..3abaf28e42
--- /dev/null
+++ b/indra/newview/scripts/lua/test_LLChat.lua
@@ -0,0 +1,18 @@
+LLChat = require 'LLChat'
+
+function generateRandomWord(length)
+ local alphabet = "abcdefghijklmnopqrstuvwxyz"
+ local wordTable = {}
+ for i = 1, length do
+ local randomIndex = math.random(1, #alphabet)
+ table.insert(wordTable, alphabet:sub(randomIndex, randomIndex))
+ end
+ return table.concat(wordTable)
+end
+
+local msg = {'AI says:'}
+math.randomseed(os.time())
+for i = 1, math.random(1, 10) do
+ table.insert(msg, generateRandomWord(math.random(1, 8)))
+end
+LLChat.sendNearby(table.concat(msg, ' '))