From ccc7fffb22b347149bf807b9d92677e5616c5017 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Tue, 8 Oct 2024 15:40:12 +0300 Subject: Lua api to get avatar screen position --- indra/newview/scripts/lua/require/LLAgent.lua | 9 +++++++++ indra/newview/scripts/lua/test_screen_position.lua | 8 ++++++++ 2 files changed, 17 insertions(+) create mode 100644 indra/newview/scripts/lua/test_screen_position.lua (limited to 'indra/newview/scripts') diff --git a/indra/newview/scripts/lua/require/LLAgent.lua b/indra/newview/scripts/lua/require/LLAgent.lua index 70f3cdfffb..b2be69dcdf 100644 --- a/indra/newview/scripts/lua/require/LLAgent.lua +++ b/indra/newview/scripts/lua/require/LLAgent.lua @@ -131,6 +131,15 @@ function LLAgent.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/test_screen_position.lua b/indra/newview/scripts/lua/test_screen_position.lua new file mode 100644 index 0000000000..94d57339b1 --- /dev/null +++ b/indra/newview/scripts/lua/test_screen_position.lua @@ -0,0 +1,8 @@ +LLAgent = require 'LLAgent' + +local screen_pos = LLAgent.getAgentScreenPos() +if screen_pos.onscreen then + print("Avatar screen coordinates X: " .. screen_pos.x .. " Y: " .. screen_pos.y) +else + print("Avatar is not on the screen") +end -- cgit v1.2.3