GetNextItemInInventory
From NWN Lexicon
Contents |
[edit] GetNextItemInInventory(object)
Determines the first item in an object's inventory.
object GetNextItemInInventory( object oTarget = OBJECT_SELF );
[edit] Parameters
oTarget
The object that has the inventory. (Default: OBJECT_SELF)
[edit] Description
Returns the next item in oTarget's inventory or OBJECT_INVALID if the caller is not a creature, item, placeable or store, or if no more items are found.
[edit] Remarks
GetFirstItemInInventory() should be called on oTarget before this function is be called.
When an item with an inventory (such as a bag of holding) is returned using the GetFirstItemInInventory and GetNextItemInInventory functions, the next call to GetNextItemInInventory will start to look inside the nested inventory (e.g. the bag of holding's inventory).
[edit] Version
1.62
[edit] Example
// This function counts up the total number of items in the first PC's inventory. //(The number of items in a stackable count toward the total) void main() { int nItems = 0; object oItem = GetFirstItemInInventory(GetFirstPC()); while (GetIsObjectValid(oItem) == TRUE) { nItems = nItems + GetNumStackedItems(oItem); oItem = GetNextItemInInventory(GetFirstPC()); } }
[edit] See Also
functions: |
author: Tom Cassiotis, editor: Lilac Soul, additional contributor(s): Ian Christie