SetItemStackSize
Contents |
[edit] SetItemStackSize(object, int)
Set the number of items in a given stack.
void SetItemStackSize( object oItem, int nSize );
[edit] Parameters
oItem
Item to set the stack size of.
nSize
New stack size.
[edit] Description
Sets the number of items in a given stack. If a number less than 1 is passed, then the stack size is set to 1 (not destroyed like the SetItemCharges function). If a number greater than the maximum stack size for an item of its type is passed, the number of items in the stack is set to the item's maximum stack size.
[edit] Remarks
Other than removing a single item from a stack of, say, potions (or adding one), this function can be used to determine if an item is stackable or not. See code sample below.
[edit] Known Bugs
Setting the stack size on an item at ground won't updates to the nearby players.
[edit] Version
1.30
[edit] Example
//Returns TRUE if oItem is stackable int GetIsStackableItem(object oItem) { //Must have a chest tagged checkchest object oCopy=CopyItem(oItem, GetObjectByTag("checkchest")); //Set the stacksize to two SetItemStackSize(oCopy, 2); //Check if it really is two - otherwise, not stackable! int bStack=GetItemStackSize(oCopy)==2; //Destroy the test copy DestroyObject(oCopy); //Return bStack which is TRUE if item is stackable return bStack; }
[edit] See Also
functions: |
author: Charles Feduke, editor: Lilac Soul, additional contributor(s): Lilac Soul