Difference between revisions of "LlGetInventoryName"

From Second Life Wiki
Jump to navigation Jump to search
Line 11: Line 11:
|caveats
|caveats
|constants={{LSL Constants Inventory}}
|constants={{LSL Constants Inventory}}
|examples
|examples======Will Unpack all items of a box=====
<pre>
// script created by SpiritWolf Chikuwa
//
// /!\ PUBLIC DOMAIN /!\
// You can Copy/Mod/Trans
// Please, do not resell this script and give it full perm
// Just please leave this header intact
//
// Minor changes: (insert your name here and delete this comment if you do any mod of this script, thank you)
//
// Script start here:
 
list    gInventoryList;
 
list getInventoryList()
{
    integer    i;
    integer    n = llGetInventoryNumber(INVENTORY_ALL);
    list          result = [];
 
    for( i = 0; i < n; i++ )
    {
        result += [ llGetInventoryName(INVENTORY_ALL, i) ];
    }
    return result;
}
 
default
{
    state_entry()
    {
        gInventoryList = getInventoryList();
    }
 
    touch_start( integer n )
    {
       
        integer i;
 
        for( i = 0; i < n; i++ )
        {
            llGiveInventoryList(llDetectedKey(i), llGetObjectName(), gInventoryList );
       
        }
    }
 
    changed( integer change )
    {
      if ( change == CHANGED_INVENTORY )
          gInventoryList = getInventoryList();
    }
}
 
// llGetInventory number and name will scan all objects on the box.
// llGiveInventory will give you the content.
// See also llGetInventory and llGiveInventory on LSL Wiki for further informations.
</pre>
|helpers
|helpers
|also_functions=
|also_functions=

Revision as of 20:09, 2 March 2007

Summary

Function: string llGetInventoryName( integer type, integer number );
0.0 Forced Delay
10.0 Energy

Returns a string that is the name of the inventory item number of type.

• integer type INVENTORY_* flag
• integer number

number does not support negative indexes.

Flag Inventory Type
INVENTORY_NONE -1 Item does not exist.
INVENTORY_ALL Any inventory type.
INVENTORY_TEXTURE 0 texture
INVENTORY_SOUND 1 sound
INVENTORY_LANDMARK 3 landmark
INVENTORY_CLOTHING 5 clothing
INVENTORY_OBJECT 6 object
Flag Inventory Type
INVENTORY_NOTECARD 7 notecard
INVENTORY_SCRIPT 10 script
INVENTORY_BODYPART 13 body part
INVENTORY_ANIMATION 20 animation
INVENTORY_GESTURE 21 gesture
INVENTORY_SETTING 56 setting
INVENTORY_MATERIAL 57 material

Caveats

  • If number is out of bounds the script continues to execute without an error message.

Examples

Will Unpack all items of a box
// script created by SpiritWolf Chikuwa
//
// /!\ PUBLIC DOMAIN /!\
// You can Copy/Mod/Trans 
// Please, do not resell this script and give it full perm
// Just please leave this header intact
//
// Minor changes: (insert your name here and delete this comment if you do any mod of this script, thank you)
//
// Script start here:

list    gInventoryList;

list getInventoryList()
{
    integer    i;
    integer    n = llGetInventoryNumber(INVENTORY_ALL);
    list          result = [];

    for( i = 0; i < n; i++ )
    {
        result += [ llGetInventoryName(INVENTORY_ALL, i) ];
    }
    return result;
}

default
{
    state_entry()
    {
        gInventoryList = getInventoryList();
    }

    touch_start( integer n )
    {
        
        integer i;

        for( i = 0; i < n; i++ )
        {
            llGiveInventoryList(llDetectedKey(i), llGetObjectName(), gInventoryList );
        
        }
    }

    changed( integer change )
    {
       if ( change == CHANGED_INVENTORY )
           gInventoryList = getInventoryList();
    }
}

// llGetInventory number and name will scan all objects on the box.
// llGiveInventory will give you the content.
// See also llGetInventory and llGiveInventory on LSL Wiki for further informations.

Deep Notes

Signature

function string llGetInventoryName( integer type, integer number );