From 86eec90d97c03ac0f6be8897041185c6b5601968 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Wed, 21 Aug 2024 20:43:38 +0300 Subject: Add item limit for collectDescendentsIf func; add demo script --- indra/newview/scripts/lua/require/LLInventory.lua | 3 ++- indra/newview/scripts/lua/test_LLInventory.lua | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 indra/newview/scripts/lua/test_LLInventory.lua (limited to 'indra/newview/scripts/lua') diff --git a/indra/newview/scripts/lua/require/LLInventory.lua b/indra/newview/scripts/lua/require/LLInventory.lua index e6a347532b..b3f817da94 100644 --- a/indra/newview/scripts/lua/require/LLInventory.lua +++ b/indra/newview/scripts/lua/require/LLInventory.lua @@ -36,9 +36,10 @@ end -- [, name] -- name (substring) -- [, desc] -- description (substring) -- [, type] -- asset type +-- [, item_limit] -- item count limit in reply, maximum and default is 100 -- [, 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', ...) + local args = mapargs('folder_id,name,desc,type,filter_links,item_limit', ...) args.op = 'collectDescendentsIf' return leap.request('LLInventory', args) end diff --git a/indra/newview/scripts/lua/test_LLInventory.lua b/indra/newview/scripts/lua/test_LLInventory.lua new file mode 100644 index 0000000000..dc6eb243ad --- /dev/null +++ b/indra/newview/scripts/lua/test_LLInventory.lua @@ -0,0 +1,21 @@ +inspect = require 'inspect' +LLInventory = require 'LLInventory' + +-- Get 'My Landmarks' folder id (you can see all folder types via LLInventory.getFolderTypeNames()) +my_landmarks_id = LLInventory.getBasicFolderID('landmark') +-- Get 3 landmarks from the 'My Landmarks' folder (you can see all folder types via LLInventory.getAssetTypeNames()) +landmarks = LLInventory.collectDescendentsIf{folder_id=my_landmarks_id, type="landmark", item_limit=3} +print(inspect(landmarks)) + +-- Get 'Calling Cards' folder id +calling_cards_id = LLInventory.getBasicFolderID('callcard') +-- Get all items located directly in 'Calling Cards' folder +calling_cards = LLInventory.getDirectDescendents(calling_cards_id).items + +-- Print a random calling card name from 'Calling Cards' folder +local card_names = {} +for _, value in pairs(calling_cards) do + table.insert(card_names, value.name) +end +math.randomseed(os.time()) +print("Random calling card: " .. inspect(card_names[math.random(#card_names)])) -- cgit v1.2.3