summaryrefslogtreecommitdiff
path: root/indra/newview/scripts
diff options
context:
space:
mode:
authorMnikolenko Productengine <mnikolenko@productengine.com>2024-08-21 20:43:38 +0300
committerMnikolenko Productengine <mnikolenko@productengine.com>2024-08-21 20:43:38 +0300
commit86eec90d97c03ac0f6be8897041185c6b5601968 (patch)
tree24d803ba148294fda58a63847e763dfec648600b /indra/newview/scripts
parent3cef79d979f2d21c29d17d123d6c166b9f7e7e0e (diff)
Add item limit for collectDescendentsIf func; add demo script
Diffstat (limited to 'indra/newview/scripts')
-rw-r--r--indra/newview/scripts/lua/require/LLInventory.lua3
-rw-r--r--indra/newview/scripts/lua/test_LLInventory.lua21
2 files changed, 23 insertions, 1 deletions
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)]))