Difference between revisions of "LlGiveInventoryList"

From Second Life Wiki
Jump to navigation Jump to search
(The script needs to see if it has permissions to copy the object, not if the next owner will have permissions to copy it.)
(a slightly cleaner way keeping the script out of the give list. No extra search, and a bit more obvious how it works. Plus you don't get a warning when this script isn't full perm.)
Line 15: Line 15:
// This can serve as a unpacker script for boxed objects
// This can serve as a unpacker script for boxed objects


default {
default
 
{
     touch_start(integer total_number) {
     touch_start(integer total_number)
 
    {
         list        inventory;
         list        inventory;
         string      name;
         string      name;
         integer    num = llGetInventoryNumber(INVENTORY_ALL);
         integer    num = llGetInventoryNumber(INVENTORY_ALL);
         integer    i;
         integer    i;
       
         for (i = 0; i < num; ++i) {
         for (i = 0; i < num; ++i) {
             name = llGetInventoryName(INVENTORY_ALL, i);
             name = llGetInventoryName(INVENTORY_ALL, i);
             if(llGetInventoryPermMask(name, MASK_OWNER) & PERM_COPY)
             //Don't give them the selling script.
                 inventory += name;
            if(name != llGetScriptName())
            else
            {
                 llSay(0, "Don't have permissions to give you \""+name+"\".");
                if(llGetInventoryPermMask(name, MASK_OWNER) & PERM_COPY)
                 {
                    inventory += name;
                }
                else
                 {
                    llSay(0, "Don't have permissions to give you \""+name+"\".");
                }
            }
         }
         }
       
       
         if (llGetListLength(inventory) < 1)
        //we don't want to give them this script
        {
        i = llListFindList(inventory, [llGetScriptName()]);
        inventory = llDeleteSubList(inventory, i, i);
       
         if (llGetListLength(inventory) < 1) {
             llSay(0, "No items to offer.");  
             llSay(0, "No items to offer.");  
         } else {
         }
        else
        {
             // give folder to agent, use name of object as name of folder we are giving
             // give folder to agent, use name of object as name of folder we are giving
             llGiveInventoryList(llDetectedKey(0), llGetObjectName(), inventory);
             llGiveInventoryList(llDetectedKey(0), llGetObjectName(), inventory);
         }
         }
     
     }
     }
}</lsl>
}</lsl>
|helpers
|helpers

Revision as of 13:56, 21 December 2008

Summary

Function: llGiveInventoryList( key avatar, string folder, list inventory );
3.0 Forced Delay
10.0 Energy

Gives inventory items to avatar in a folder

• key avatar
• string folder
• list inventory a list of items in the inventory of the prim this script is in

Caveats

  • This function causes the script to sleep for 3.0 seconds.
  • If inventory is missing from the prim's inventory then an error is shouted on DEBUG_CHANNEL.
  • Avatar must be, or have recently been, within the same Region as sending object.
  • Does not create a folder when avatar is a prim UUID.
    • The prim must be in the same region.

Examples

<lsl>// When a user clicks this object, this script will give a folder containing everything in the objects inventory // This can serve as a unpacker script for boxed objects

default {

   touch_start(integer total_number)
   {
       list        inventory;
       string      name;
       integer     num = llGetInventoryNumber(INVENTORY_ALL);
       integer     i;

       for (i = 0; i < num; ++i) {
           name = llGetInventoryName(INVENTORY_ALL, i);
           //Don't give them the selling script.
           if(name != llGetScriptName())
           {
               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>

See Also

Events

Functions

Deep Notes

Signature

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