From 0f00dc2f658869cc73a18b03b024a6cc88964e0b Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Wed, 22 May 2024 20:29:55 +0300 Subject: Add support for sending messages to Nearby chat from Lua script --- indra/newview/scripts/lua/LLChat.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 indra/newview/scripts/lua/LLChat.lua (limited to 'indra/newview/scripts/lua') 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 -- cgit v1.2.3 From 85664b011e37c6c9926924f6fb72ceeb10d07833 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Wed, 22 May 2024 21:03:45 +0300 Subject: add throttle for sending messages; add simple demo script --- indra/newview/scripts/lua/test_LLChat.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 indra/newview/scripts/lua/test_LLChat.lua (limited to 'indra/newview/scripts/lua') 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) -- cgit v1.2.3 From e4b7d2f463d19cab28985414365fd8415e3dc700 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Fri, 24 May 2024 15:24:50 +0300 Subject: Mark script messages in compact mode too; code clean up --- indra/newview/scripts/lua/test_LLChat.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/scripts/lua') diff --git a/indra/newview/scripts/lua/test_LLChat.lua b/indra/newview/scripts/lua/test_LLChat.lua index 95bd218baa..883b82fafb 100644 --- a/indra/newview/scripts/lua/test_LLChat.lua +++ b/indra/newview/scripts/lua/test_LLChat.lua @@ -2,15 +2,15 @@ LLChat = require 'LLChat' function generateRandomWord(length) local alphabet = "abcdefghijklmnopqrstuvwxyz" - local word = "" + local wordTable = {} for i = 1, length do local randomIndex = math.random(1, #alphabet) - word = word .. alphabet:sub(randomIndex, randomIndex) + table.insert(wordTable, alphabet:sub(randomIndex, randomIndex)) end - return word + return table.concat(wordTable) end -local msg = "" +local msg = "AI says:" math.randomseed(os.time()) for i = 1, math.random(1, 10) do msg = msg .. " ".. generateRandomWord(math.random(1, 8)) -- cgit v1.2.3 From b0ef843fe0702482e843379b4975b2dda4d58935 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 24 May 2024 09:22:40 -0400 Subject: Nat's ideas from PR #1547 --- indra/newview/scripts/lua/test_LLChat.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/newview/scripts/lua') diff --git a/indra/newview/scripts/lua/test_LLChat.lua b/indra/newview/scripts/lua/test_LLChat.lua index 95bd218baa..3c5cbeeeb2 100644 --- a/indra/newview/scripts/lua/test_LLChat.lua +++ b/indra/newview/scripts/lua/test_LLChat.lua @@ -2,17 +2,17 @@ LLChat = require 'LLChat' function generateRandomWord(length) local alphabet = "abcdefghijklmnopqrstuvwxyz" - local word = "" + local word = {} for i = 1, length do local randomIndex = math.random(1, #alphabet) - word = word .. alphabet:sub(randomIndex, randomIndex) + table.insert(word, alphabet:sub(randomIndex, randomIndex)) end - return word + return table.concat(word) end -local msg = "" +local msg = {'AI says:'} math.randomseed(os.time()) for i = 1, math.random(1, 10) do - msg = msg .. " ".. generateRandomWord(math.random(1, 8)) + table.insert(msg, generateRandomWord(math.random(1, 8))) end -LLChat.sendNearby(msg) +LLChat.sendNearby(table.concat(msg, ' ')) -- cgit v1.2.3