API:GetItemStackCount
From RoR Wiki
UI Lua API · Item functions
Version: WAR 1.4.8
Returns how many of an item the player has, by item id.
count = GetItemStackCount(itemId)
Arguments
- itemId
number– Item id (theidfield of an item data table).
Returns
- count
number– The count the client keeps for that item id, added up over all stacks. 0 if the player has none.
Details
- The value comes from a running total the client keeps per item id. It does not walk the backpacks.
- If there is no player object, or the argument check fails, the function still returns 0.
- Exactly one argument must be passed.
Errors
None besides the generic Invalid Parameters message when the argument is missing or not a number.
Example
Showing the total count on an action button that uses an item, from default/ea_actionbars/source/actionbutton.lua:
if (actionType == GameData.PlayerActions.USE_ITEM)
then
local totalCount = GetItemStackCount (actionId)
if (totalCount > 1)
then
showCountWindow = true
self.m_Windows[STACK_COUNT_TEXT]:SetText (totalCount)
end
From default/ea_interactionwindow/source/interactionaltar.lua:
EA_Window_InteractionAltar.numItemsInBackpack = GetItemStackCount( altarData.donationType )
