GetItemStackSize(object)

From NWN Lexicon
Revision as of 10:39, 21 June 2022 by Jasperre (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to 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).

You can check an items stack size maximum with Get2DAString and checking baseitems.2da column "Stacking".

This function is identical (except the return value when a non-item is checked) 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