Difference between revisions of "GetItemsInInventory"
From Dragon Age Toolset Wiki
BryanDerksen (Talk | contribs) m |
m (Fixing error with extraction) |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
− | |||
{{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= | + | |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 |
− | | | + | |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 | + | Provides access to a [[creature|creature's]] or [[placeable|placeable's]] inventory and equipped items. |
− | + | == 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. | ||
− | < | + | 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
);
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]); } }