Difference between revisions of "LlGiveInventoryList"

From Second Life Wiki
Jump to navigation Jump to search
m
Line 1: Line 1:
{{Issues/SVC-868}}{{LSL_Function/give|target|inventory|sim=*|uuid=false|insert=list of items}}{{LSL_Function
{{Issues/SVC-868}}{{LSL_Function/give|target|inventory|sim=*|uuid=false|copyok=*|insert=list of items}}{{LSL_Function
|func_id=231|func_sleep=3.0|func_energy=10.0
|func_id=231|func_sleep=3.0|func_energy=10.0
|func=llGiveInventoryList
|func=llGiveInventoryList

Revision as of 16:12, 4 May 2010

Summary

Function: llGiveInventoryList( key target, string folder, list inventory );

Gives inventory items to target, creating a new folder to put them in.

• key target avatar or prim UUID that is in the same region
• string folder folder name to use
• list inventory a list of items in the inventory of the prim this script is in

Specification

target types

Depending upon the type of target this function works differently.

  • Avatar
    • Must be or recently have been within the same Region as sending object. SVC-868
    • Places the inventory items in a newly created folder in the avatars inventory (even if there is a folder by the same name, a new one is created).
  • Prim / Object
    • The prim must be in the same region.
    • Does not create a folder.

Caveats

  • This function causes the script to sleep for 3.0 seconds.
  • If target is not the owner nor shares the same owner, and inventory does not have transfer permissions, an error is shouted on DEBUG_CHANNEL.
  • When scripts are copied or moved between inventories, their state does not survive the transfer. Memory, event queue and execution position are all discarded.
  • If inventory is missing from the prim's inventory then an error is shouted on DEBUG_CHANNEL.
All Issues ~ Search JIRA for related Bugs

Examples

<lsl>// When any user clicks this object, this script will give a folder containing everything in the objects inventory // This could be used to give away multiple freebies at once.

default {

   touch_start(integer total_number)
   {
       list        inventory;
       integer     num = llGetInventoryNumber(INVENTORY_ALL);
       string      script = llGetScriptName();
       integer     i = 0;

       for (; i < num; ++i) {
           string name = llGetInventoryName(INVENTORY_ALL, i);
           //Don't give them the selling script.
           if(name != script)
           {
               if(llGetInventoryPermMask(name, MASK_OWNER) & PERM_COPY)
               {
                   inventory += name;
               }
               else
               {
                   llSay(0, "Don't have permissions to give you \""+name+"\".");
               }
           }
       }

       if (llGetListLength(inventory) < 1)
       {
           llSay(0, "No items to offer."); 
       }
       else
       {
           // give folder to agent, use name of object as name of folder we are giving
           llGiveInventoryList(llDetectedKey(0), llGetObjectName(), inventory);
       }
   }

}</lsl> This script illustrates how to use llGiveInventoryList and llGiveInventory together to unpack no-copy items from a box. Copiable items will end up in a folder. No-copy items are transferred separately. <lsl>default {

    touch_start(integer total_number)
    {
         if(llDetectedKey(0) == llGetOwner())
         {
              string InvenName;
              integer InvenNumber = llGetInventoryNumber(INVENTORY_ALL);
              list InvenList = [];
              integer y;
              for(y = 0; y < InvenNumber; y++)
              {
                   InvenName = llGetInventoryName(INVENTORY_ALL, y);
                   if(!llGetInventoryPermMask(InvenName,PERM_COPY))
                   {
                        llGiveInventory(llGetOwner(),InvenName);
                   }
                   else
                   {
                        InvenList += [InvenName];
                   }
              }
              llGiveInventoryList(llGetOwner(), llGetObjectName(), InvenList);
         }
    }

}

</lsl>

See Also

Events

•  changed

Functions

•  llGiveInventory

Deep Notes

All Issues

~ Search JIRA for related Issues
   llGiveInventoryList should be able to work gridwide

Signature

function void llGiveInventoryList( key target, string folder, list inventory );