From b6cbad1cf6c6ae6293825da776ce2191175d4632 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Mon, 16 Sep 2024 20:29:53 +0300 Subject: Lua api for autopilot functions --- indra/newview/llagentlistener.cpp | 56 ++++++++++++++++++--------- indra/newview/scripts/lua/require/LLAgent.lua | 49 +++++++++++++++++++++++ 2 files changed, 86 insertions(+), 19 deletions(-) diff --git a/indra/newview/llagentlistener.cpp b/indra/newview/llagentlistener.cpp index d9002bf073..120e52402d 100644 --- a/indra/newview/llagentlistener.cpp +++ b/indra/newview/llagentlistener.cpp @@ -87,14 +87,15 @@ LLAgentListener::LLAgentListener(LLAgent &agent) add("startAutoPilot", "Start the autopilot system using the following parameters:\n" "[\"target_global\"]: array of target global {x, y, z} position\n" - "[\"stop_distance\"]: target maxiumum distance from target [default: autopilot guess]\n" + "[\"stop_distance\"]: target maximum distance from target [default: autopilot guess]\n" "[\"target_rotation\"]: array of [x, y, z, w] quaternion values [default: no target]\n" "[\"rotation_threshold\"]: target maximum angle from target facing rotation [default: 0.03 radians]\n" "[\"behavior_name\"]: name of the autopilot behavior [default: \"\"]" "[\"allow_flying\"]: allow flying during autopilot [default: True]", //"[\"callback_pump\"]: pump to send success/failure and callback data to [default: none]\n" //"[\"callback_data\"]: data to send back during a callback [default: none]", - &LLAgentListener::startAutoPilot); + &LLAgentListener::startAutoPilot, + llsd::map("target_global", LLSD())); add("getAutoPilot", "Send information about current state of the autopilot system to [\"reply\"]:\n" "[\"enabled\"]: boolean indicating whether or not autopilot is enabled\n" @@ -107,13 +108,14 @@ LLAgentListener::LLAgentListener(LLAgent &agent) "[\"rotation_threshold\"]: target maximum angle from target facing rotation\n" "[\"behavior_name\"]: name of the autopilot behavior", &LLAgentListener::getAutoPilot, - LLSDMap("reply", LLSD())); + llsd::map("reply", LLSD())); add("startFollowPilot", "[\"leader_id\"]: uuid of target to follow using the autopilot system (optional with avatar_name)\n" "[\"avatar_name\"]: avatar name to follow using the autopilot system (optional with leader_id)\n" "[\"allow_flying\"]: allow flying during autopilot [default: True]\n" - "[\"stop_distance\"]: target maxiumum distance from target [default: autopilot guess]", - &LLAgentListener::startFollowPilot); + "[\"stop_distance\"]: target maximum distance from target [default: autopilot guess]", + &LLAgentListener::startFollowPilot, + llsd::map("reply", LLSD())); add("setAutoPilotTarget", "Update target for currently running autopilot:\n" "[\"target_global\"]: array of target global {x, y, z} position", @@ -205,7 +207,7 @@ void LLAgentListener::requestSit(LLSD const & event_data) const //mAgent.getAvatarObject()->sitOnObject(); // shamelessly ripped from llviewermenu.cpp:handle_sit_or_stand() // *TODO - find a permanent place to share this code properly. - + Response response(LLSD(), event_data); LLViewerObject *object = NULL; if (event_data.has("obj_uuid")) { @@ -216,6 +218,12 @@ void LLAgentListener::requestSit(LLSD const & event_data) const LLVector3 target_position = ll_vector3_from_sd(event_data["position"]); object = findObjectClosestTo(target_position); } + else + { + //just sit on the ground + mAgent.setControlFlags(AGENT_CONTROL_SIT_ON_GROUND); + return; + } if (object && object->getPCode() == LL_PCODE_VOLUME) { @@ -231,8 +239,7 @@ void LLAgentListener::requestSit(LLSD const & event_data) const } else { - LL_WARNS() << "LLAgent requestSit could not find the sit target: " - << event_data << LL_ENDL; + response.error("requestSit could not find the sit target"); } } @@ -354,11 +361,10 @@ void LLAgentListener::getPosition(const LLSD& event_data) const void LLAgentListener::startAutoPilot(LLSD const & event_data) { - LLQuaternion target_rotation_value; LLQuaternion* target_rotation = NULL; if (event_data.has("target_rotation")) { - target_rotation_value = ll_quaternion_from_sd(event_data["target_rotation"]); + LLQuaternion target_rotation_value = ll_quaternion_from_sd(event_data["target_rotation"]); target_rotation = &target_rotation_value; } // *TODO: Use callback_pump and callback_data @@ -381,11 +387,17 @@ void LLAgentListener::startAutoPilot(LLSD const & event_data) stop_distance = (F32)event_data["stop_distance"].asReal(); } + std::string behavior_name = LLCoros::getName(); + if (event_data.has("behavior_name")) + { + behavior_name = event_data["behavior_name"].asString(); + } + // Clear follow target, this is doing a path mFollowTarget.setNull(); mAgent.startAutoPilotGlobal(ll_vector3d_from_sd(event_data["target_global"]), - event_data["behavior_name"], + behavior_name, target_rotation, NULL, NULL, stop_distance, @@ -395,7 +407,7 @@ void LLAgentListener::startAutoPilot(LLSD const & event_data) void LLAgentListener::getAutoPilot(const LLSD& event_data) const { - LLSD reply = LLSD::emptyMap(); + Response reply(LLSD(), event_data); LLSD::Boolean enabled = mAgent.getAutoPilot(); reply["enabled"] = enabled; @@ -424,12 +436,11 @@ void LLAgentListener::getAutoPilot(const LLSD& event_data) const reply["rotation_threshold"] = mAgent.getAutoPilotRotationThreshold(); reply["behavior_name"] = mAgent.getAutoPilotBehaviorName(); reply["fly"] = (LLSD::Boolean) mAgent.getFlying(); - - sendReply(reply, event_data); } void LLAgentListener::startFollowPilot(LLSD const & event_data) { + Response response(LLSD(), event_data); LLUUID target_id; bool allow_flying = true; @@ -463,6 +474,10 @@ void LLAgentListener::startFollowPilot(LLSD const & event_data) } } } + else + { + return response.error("'leader_id' or 'avatar_name' should be specified"); + } F32 stop_distance = 0.f; if (event_data.has("stop_distance")) @@ -470,13 +485,16 @@ void LLAgentListener::startFollowPilot(LLSD const & event_data) stop_distance = (F32)event_data["stop_distance"].asReal(); } - if (target_id.notNull()) + if (!gObjectList.findObject(target_id)) { - mAgent.setFlying(allow_flying); - mFollowTarget = target_id; // Save follow target so we can report distance later - - mAgent.startFollowPilot(target_id, allow_flying, stop_distance); + std::string target_info = event_data.has("leader_id") ? event_data["target_id"] : event_data["avatar_name"]; + return response.error(stringize("Target ", std::quoted(target_info), " was not found")); } + + mAgent.setFlying(allow_flying); + mFollowTarget = target_id; // Save follow target so we can report distance later + + mAgent.startFollowPilot(target_id, allow_flying, stop_distance); } void LLAgentListener::setAutoPilotTarget(LLSD const & event_data) const diff --git a/indra/newview/scripts/lua/require/LLAgent.lua b/indra/newview/scripts/lua/require/LLAgent.lua index 5cee998fcd..7b12493acc 100644 --- a/indra/newview/scripts/lua/require/LLAgent.lua +++ b/indra/newview/scripts/lua/require/LLAgent.lua @@ -80,4 +80,53 @@ function LLAgent.teleport(...) return leap.request('LLTeleportHandler', args).message end +function LLAgent.requestSit(...) + local args = mapargs('obj_uuid,position', ...) + args.op = 'requestSit' + return leap.request('LLAgent', args) +end + +function LLAgent.requestStand() + leap.send('LLAgent', {op = 'requestStand'}) +end + +-- Start the autopilot to move to "target_global" location using specified parameters +-- LLAgent.startAutoPilot{ target_global array of target global {x, y, z} position +-- [, allow_flying] allow flying during autopilot [default: true] +-- [, stop_distance] target maximum distance from target [default: autopilot guess] +-- [, behavior_name] name of the autopilot behavior [default: (script name)] +-- [, target_rotation] array of [x, y, z, w] quaternion values [default: no target] +-- [, rotation_threshold] target maximum angle from target facing rotation [default: 0.03 radians] +function LLAgent.startAutoPilot(...) + local args = mapargs('target_global,allow_flying,stop_distance,behavior_name,target_rotation,rotation_threshold', ...) + args.op = 'startAutoPilot' + leap.send('LLAgent', args) +end + +-- Update target location for currently running autopilot +function LLAgent.setAutoPilotTarget(target_global) + leap.send('LLAgent', {op = 'setAutoPilotTarget', target_global=target_global}) +end + +-- Start the autopilot to move to the specified target location +-- either "leader_id" (uuid of target) or "avatar_name" (avatar full name) should be specified +-- "allow_flying" [default: true], "stop_distance" [default: autopilot guess] +function LLAgent.startFollowPilot(...) + local args = mapargs('leader_id,avatar_name,allow_flying,stop_distance', ...) + args.op = 'startFollowPilot' + return leap.request('LLAgent', args) +end + +-- Stop the autopilot system: "user_cancel" indicates whether or not to act as though user canceled autopilot [default: false] +function LLAgent.stopAutoPilot(...) + local args = mapargs('user_cancel', ...) + args.op = 'stopAutoPilot' + leap.send('LLAgent', args) +end + +-- Get information about current state of the autopilot +function LLAgent.getAutoPilot() + return leap.request('LLAgent', {op = 'getAutoPilot'}) +end + return LLAgent -- cgit v1.2.3 From ed7603bfe63ce5e8c1ff1101270e0406de01dc92 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Tue, 17 Sep 2024 12:37:17 +0300 Subject: Use event pump to get autopilot status, when it's terminated; add demo script --- indra/newview/llagentlistener.cpp | 29 ++++++++----- indra/newview/llagentlistener.h | 2 +- indra/newview/scripts/lua/require/LLAgent.lua | 13 +++++- indra/newview/scripts/lua/require/LLChat.lua | 1 + .../newview/scripts/lua/require/LLChatListener.lua | 48 --------------------- indra/newview/scripts/lua/require/LLListener.lua | 50 ++++++++++++++++++++++ indra/newview/scripts/lua/test_LLChatListener.lua | 6 +-- indra/newview/scripts/lua/test_autopilot.lua | 22 ++++++++++ 8 files changed, 108 insertions(+), 63 deletions(-) delete mode 100644 indra/newview/scripts/lua/require/LLChatListener.lua create mode 100644 indra/newview/scripts/lua/require/LLListener.lua create mode 100644 indra/newview/scripts/lua/test_autopilot.lua diff --git a/indra/newview/llagentlistener.cpp b/indra/newview/llagentlistener.cpp index 120e52402d..10f56c4eb3 100644 --- a/indra/newview/llagentlistener.cpp +++ b/indra/newview/llagentlistener.cpp @@ -90,10 +90,9 @@ LLAgentListener::LLAgentListener(LLAgent &agent) "[\"stop_distance\"]: target maximum distance from target [default: autopilot guess]\n" "[\"target_rotation\"]: array of [x, y, z, w] quaternion values [default: no target]\n" "[\"rotation_threshold\"]: target maximum angle from target facing rotation [default: 0.03 radians]\n" - "[\"behavior_name\"]: name of the autopilot behavior [default: \"\"]" - "[\"allow_flying\"]: allow flying during autopilot [default: True]", - //"[\"callback_pump\"]: pump to send success/failure and callback data to [default: none]\n" - //"[\"callback_data\"]: data to send back during a callback [default: none]", + "[\"behavior_name\"]: name of the autopilot behavior [default: \"\"]\n" + "[\"allow_flying\"]: allow flying during autopilot [default: True]\n" + "event with [\"success\"] flag is sent to 'LLAutopilot' event pump, when auto pilot is terminated", &LLAgentListener::startAutoPilot, llsd::map("target_global", LLSD())); add("getAutoPilot", @@ -216,7 +215,7 @@ void LLAgentListener::requestSit(LLSD const & event_data) const else if (event_data.has("position")) { LLVector3 target_position = ll_vector3_from_sd(event_data["position"]); - object = findObjectClosestTo(target_position); + object = findObjectClosestTo(target_position, true); } else { @@ -249,7 +248,7 @@ void LLAgentListener::requestStand(LLSD const & event_data) const } -LLViewerObject * LLAgentListener::findObjectClosestTo( const LLVector3 & position ) const +LLViewerObject * LLAgentListener::findObjectClosestTo(const LLVector3 & position, bool sit_target) const { LLViewerObject *object = NULL; @@ -260,8 +259,13 @@ LLViewerObject * LLAgentListener::findObjectClosestTo( const LLVector3 & positio while (cur_index < num_objects) { LLViewerObject * cur_object = gObjectList.getObject(cur_index++); - if (cur_object) - { // Calculate distance from the target position + if (cur_object && !cur_object->isAttachment()) + { + if(sit_target && (cur_object->getPCode() != LL_PCODE_VOLUME)) + { + continue; + } + // Calculate distance from the target position LLVector3 target_diff = cur_object->getPositionRegion() - position; F32 distance_to_target = target_diff.length(); if (distance_to_target < min_distance) @@ -367,7 +371,7 @@ void LLAgentListener::startAutoPilot(LLSD const & event_data) LLQuaternion target_rotation_value = ll_quaternion_from_sd(event_data["target_rotation"]); target_rotation = &target_rotation_value; } - // *TODO: Use callback_pump and callback_data + F32 rotation_threshold = 0.03f; if (event_data.has("rotation_threshold")) { @@ -396,10 +400,15 @@ void LLAgentListener::startAutoPilot(LLSD const & event_data) // Clear follow target, this is doing a path mFollowTarget.setNull(); + auto finish_cb = [](bool success, void*) + { + LLEventPumps::instance().obtain("LLAutopilot").post(llsd::map("success", success)); + }; + mAgent.startAutoPilotGlobal(ll_vector3d_from_sd(event_data["target_global"]), behavior_name, target_rotation, - NULL, NULL, + finish_cb, NULL, stop_distance, rotation_threshold, allow_flying); diff --git a/indra/newview/llagentlistener.h b/indra/newview/llagentlistener.h index 2765bb5b66..05724ff443 100644 --- a/indra/newview/llagentlistener.h +++ b/indra/newview/llagentlistener.h @@ -67,7 +67,7 @@ private: void stopAnimation(LLSD const &event_data); void getAnimationInfo(LLSD const &event_data); - LLViewerObject * findObjectClosestTo( const LLVector3 & position ) const; + LLViewerObject * findObjectClosestTo( const LLVector3 & position, bool sit_target = false ) const; private: LLAgent & mAgent; diff --git a/indra/newview/scripts/lua/require/LLAgent.lua b/indra/newview/scripts/lua/require/LLAgent.lua index 7b12493acc..4a1132fe7e 100644 --- a/indra/newview/scripts/lua/require/LLAgent.lua +++ b/indra/newview/scripts/lua/require/LLAgent.lua @@ -80,6 +80,11 @@ function LLAgent.teleport(...) return leap.request('LLTeleportHandler', args).message end +-- Call with no arguments to sit on the ground. +-- Otherwise specify "obj_uuid" to sit on, +-- or region "position" {x, y, z} where to find closest object to sit on. +-- For example: LLAgent.requestSit{position=LLAgent.getRegionPosition()} +-- Your avatar should be close enough to the object you want to sit on function LLAgent.requestSit(...) local args = mapargs('obj_uuid,position', ...) args.op = 'requestSit' @@ -90,6 +95,11 @@ function LLAgent.requestStand() leap.send('LLAgent', {op = 'requestStand'}) end +-- *************************************************************************** +-- Autopilot +-- *************************************************************************** +LLAgent.autoPilotPump = "LLAutopilot" + -- Start the autopilot to move to "target_global" location using specified parameters -- LLAgent.startAutoPilot{ target_global array of target global {x, y, z} position -- [, allow_flying] allow flying during autopilot [default: true] @@ -97,6 +107,7 @@ end -- [, behavior_name] name of the autopilot behavior [default: (script name)] -- [, target_rotation] array of [x, y, z, w] quaternion values [default: no target] -- [, rotation_threshold] target maximum angle from target facing rotation [default: 0.03 radians] +-- an event with "success" flag is sent to "LLAutopilot" event pump, when auto pilot is terminated function LLAgent.startAutoPilot(...) local args = mapargs('target_global,allow_flying,stop_distance,behavior_name,target_rotation,rotation_threshold', ...) args.op = 'startAutoPilot' @@ -109,7 +120,7 @@ function LLAgent.setAutoPilotTarget(target_global) end -- Start the autopilot to move to the specified target location --- either "leader_id" (uuid of target) or "avatar_name" (avatar full name) should be specified +-- either "leader_id" (uuid of target) or "avatar_name" (avatar full name: use just first name for 'Resident') should be specified -- "allow_flying" [default: true], "stop_distance" [default: autopilot guess] function LLAgent.startFollowPilot(...) local args = mapargs('leader_id,avatar_name,allow_flying,stop_distance', ...) diff --git a/indra/newview/scripts/lua/require/LLChat.lua b/indra/newview/scripts/lua/require/LLChat.lua index bc0fc86d22..3ac3bab746 100644 --- a/indra/newview/scripts/lua/require/LLChat.lua +++ b/indra/newview/scripts/lua/require/LLChat.lua @@ -5,6 +5,7 @@ local LLChat = {} -- *************************************************************************** -- Nearby chat -- *************************************************************************** +LLChat.nearbyChatPump = "LLNearbyChat" -- 0 is public nearby channel, other channels are used to communicate with LSL scripts function LLChat.sendNearby(msg, channel) diff --git a/indra/newview/scripts/lua/require/LLChatListener.lua b/indra/newview/scripts/lua/require/LLChatListener.lua deleted file mode 100644 index 82b28966ce..0000000000 --- a/indra/newview/scripts/lua/require/LLChatListener.lua +++ /dev/null @@ -1,48 +0,0 @@ -local fiber = require 'fiber' -local inspect = require 'inspect' -local leap = require 'leap' -local util = require 'util' - -local LLChatListener = {} -local waitfor = {} -local listener_name = {} - -function LLChatListener:new() - local obj = setmetatable({}, self) - self.__index = self - obj.name = 'Chat_listener' - - return obj -end - -util.classctor(LLChatListener) - -function LLChatListener:handleMessages(event_data) - print(inspect(event_data)) - return true -end - -function LLChatListener:start() - waitfor = leap.WaitFor(-1, self.name) - function waitfor:filter(pump, data) - if pump == "LLNearbyChat" then - return data - end - end - - fiber.launch(self.name, function() - event = waitfor:wait() - while event and self:handleMessages(event) do - event = waitfor:wait() - end - end) - - listener_name = leap.request(leap.cmdpump(), {op='listen', source='LLNearbyChat', listener="ChatListener", tweak=true}).listener -end - -function LLChatListener:stop() - leap.send(leap.cmdpump(), {op='stoplistening', source='LLNearbyChat', listener=listener_name}) - waitfor:close() -end - -return LLChatListener diff --git a/indra/newview/scripts/lua/require/LLListener.lua b/indra/newview/scripts/lua/require/LLListener.lua new file mode 100644 index 0000000000..e3bfb6b358 --- /dev/null +++ b/indra/newview/scripts/lua/require/LLListener.lua @@ -0,0 +1,50 @@ +local fiber = require 'fiber' +local inspect = require 'inspect' +local leap = require 'leap' +local util = require 'util' + +local LLListener = {} +local waitfor = {} +local listener_name = {} +local pump = {} + +function LLListener:new() + local obj = setmetatable({}, self) + self.__index = self + obj.name = 'Listener' + + return obj +end + +util.classctor(LLListener) + +function LLListener:handleMessages(event_data) + print(inspect(event_data)) + return true +end + +function LLListener:start(pump_name) + pump = pump_name + waitfor = leap.WaitFor(-1, self.name) + function waitfor:filter(pump_, data) + if pump == pump_ then + return data + end + end + + fiber.launch(self.name, function() + event = waitfor:wait() + while event and self:handleMessages(event) do + event = waitfor:wait() + end + end) + + listener_name = leap.request(leap.cmdpump(), {op='listen', source=pump, listener="LLListener", tweak=true}).listener +end + +function LLListener:stop() + leap.send(leap.cmdpump(), {op='stoplistening', source=pump, listener=listener_name}) + waitfor:close() +end + +return LLListener diff --git a/indra/newview/scripts/lua/test_LLChatListener.lua b/indra/newview/scripts/lua/test_LLChatListener.lua index 4a4d40bee5..1df2880f3d 100644 --- a/indra/newview/scripts/lua/test_LLChatListener.lua +++ b/indra/newview/scripts/lua/test_LLChatListener.lua @@ -1,4 +1,4 @@ -local LLChatListener = require 'LLChatListener' +local LLListener = require 'LLListener' local LLChat = require 'LLChat' local UI = require 'UI' @@ -22,7 +22,7 @@ function openOrEcho(message) end end -local listener = LLChatListener() +local listener = LLListener() function listener:handleMessages(event_data) if string.find(event_data.message, '[LUA]') then @@ -36,4 +36,4 @@ function listener:handleMessages(event_data) return true end -listener:start() +listener:start(LLChat.nearbyChatPump) diff --git a/indra/newview/scripts/lua/test_autopilot.lua b/indra/newview/scripts/lua/test_autopilot.lua new file mode 100644 index 0000000000..0560477d38 --- /dev/null +++ b/indra/newview/scripts/lua/test_autopilot.lua @@ -0,0 +1,22 @@ +local LLAgent = require 'LLAgent' +local LLListener = require 'LLListener' + +local pos = LLAgent.getGlobalPosition() +pos[1]+=10 -- delta x +pos[2]+=5 -- delta y +LLAgent.requestStand() +LLAgent.startAutoPilot{target_global=pos,allow_flying=false,stop_distance=1} + +local listener = LLListener() + +function listener:handleMessages(event_data) + if event_data.success then + print('Destination is reached') + LLAgent.requestSit() + else + print('Failed to reach destination') + end + return false +end + +listener:start(LLAgent.autoPilotPump) -- cgit v1.2.3 From 80066449b9cbee018dd1c874c02579b1cbd3d348 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Thu, 26 Sep 2024 17:20:47 +0300 Subject: update LLListener and related scripts --- indra/newview/llagentlistener.cpp | 8 ++++---- indra/newview/scripts/lua/require/LLListener.lua | 18 +++++++++--------- indra/newview/scripts/lua/test_LLChatListener.lua | 4 ++-- indra/newview/scripts/lua/test_autopilot.lua | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/indra/newview/llagentlistener.cpp b/indra/newview/llagentlistener.cpp index 10f56c4eb3..14e443ec4e 100644 --- a/indra/newview/llagentlistener.cpp +++ b/indra/newview/llagentlistener.cpp @@ -87,7 +87,7 @@ LLAgentListener::LLAgentListener(LLAgent &agent) add("startAutoPilot", "Start the autopilot system using the following parameters:\n" "[\"target_global\"]: array of target global {x, y, z} position\n" - "[\"stop_distance\"]: target maximum distance from target [default: autopilot guess]\n" + "[\"stop_distance\"]: maximum stop distance from target [default: autopilot guess]\n" "[\"target_rotation\"]: array of [x, y, z, w] quaternion values [default: no target]\n" "[\"rotation_threshold\"]: target maximum angle from target facing rotation [default: 0.03 radians]\n" "[\"behavior_name\"]: name of the autopilot behavior [default: \"\"]\n" @@ -100,7 +100,7 @@ LLAgentListener::LLAgentListener(LLAgent &agent) "[\"enabled\"]: boolean indicating whether or not autopilot is enabled\n" "[\"target_global\"]: array of target global {x, y, z} position\n" "[\"leader_id\"]: uuid of target autopilot is following\n" - "[\"stop_distance\"]: target maximum distance from target\n" + "[\"stop_distance\"]: maximum stop distance from target\n" "[\"target_distance\"]: last known distance from target\n" "[\"use_rotation\"]: boolean indicating if autopilot has a target facing rotation\n" "[\"target_facing\"]: array of {x, y} target direction to face\n" @@ -112,7 +112,7 @@ LLAgentListener::LLAgentListener(LLAgent &agent) "[\"leader_id\"]: uuid of target to follow using the autopilot system (optional with avatar_name)\n" "[\"avatar_name\"]: avatar name to follow using the autopilot system (optional with leader_id)\n" "[\"allow_flying\"]: allow flying during autopilot [default: True]\n" - "[\"stop_distance\"]: target maximum distance from target [default: autopilot guess]", + "[\"stop_distance\"]: maximum stop distance from target [default: autopilot guess]", &LLAgentListener::startFollowPilot, llsd::map("reply", LLSD())); add("setAutoPilotTarget", @@ -496,7 +496,7 @@ void LLAgentListener::startFollowPilot(LLSD const & event_data) if (!gObjectList.findObject(target_id)) { - std::string target_info = event_data.has("leader_id") ? event_data["target_id"] : event_data["avatar_name"]; + std::string target_info = event_data.has("leader_id") ? event_data["leader_id"] : event_data["avatar_name"]; return response.error(stringize("Target ", std::quoted(target_info), " was not found")); } diff --git a/indra/newview/scripts/lua/require/LLListener.lua b/indra/newview/scripts/lua/require/LLListener.lua index e3bfb6b358..b05f966097 100644 --- a/indra/newview/scripts/lua/require/LLListener.lua +++ b/indra/newview/scripts/lua/require/LLListener.lua @@ -6,12 +6,12 @@ local util = require 'util' local LLListener = {} local waitfor = {} local listener_name = {} -local pump = {} -function LLListener:new() +function LLListener:new(pump_name) local obj = setmetatable({}, self) self.__index = self - obj.name = 'Listener' + obj.name = 'Listener:' .. pump_name + obj._pump = pump_name return obj end @@ -23,11 +23,11 @@ function LLListener:handleMessages(event_data) return true end -function LLListener:start(pump_name) - pump = pump_name +function LLListener:start() + _pump = self._pump waitfor = leap.WaitFor(-1, self.name) - function waitfor:filter(pump_, data) - if pump == pump_ then + function waitfor:filter(pump, data) + if _pump == pump then return data end end @@ -39,11 +39,11 @@ function LLListener:start(pump_name) end end) - listener_name = leap.request(leap.cmdpump(), {op='listen', source=pump, listener="LLListener", tweak=true}).listener + listener_name = leap.request(leap.cmdpump(), {op='listen', source=_pump, listener="LLListener", tweak=true}).listener end function LLListener:stop() - leap.send(leap.cmdpump(), {op='stoplistening', source=pump, listener=listener_name}) + leap.send(leap.cmdpump(), {op='stoplistening', source=self._pump, listener=listener_name}) waitfor:close() end diff --git a/indra/newview/scripts/lua/test_LLChatListener.lua b/indra/newview/scripts/lua/test_LLChatListener.lua index 1df2880f3d..0f269b54e6 100644 --- a/indra/newview/scripts/lua/test_LLChatListener.lua +++ b/indra/newview/scripts/lua/test_LLChatListener.lua @@ -22,7 +22,7 @@ function openOrEcho(message) end end -local listener = LLListener() +local listener = LLListener(LLChat.nearbyChatPump) function listener:handleMessages(event_data) if string.find(event_data.message, '[LUA]') then @@ -36,4 +36,4 @@ function listener:handleMessages(event_data) return true end -listener:start(LLChat.nearbyChatPump) +listener:start() diff --git a/indra/newview/scripts/lua/test_autopilot.lua b/indra/newview/scripts/lua/test_autopilot.lua index 0560477d38..09c85c140a 100644 --- a/indra/newview/scripts/lua/test_autopilot.lua +++ b/indra/newview/scripts/lua/test_autopilot.lua @@ -7,7 +7,7 @@ pos[2]+=5 -- delta y LLAgent.requestStand() LLAgent.startAutoPilot{target_global=pos,allow_flying=false,stop_distance=1} -local listener = LLListener() +local listener = LLListener(LLAgent.autoPilotPump) function listener:handleMessages(event_data) if event_data.success then @@ -19,4 +19,4 @@ function listener:handleMessages(event_data) return false end -listener:start(LLAgent.autoPilotPump) +listener:start() -- cgit v1.2.3 From 34af8cc936eba7f058bf02819f736f1547c39525 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Thu, 26 Sep 2024 22:39:02 +0300 Subject: get rid of extra LL in help text --- indra/llcommon/lua_function.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/llcommon/lua_function.cpp b/indra/llcommon/lua_function.cpp index a9f88f3170..33666964f7 100644 --- a/indra/llcommon/lua_function.cpp +++ b/indra/llcommon/lua_function.cpp @@ -1150,7 +1150,7 @@ lua_function(check_stop, "check_stop(): ensure that a Lua script responds to vie * help() *****************************************************************************/ lua_function(help, - "LL.help(): list viewer's Lua functions\n" + "help(): list viewer's Lua functions\n" "LL.help(function): show help string for specific function") { auto& luapump{ LLEventPumps::instance().obtain("lua output") }; @@ -1210,7 +1210,7 @@ lua_function(help, *****************************************************************************/ lua_function( leaphelp, - "LL.leaphelp(): list viewer's LEAP APIs\n" + "leaphelp(): list viewer's LEAP APIs\n" "LL.leaphelp(api): show help for specific api string name") { LLSD request; -- cgit v1.2.3