GetItemStackSize(object)

From NWN Lexicon
Jump to: navigation, search

Determines the number of stacked items contained within an inventory object.

int GetItemStackSize(
    object oItem
);

Parameters

oItem
The item to determine the stack count of.


Description

Returns the number of items in a stack attached to oItem. Only items that are the same may be stacked; i.e. two gems of the same name can be stacked, but a sword and an arrow cannot.


Remarks

Returns 0 if an invalid object is provided for oItem, or if oItem isn't an item (like a creature or a placeable).

This function is identical to GetNumStackedItems but was added later to likely be the logical counterpart to SetItemStackSize.


Version

1.30

Example

// Demonstrates how to check an NPC's arrow supply and yield speech when it is depleted.
 
void main()
{
     // Retrieves NPC's arrow object.
     object oArrows = GetObjectByTag("MY_ARROWS");
 
     if(GetItemStackSize(oArrows) == 0)
     {
          ActionSpeakString("My arrow supply is depleted!");
     }
}

See Also

functions:

GetNumStackedItems SetItemStackSize