summaryrefslogtreecommitdiff
path: root/indra/newview/scripts/lua
diff options
context:
space:
mode:
authorMaxim Nikolenko <maximnproductengine@lindenlab.com>2024-08-13 15:48:26 +0300
committerGitHub <noreply@github.com>2024-08-13 15:48:26 +0300
commit083212979d3fc0a2dd24fe795950e1d1a2251c73 (patch)
treeb9a9f7057fa1d1438db2b88761fcfd6a248516a5 /indra/newview/scripts/lua
parentff601107f093e33f70e08a9453ed329e064ce45c (diff)
parent9f2e322c7eea6830d372943d74f986d299cd314a (diff)
Merge pull request #2240 from secondlife/lua-groupchat
Lua api for sending group messages
Diffstat (limited to 'indra/newview/scripts/lua')
-rw-r--r--indra/newview/scripts/lua/require/LLAgent.lua11
-rw-r--r--indra/newview/scripts/lua/require/LLChat.lua25
-rw-r--r--indra/newview/scripts/lua/test_group_chat.lua15
3 files changed, 49 insertions, 2 deletions
diff --git a/indra/newview/scripts/lua/require/LLAgent.lua b/indra/newview/scripts/lua/require/LLAgent.lua
index bc9a6b23a0..5ee092f2f6 100644
--- a/indra/newview/scripts/lua/require/LLAgent.lua
+++ b/indra/newview/scripts/lua/require/LLAgent.lua
@@ -11,6 +11,17 @@ function LLAgent.getGlobalPosition()
return leap.request('LLAgent', {op = 'getPosition'}).global
end
+-- Return array information about the agent's groups
+-- id: group id\n"
+-- name: group name\n"
+-- insignia: group insignia texture id
+-- notices: bool indicating if this user accepts notices from this group
+-- display: bool indicating if this group is listed in the user's profile
+-- contrib: user's land contribution to this group
+function LLAgent.getGroups()
+ return leap.request('LLAgent', {op = 'getGroups'}).groups
+end
+
-- Use LL.leaphelp('LLAgent') and see 'setCameraParams' to get more info about params
-- -- TYPE -- DEFAULT -- RANGE
-- LLAgent.setCamera{ [, camera_pos] -- vector3
diff --git a/indra/newview/scripts/lua/require/LLChat.lua b/indra/newview/scripts/lua/require/LLChat.lua
index 78dca765e8..bc0fc86d22 100644
--- a/indra/newview/scripts/lua/require/LLChat.lua
+++ b/indra/newview/scripts/lua/require/LLChat.lua
@@ -2,8 +2,13 @@ local leap = require 'leap'
local LLChat = {}
-function LLChat.sendNearby(msg)
- leap.send('LLChatBar', {op='sendChat', message=msg})
+-- ***************************************************************************
+-- Nearby chat
+-- ***************************************************************************
+
+-- 0 is public nearby channel, other channels are used to communicate with LSL scripts
+function LLChat.sendNearby(msg, channel)
+ leap.send('LLChatBar', {op='sendChat', message=msg, channel=channel})
end
function LLChat.sendWhisper(msg)
@@ -14,4 +19,20 @@ function LLChat.sendShout(msg)
leap.send('LLChatBar', {op='sendChat', type='shout', message=msg})
end
+-- ***************************************************************************
+-- Group chat
+-- ***************************************************************************
+
+function LLChat.startGroupChat(group_id)
+ return leap.request('GroupChat', {op='startGroupChat', group_id=group_id})
+end
+
+function LLChat.leaveGroupChat(group_id)
+ leap.send('GroupChat', {op='leaveGroupChat', group_id=group_id})
+end
+
+function LLChat.sendGroupIM(msg, group_id)
+ leap.send('GroupChat', {op='sendGroupIM', message=msg, group_id=group_id})
+end
+
return LLChat
diff --git a/indra/newview/scripts/lua/test_group_chat.lua b/indra/newview/scripts/lua/test_group_chat.lua
new file mode 100644
index 0000000000..eaff07ed14
--- /dev/null
+++ b/indra/newview/scripts/lua/test_group_chat.lua
@@ -0,0 +1,15 @@
+LLChat = require 'LLChat'
+LLAgent = require 'LLAgent'
+popup = require 'popup'
+
+local OK = 'OK_okcancelbuttons'
+local GROUPS = LLAgent.getGroups()
+
+-- Choose one of the groups randomly and send group message
+math.randomseed(os.time())
+group_info = GROUPS[math.random(#GROUPS)]
+LLChat.startGroupChat(group_info.id)
+response = popup:alertYesCancel('Started group chat with ' .. group_info.name .. ' group. Send greetings?')
+if next(response) == OK then
+ LLChat.sendGroupIM('Greetings', group_info.id)
+end