From 3d7e020353989474a290a3f8ca7bada9e20697f5 Mon Sep 17 00:00:00 2001 From: RebeccaNod1 Date: Fri, 8 May 2026 17:26:30 -0600 Subject: [PATCH] Add GetWornItems, AddOutfit, and RemoveOutfit commands for dashboard integration --- SecondBotEvents/Commands/Inventory.cs | 46 +++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/SecondBotEvents/Commands/Inventory.cs b/SecondBotEvents/Commands/Inventory.cs index a022256..97ede5e 100644 --- a/SecondBotEvents/Commands/Inventory.cs +++ b/SecondBotEvents/Commands/Inventory.cs @@ -1,4 +1,4 @@ -using BetterSecondBot.Static; +using BetterSecondBot.Static; using System.Text.Json; using OpenMetaverse; using OpenMetaverse.Assets; @@ -1100,7 +1100,7 @@ namespace SecondBotEvents.Commands } - [About("Requests the mapped inventory on the bot using catched data only")] + [About("Requests theMapped inventory on the bot using catched data only")] [ReturnHints("a json data object with: " + "{" + " Name: String
"+ @@ -1115,6 +1115,48 @@ namespace SecondBotEvents.Commands return BasicReply(JsonSerializer.Serialize(root, JsonOptions.UnsafeRelaxed)); } + [About("Requests a list of all worn item UUIDs")] + [ReturnHints("List of UUID strings")] + [CmdTypeGet()] + public object GetWornItems() + { + List worn = []; + var links = master.CurrentOutfitFolder.ContentLinks(); + foreach (var link in links) + { + worn.Add(link.AssetUUID.ToString()); + } + return BasicReply(JsonSerializer.Serialize(worn, JsonOptions.UnsafeRelaxed)); + } + + [About("Adds the contents of the given folder to the current outfit")] + [ArgHints("folder", "UUID of folder", "UUID")] + [CmdTypeDo()] + public object AddOutfit(string folder) + { + if (UUID.TryParse(folder, out UUID folderUUID) == false) return Failure("invaild folder uuid", [folder]); + List contents = GetClient().Inventory.FolderContents(folderUUID, GetClient().Self.AgentID, true, true, InventorySortOrder.ByName, TimeSpan.FromSeconds(15)); + if (contents == null) return Failure("folder empty or not found", [folder]); + List items = []; + foreach (InventoryBase item in contents) if (item is InventoryWearable || item is InventoryObject) items.Add((InventoryItem)item); + master.CurrentOutfitFolder.AddToOutfit(items, false); + return BasicReply("ok", [folder]); + } + + [About("Removes the contents of the given folder from the current outfit")] + [ArgHints("folder", "UUID of folder", "UUID")] + [CmdTypeDo()] + public object RemoveOutfit(string folder) + { + if (UUID.TryParse(folder, out UUID folderUUID) == false) return Failure("invaild folder uuid", [folder]); + List contents = GetClient().Inventory.FolderContents(folderUUID, GetClient().Self.AgentID, true, true, InventorySortOrder.ByName, TimeSpan.FromSeconds(15)); + if (contents == null) return Failure("folder empty or not found", [folder]); + List items = []; + foreach (InventoryBase item in contents) if (item is InventoryWearable || item is InventoryObject) items.Add((InventoryItem)item); + master.CurrentOutfitFolder.RemoveFromOutfit(items); + return BasicReply("ok", [folder]); + } + protected InventoryNodeEntry LoadInventoryNode(UUID folder, string name="") { InventoryNodeEntry myentry = new InventoryNodeEntry();