From 3cef79d979f2d21c29d17d123d6c166b9f7e7e0e Mon Sep 17 00:00:00 2001
From: Mnikolenko Productengine <mnikolenko@productengine.com>
Date: Tue, 20 Aug 2024 23:09:14 +0300
Subject: Add collectDescendentsIf api for Lua

---
 indra/newview/scripts/lua/require/LLInventory.lua | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

(limited to 'indra/newview/scripts')

diff --git a/indra/newview/scripts/lua/require/LLInventory.lua b/indra/newview/scripts/lua/require/LLInventory.lua
index 880a2516f1..e6a347532b 100644
--- a/indra/newview/scripts/lua/require/LLInventory.lua
+++ b/indra/newview/scripts/lua/require/LLInventory.lua
@@ -19,10 +19,29 @@ function LLInventory.getBasicFolderID(ft_name)
     return leap.request('LLInventory', {op = 'getBasicFolderID', ft_name=ft_name}).id
 end
 
+-- Get the table of asset type names, which can be later used to get the specific items via LLInventory.collectDescendentsIf(...)
+function LLInventory.getAssetTypeNames()
+    return leap.request('LLInventory', {op = 'getAssetTypeNames'}).type_names
+end
+
 -- Get the direct descendents of the 'folder_id' provided,
 -- reply will contain "items" and "categories" tables accordingly
 function LLInventory.getDirectDescendents(folder_id)
     return leap.request('LLInventory', {op = 'getDirectDescendents', folder_id=folder_id})
 end
 
+-- Get the descendents of the 'folder_id' provided, which pass specified filters
+-- reply will contain "items" and "categories" tables accordingly
+-- LLInventory.collectDescendentsIf{ folder_id   -- parent folder ID
+-- [, name]              -- name (substring)
+-- [, desc]              -- description (substring)
+-- [, type]              -- asset type
+-- [, filter_links]}     -- EXCLUDE_LINKS - don't show links, ONLY_LINKS - only show links, INCLUDE_LINKS - show links too (default)
+function LLInventory.collectDescendentsIf(...)
+    local args = mapargs('folder_id,name,desc,type,filter_links', ...)
+    args.op = 'collectDescendentsIf'
+    return leap.request('LLInventory', args)
+end
+
+
 return LLInventory
-- 
cgit v1.2.3