diff options
author | Erik Kundiman <erik@megapahit.org> | 2024-11-02 20:55:56 +0800 |
---|---|---|
committer | Erik Kundiman <erik@megapahit.org> | 2024-11-03 19:33:18 +0800 |
commit | 3f72f9a202bed628f838cc24fe58a0511ca0d161 (patch) | |
tree | 0684cfff91551d9b6aabdb825981b46a5cb53fe8 /indra/newview/scripts/lua/test_LLInventory.lua | |
parent | d302bf3c96666cfd46d7585cb3d8b6ec27bb83bf (diff) | |
parent | 9c0a6d1b0e5e9d6da6a63ff367f40ab08c064bbe (diff) |
Merge remote-tracking branch 'secondlife/release/maint-c' into maint-c
Diffstat (limited to 'indra/newview/scripts/lua/test_LLInventory.lua')
-rw-r--r-- | indra/newview/scripts/lua/test_LLInventory.lua | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/indra/newview/scripts/lua/test_LLInventory.lua b/indra/newview/scripts/lua/test_LLInventory.lua new file mode 100644 index 0000000000..de57484bcd --- /dev/null +++ b/indra/newview/scripts/lua/test_LLInventory.lua @@ -0,0 +1,24 @@ +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", limit=3} +for _, landmark in pairs(landmarks.items) do + print(landmark.name) +end + +-- 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 +-- (because getDirectDescendents().items is a Lua result set, selecting +-- a random entry only fetches one slice containing that entry) +math.randomseed(os.time()) +for i = 1, 5 do + pick = math.random(#calling_cards) + print(`Random calling card (#{pick} of {#calling_cards}): {calling_cards[pick].name}`) +end |