Difference between revisions of "GetItemsInInventory"

From Dragon Age Toolset Wiki
Jump to: navigation, search
(Added a bug related to the nBaseItemType param)
m (Fixing error with extraction)
 
Line 1: Line 1:
{{Generated with errors}}
 
 
{{dafunction
 
{{dafunction
|name=GetItemsInInventory
+
|name         = GetItemsInInventory
|brief=Gets all items in an object inventory
+
|brief         = Gets all items in an object inventory
|param1type=object
+
|param1type   = object
|param1name=oObject
+
|param1name   = oObject
|param1desc=A creature or placeable with an inventory
+
|param1desc   = A creature or placeable with an inventory
|param1default=
+
|param1default =
|param2type=int
+
|param2type   = int
|param2name=nGetItemsOptions
+
|param2name   = nGetItemsOptions
|param2desc=
+
|param2desc   = A [[GET_ITEMS_OPTION_*]] constant
|param2default=GET_ITEMS_OPTION_ALL
+
|param2default = GET_ITEMS_OPTION_ALL
|param3type=int
+
|param3type   = int
|param3name=nBaseItemType
+
|param3name   = nBaseItemType
|param3desc=Return only items with base item type matching. 0 to disable this filter. NB : This filter does not work on placeables inventories.
+
|param3desc   = Only return items with a matching base item type or 0 to disable this filter
|param3default=0
+
|param3default = 0
|param4type=string
+
|param4type   = string
|param4name=sTagFilter
+
|param4name   = sTagFilter
|param4desc=
+
|param4desc   = Only return items with a matching tag or "" to disable this filter
|param4default=""
+
|param4default = ""
|param5type=int
+
|param5type   = int
|param5name=bIgnorePlotItems
+
|param5name   = bIgnorePlotItems
|param5desc=
+
|param5desc   = Only return items which are NOT plot items or FALSE to disable this filter
|param5default=FALSE
+
|param5default = FALSE
|returntype=object
+
|returntype   = object
|returnarra=TRUE
+
|returnarra   = TRUE
|returndesc=
+
|returndesc   = An array of all items in/on the object that match the specified filters
|sourcefile=script.ldf
+
|sourcefile   = script.ldf
|sourcemodule=
+
|sourcemodul  =
 
}}
 
}}
  
 
== Description ==
 
== Description ==
 
<!-- This section contains the full description from the functions comments. Do not change unless you are confident these are incomplete or incorrect. -->
 
<!-- This section contains the full description from the functions comments. Do not change unless you are confident these are incomplete or incorrect. -->
Provides access to a creatures or placeables inventory and equipped items.
+
Provides access to a [[creature|creature's]] or [[placeable|placeable's]] inventory and equipped items.
  
<!-- == Remarks == -->
+
== Remarks ==
 
<!-- This section contains additional comments, observations and known issues. -->
 
<!-- This section contains additional comments, observations and known issues. -->
 +
The <code>nGetItemsOptions</code> filter is not a bit field, i.e. you cannot use the [[bitwise or operator]] to combine options.
  
<!-- == Examples == -->
+
The <code>nBaseItemType</code> filter does not work on placeable's inventories.
 +
 
 +
== Examples ==
 
<!-- This section contains examples transcluded from the snippet library. -->
 
<!-- This section contains examples transcluded from the snippet library. -->
 +
<dascript>
 +
// Remove all equipped items from a creature and put them in the creature's inventory.
 +
void UnequipAllEquippedItems(object oCreature)
 +
{
 +
    int nItem;
 +
 +
    object[] oItems = GetItemsInInventory(oCreature, GET_ITEMS_OPTION_EQUIPPED);
 +
    int nItems = GetArraySize(oItems);
 +
 +
    for(nItem = 0; nItem < nItems; nItem++)
 +
    {
 +
        UnequipItem(oCreature, oItems[nItem]);
 +
    }
 +
}
 +
</dascript>
  
 
<!-- == See also == -->
 
<!-- == See also == -->
 
<!-- This section contains links to articles, functions or constant groups. -->
 
<!-- This section contains links to articles, functions or constant groups. -->
  
[[Category: Items functions]]
+
[[Category:Items functions]]

Latest revision as of 10:55, 8 June 2014

Gets all items in an object inventory

object[] GetItemsInInventory(
object oObject,
int nGetItemsOptions = GET_ITEMS_OPTION_ALL,
int nBaseItemType = 0,
string sTagFilter = "",
int bIgnorePlotItems = FALSE
);
Parameters:
oObject
A creature or placeable with an inventory
nGetItemsOptions
A GET_ITEMS_OPTION_* constant
nBaseItemType
Only return items with a matching base item type or 0 to disable this filter
sTagFilter
Only return items with a matching tag or "" to disable this filter
bIgnorePlotItems
Only return items which are NOT plot items or FALSE to disable this filter
Returns:

An array of all items in/on the object that match the specified filters

Source:

script.ldf

Description

Provides access to a creature's or placeable's inventory and equipped items.

Remarks

The nGetItemsOptions filter is not a bit field, i.e. you cannot use the bitwise or operator to combine options.

The nBaseItemType filter does not work on placeable's inventories.

Examples

// Remove all equipped items from a creature and put them in the creature's inventory.
void UnequipAllEquippedItems(object oCreature)
{
    int nItem;
 
    object[] oItems = GetItemsInInventory(oCreature, GET_ITEMS_OPTION_EQUIPPED);
    int nItems = GetArraySize(oItems);
 
    for(nItem = 0; nItem < nItems; nItem++)
    {
        UnequipItem(oCreature, oItems[nItem]);
    }
}