LlGetInventoryType Test

From Second Life Wiki
Jump to: navigation, search

[LLGetInventoryTypeTest]

[VERSION] 0.1

[LENGTH] 00:15

[TESTERS] 1

[OVERVIEW] This test has been designed to exercise the LLGetInventoryType LSL function.

[SETUP] This test requires 1 Tester and rezzable land

[*]

[0010] Right-click on the ground and select "Create" from the pie menu and Rez a default cube

[0020] Click "more >>" if neccesary and select the contents tab

[0040] Open your Inventory and locate/copy or create one of each of the following to the cubes contents folder

[0050] An animation, bodypart, item of clothing, gesture, landmark, notecard, an object, a script, sound, a texture or image.

[0060] Also insert the following script into the cubes contents

[SCRIPT] llGetInventoryTypeTest

[0070] Close the edit window

[0080] Left-click on the cube

[0090] Verify the type of item it chats corresponds to the name and actual type of item it is.

[0100] Delete the cube

[END]


[llGetInventoryTypeTest]

list INVENTORY_TYPES = [
    INVENTORY_NONE,
    INVENTORY_ANIMATION,
    INVENTORY_BODYPART,
    INVENTORY_CLOTHING,
    INVENTORY_GESTURE,
    INVENTORY_LANDMARK,
    INVENTORY_NOTECARD,
    INVENTORY_OBJECT,
    INVENTORY_SCRIPT,
    INVENTORY_SOUND,
    INVENTORY_TEXTURE ];
    
list INVENTORY_DESCRIPTIONS = [
    "not a known item",
    "an animation",
    "a bodypart",
    "a clothing item",
    "a gesture",
    "a landmark",
    "a notecard",
    "an object",
    "a script",
    "a sound",
    "a texture" ];

default
{
    touch_start(integer num_detected)
    {
        integer NumItems =  llGetInventoryNumber(INVENTORY_ALL);
        integer i;
        for (i = 0; i < NumItems; i++)
        {
            string Name = llGetInventoryName(INVENTORY_ALL, i);
            integer Type = llGetInventoryType(Name);
            integer TypeIndex = llListFindList(INVENTORY_TYPES, [Type]);
            if (TypeIndex == -1)
            {
                llOwnerSay("ERROR: Unknown type for item '" + Name + "'.");
                return;
            }
            string Desc = llList2String(INVENTORY_DESCRIPTIONS, TypeIndex);
            llOwnerSay("'" + Name + "' is " + Desc + ".");       
        }
    }
}