Difference between revisions of "LlGiveAgentInventory"

From Second Life Wiki
Jump to navigation Jump to search
m (Added example after testing it on ADITI)
 
Line 20: Line 20:


|caveats
|caveats
|examples
|examples=
In this example, the object inventory needs to contain two objects named ''Item 1'' and ''Item 2''. The destination folder will be named ''Destination Folder'' and will be created under the main folder ''Objects'', in the sub-folder ''Subfolder''. If ''Subfolder'' does not exist, it will be created.
 
If the object gets touched for a second time, the sub-folder ''Subfolder'' will '''not''' be duplicated, however the destination folder ''Destination Folder'' '''will''' be duplicated.
 
If ''Item 1'' and/or ''Item 2'' do not exist, the transfer will silently fail partially or completely.
<syntaxhighlight lang="lsl2">default
{
    touch_start(integer total_number)
    {
        llGiveAgentInventory(llDetectedKey(0), "Destination Folder", ["Item 1","Item 2"], [0, "Objects|Subfolder"] );
    }
}</syntaxhighlight>
|helpers
|helpers
|also_functions={{LSL DefineRow||[[llGiveInventory]]}}
|also_functions={{LSL DefineRow||[[llGiveInventory]]}}

Latest revision as of 08:04, 19 December 2024

Summary

Function: integer llGiveAgentInventory( key agent, string folder, list inventory, list options );
3.0 Forced Delay
10.0 Energy

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

• key agent agent to receive inventory offer.
• string folder destination folder name to use.
• list inventory a list of items in the inventory of the prim this script is inlist of inventory items to give to the agent
• list options list of options for inventory transfer.

Specification

  • The target must be an avatar in the same region as the sending object, or must have recently been in the region.
  • Places the inventory items in a newly created folder in the avatar's inventory (even if there is a folder by the same name, a new one is created).
  • If a path of root folders has been specified, the function will ensure that those folders exist but will not recreate them if they already exist.

Transfer Options

Flags Parameters Description
TRANSFER_DEST 0 [ TRANSFER_DEST, string ] Sets a root path that will be used as the parent for folder. If the root path does not exist it will be created.

If it already exists in the target inventory it will be reused. Path folders are separated by a "|" character. The path may have have up to 4 folders in it.

Examples:
"Objects|Vehicles|My Motorcycle Company"
"Clothing|Shoes|Breedables"
"My Store|Home & Garden|"

TRANSFER_FLAGS 1 [ TRANSFER_FLAGS, integer ] There are no flags defined at this time.

Transfer Errors

Constant Description
TRANSFER_OK 0 No error detected, inventory transferred
TRANSFER_BAD_OPTS -1 A bad option was passed in the options list.
TRANSFER_NO_TARGET -2 Could not find the receiving agent in the current region.
TRANSFER_THROTTLE -3 Transfer rate exceeded the inventory transfer throttle.
TRANSFER_NO_ITEMS -4 The list of items was empty or contained only non-transferable items.
TRANSFER_BAD_ROOT -5 The root path specified in TRANSFER_DEST contained an invalid directory or was reduced to nothing.
TRANSFER_NO_PERMS -6 The object does not have transfer permissions.
TRANSFER_NO_ATTACHMENT -7 Can not transfer ownership of an attached object.

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.
  • If inventory permissions do not allow copy, the transfer fails and an error is shouted on DEBUG_CHANNEL.
  • If target is a prim that is not in the same region 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.

Examples

In this example, the object inventory needs to contain two objects named Item 1 and Item 2. The destination folder will be named Destination Folder and will be created under the main folder Objects, in the sub-folder Subfolder. If Subfolder does not exist, it will be created.

If the object gets touched for a second time, the sub-folder Subfolder will not be duplicated, however the destination folder Destination Folder will be duplicated.

If Item 1 and/or Item 2 do not exist, the transfer will silently fail partially or completely.

default
{
    touch_start(integer total_number)
    {
        llGiveAgentInventory(llDetectedKey(0), "Destination Folder", ["Item 1","Item 2"], [0, "Objects|Subfolder"] );
    }
}

See Also

Events

•  changed

Functions

•  llGiveInventory
•  llGiveInventoryList

Deep Notes

Signature

function integer llGiveAgentInventory( key agent, string folder, list inventory, list options );