summaryrefslogtreecommitdiff
path: root/indra/newview/scripts/lua/require
diff options
context:
space:
mode:
authorMaxim Nikolenko <maximnproductengine@lindenlab.com>2024-10-17 00:38:52 +0300
committerGitHub <noreply@github.com>2024-10-17 00:38:52 +0300
commit38c684b825d1280600787ecd628cadb53ef1498f (patch)
treebd69624da08bca36222d14967cfd751784183b71 /indra/newview/scripts/lua/require
parent43beabd0c7ef22e9c814124916c2f193624834e7 (diff)
parent3ed29a74f734a2b790814970df71a83c6cb47303 (diff)
Merge pull request #2805 from secondlife/maxim/lua-nearby-avatars
Lua api to get info about nearby avatars and objects
Diffstat (limited to 'indra/newview/scripts/lua/require')
-rw-r--r--indra/newview/scripts/lua/require/LLAgent.lua45
-rw-r--r--indra/newview/scripts/lua/require/UI.lua6
2 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 4a1132fe7e..6068a916ed 100644
--- a/indra/newview/scripts/lua/require/LLAgent.lua
+++ b/indra/newview/scripts/lua/require/LLAgent.lua
@@ -1,8 +1,26 @@
local leap = require 'leap'
local mapargs = require 'mapargs'
+local result_view = require 'result_view'
+
+local function result(keys)
+ local result_table = {
+ result=result_view(keys.result),
+ -- call result_table:close() to release result sets before garbage
+ -- collection or script completion
+ close = function(self)
+ result_view.close(keys.result[1])
+ end
+ }
+ -- When the result_table is destroyed, close its result_views.
+ return LL.setdtor('LLAgent result', result_table, result_table.close)
+end
local LLAgent = {}
+function LLAgent.getID()
+ return leap.request('LLAgent', {op = 'getID'}).id
+end
+
function LLAgent.getRegionPosition()
return leap.request('LLAgent', {op = 'getPosition'}).region
end
@@ -95,6 +113,33 @@ function LLAgent.requestStand()
leap.send('LLAgent', {op = 'requestStand'})
end
+-- Get the nearby avatars in a range of provided "dist",
+-- if "dist" is not specified, "RenderFarClip" setting is used
+-- reply will contain "result" table with following fields:
+-- "id", "global_pos", "region_pos", "name", "region_id"
+function LLAgent.getNearbyAvatarsList(...)
+ local args = mapargs('dist', ...)
+ args.op = 'getNearbyAvatarsList'
+ return result(leap.request('LLAgent', args))
+end
+
+-- reply will contain "result" table with following fields:
+-- "id", "global_pos", "region_pos", "region_id"
+function LLAgent.getNearbyObjectsList(...)
+ local args = mapargs('dist', ...)
+ args.op = 'getNearbyObjectsList'
+ return result(leap.request('LLAgent', args))
+end
+
+-- Get screen position of your own avatar or any other (if "avatar_id" is specified)
+-- reply contains "x", "y" coordinates and "onscreen" flag to indicate if it's actually in within the current window
+-- avatar render position is used as the point
+function LLAgent.getAgentScreenPos(...)
+ local args = mapargs('avatar_id', ...)
+ args.op = 'getAgentScreenPos'
+ return leap.request('LLAgent', args)
+end
+
-- ***************************************************************************
-- Autopilot
-- ***************************************************************************
diff --git a/indra/newview/scripts/lua/require/UI.lua b/indra/newview/scripts/lua/require/UI.lua
index cf2695917e..34f3fb75eb 100644
--- a/indra/newview/scripts/lua/require/UI.lua
+++ b/indra/newview/scripts/lua/require/UI.lua
@@ -222,8 +222,10 @@ function UI.hideFloater(floater_name)
leap.send("LLFloaterReg", {op = "hideInstance", name = floater_name})
end
-function UI.toggleFloater(floater_name)
- leap.send("LLFloaterReg", {op = "toggleInstance", name = floater_name})
+function UI.toggleFloater(...)
+ local args = mapargs('name,key', ...)
+ args.op = 'toggleInstance'
+ leap.send("LLFloaterReg", args)
end
function UI.isFloaterVisible(floater_name)