Skip to content
lsl.devlsl.devLSL Dev

Inventory

Every prim has its own inventory, the Contents tab in the build window. It holds the scripts that run in the prim, plus objects to rez, notecards to read, and textures, sounds, animations, landmarks and other items for scripts to use or hand out. This page is about that prim inventory. It does not cover an avatar’s own inventory, which scripts cannot browse; scripts can only offer items to it.

Inventory sits underneath most other features. A vendor gives a folder of goods, a gun rezzes bullets (see Combat), a configurable product reads a notecard, and an updater loads scripts into other prims. Every item carries permission masks, and those masks decide what a script may do with it.

Concepts

Functions and events

These are the functions and events for working with a prim’s inventory.

integerllGetInventoryNumber(integer type)
stringllGetInventoryName(integer type, integer index)
integerllGetInventoryType(string item)
keyllGetInventoryKey(string item)
keyllGetInventoryCreator(string item)
stringllGetInventoryDesc(string item)
stringllGetInventoryAcquireTime(string item)
integerllGetInventoryPermMask(string item, integer group)
voidllGiveInventory(key target, string item)
voidllGiveInventoryList(key target, string folder, list items)
integerllGiveAgentInventory(key agent, string folder, list items, list options)
voidllRemoveInventory(string item)
voidllRezObject(string item, vector pos, vector vel, rotation rot, integer start_param)
voidllRezAtRoot(string item, vector pos, vector vel, rotation rot, integer start_param)
keyllRezObjectWithParams(string item, list options)
integerllDerezObject(key id, integer flags)
eventobject_rez(key id)
keyllGetNotecardLine(string name, integer line)
stringllGetNotecardLineSync(string name, integer line)
keyllGetNumberOfNotecardLines(string name)
voidllSetScriptState(string script, integer running)
integerllGetScriptState(string script)
voidllResetOtherScript(string script)
voidllRemoteLoadScriptPin(key target, string script, integer pin, integer running, integer start_param)
voidllSetRemoteScriptAccessPin(integer pin)
voidllAllowInventoryDrop(integer add)
keyllRequestInventoryData(string item)
eventchanged(integer changes)
eventdataserver(key queryid, string data)

Notecards as configuration

A notecard is the usual way for owners to configure a product without editing its script. Read it from state_entry, and read it again when changed reports CHANGED_INVENTORY. Notecards are also covered under Data Storage.

Vendors and givers

Selling and handing out items combines this feature with Money for payment, Dialog for menus and llGiveInventoryList to deliver a folder.

Rezzers

Rezzing objects from inventory is also part of Linksets, where the rezzed object’s on_rez event and start parameter are covered.

Scripting Details

Here are the functions and events in detail.

integerllGetInventoryNumber(integer type)
Returns the number of items of a given type (INVENTORY_*, or INVENTORY_ALL) in the prim
stringllGetInventoryName(integer type, integer index)
Returns the name of the item of a given type at index. Items are sorted alphabetically
integerllGetInventoryType(string item)
Returns the INVENTORY_* type of the named item, or INVENTORY_NONE if there is no such item
keyllGetInventoryKey(string item)
Returns the asset key of the item. Returns NULL_KEY unless the item is copy, modify and transfer; a notecard that has never been saved also has NULL_KEY
keyllGetInventoryCreator(string item)
Returns the key of the item’s creator
stringllGetInventoryDesc(string item)
Returns the item’s description
stringllGetInventoryAcquireTime(string item)
Returns when the item was placed in the prim, as a UTC timestamp "YYYY-MM-DDThh:mm:ssZ"
integerllGetInventoryPermMask(string item, integer group)
Returns the item’s PERM_* flags for the MASK_* category in group
voidllGiveInventory(key target, string item)
Gives one item to an avatar or to an object in the same region. Scripts given to an object arrive disabled; send a running script with llRemoteLoadScriptPin instead
voidllGiveInventoryList(key target, string folder, list items)
Gives a list of items to an avatar as a new folder named folder. When the target is an object, the items go straight into its inventory and no folder is made
integerllGiveAgentInventory(key agent, string folder, list items, list options)
Gives items to an avatar in the same region as a new folder, with options such as TRANSFER_DEST, and returns a TRANSFER_* status. No-copy items are left out
voidllRemoveInventory(string item)
Permanently deletes the named item. If the script removes itself, it keeps running for a short time
voidllRezObject(string item, vector pos, vector vel, rotation rot, integer start_param)
Rezzes an inventory object with its bounding box centred on pos, passing start_param to the new object’s on_rez event
voidllRezAtRoot(string item, vector pos, vector vel, rotation rot, integer start_param)
Like llRezObject, but places the object’s root prim at pos
keyllRezObjectWithParams(string item, list options)
Rezzes an inventory object with a list of REZ_* parameters, and returns its key, or a blank key on failure
eventobject_rez(key id)
Triggered in the rezzer when it has rezzed an object from inventory, with the new object’s key
integerllDerezObject(key id, integer flags)
With DEREZ_TO_INVENTORY in flags, takes an object rezzed by this linkset back into the rezzer’s inventory, saving its current state in place of the original item; other DEREZ_* flags delete it or mark it temporary. Returns TRUE on success. The target must have the same owner, be copyable and not be an attachment
keyllGetNotecardLine(string name, integer line)
Requests line line (counting from 0) of a notecard. The text arrives in dataserver, or EOF past the end. Only the first 1024 bytes of a long line are returned
stringllGetNotecardLineSync(string name, integer line)
Returns line line at once from the region’s cache, without a dataserver event. Returns NAK if the notecard is not cached, or EOF past the end
keyllGetNumberOfNotecardLines(string name)
Requests the number of lines in a notecard; the count arrives in dataserver as a string
voidllSetScriptState(string script, integer running)
Sets another script in the prim running (TRUE) or stopped (FALSE). It cannot start a script that arrived through llGiveInventory
integerllGetScriptState(string script)
Returns TRUE if the named script in the prim is running
voidllResetOtherScript(string script)
Resets the named script in the prim
voidllRemoteLoadScriptPin(key target, string script, integer pin, integer running, integer start_param)
Copies a script into target, running or not, with start_param. The owner needs modify rights on the target, and pin must match the PIN the target set
voidllSetRemoteScriptAccessPin(integer pin)
Sets this prim’s PIN for llRemoteLoadScriptPin. A PIN of 0 disables remote loading
voidllAllowInventoryDrop(integer add)
With TRUE, anyone can drop items (but not scripts) into the prim. In a linkset it must be called from the root prim
keyllRequestInventoryData(string item)
Requests data for an inventory item through dataserver. Only landmarks are supported; they return the position they point to, relative to the current region
eventchanged(integer changes)
Triggered when the object changes; the changes bitfield includes CHANGED_INVENTORY and CHANGED_ALLOWED_DROP for inventory changes
eventdataserver(key queryid, string data)
Triggered when requested data arrives: notecard lines and counts, landmark data and other queries. Match queryid against the key the request returned

Additional

Constant groups InventoryType 14AssetPermission 5AssetPermissionCategory 5AssetPermissionCategoryFlag 1GiveAgentInventoryParam 2TransferError 8DerezMode 3

See also Feature PrimsFeature LinksetsFeature Data StorageFeature AvatarsCategory Prim InventoryCategory Avatar InventoryCategory NotecardCategory Asset PermissionsPlanned Recipe: reading a configuration notecardPlanned Recipe: a simple giver