From NWN Lexicon
Revision as of 15:25, 24 January 2023 by Jasperre (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Determines the next item in an object's inventory.


The object that has the inventory. (Default: OBJECT_SELF)


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.


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). You can also specifically just search a given inventory bag/container, by starting a new loop with GetFirstItemInInventory(oItemContainer); which will preserve the original loop on the given creature or placeable.




// 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());

See Also



 author: Tom Cassiotis, editor: Lilac Soul, additional contributor(s): Ian Christie