WoW:API GetBagName: Difference between revisions
Jump to navigation
Jump to search
m (Notes) |
m (Move page script moved page API GetBagName to API GetBagName without leaving a redirect) |
||
(4 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
{{wowapi}} | |||
;''Arguments'' | ;''Arguments'' | ||
:;:(bagID) | :;:(bagID) | ||
:::;[[API TYPE bagID|bagID]] : number - number of the bag the item is in, 0 is your backpack, 1-4 are the four additional bags, numbered right to left. | :::;[[API TYPE bagID|bagID]] : number - number of the bag the item is in, 0 is your backpack, 1-4 are the four additional bags, numbered right to left. Actually, for this method, this parameter is valid as [[API_ContainerIDToInventoryID]]. | ||
---- | ---- | ||
Line 14: | Line 13: | ||
local bagName = GetBagName(0); | local bagName = GetBagName(0); | ||
--Returns "Backpack" | -- Returns localized "Backpack". | ||
---- | ---- | ||
;''Result'' | ;''Result'' | ||
: bagName will contain the name of the specified bag if the bag number is 0-4 otherwise it will be nil, unless when the bank is opened, in which case GetBagName(-1) (for the bank) is nil and GetBagName( | : bagName will contain the name of the specified bag if the bag number is 0-4 otherwise it will be nil, unless when the bank is opened, in which case GetBagName(-1) (for the bank) is nil and GetBagName(5) will give the name of the first bank bag, GetBagName(6) the name of the second bank bag, etc ... When coding, use the global variables (NUM_BAG_SLOTS, etc, ...) instead of hard coding these numbers, in case they change in the future. For details, see [[BagId]]. | ||
---- | ---- | ||
;''Notes'' | ;''Notes'' | ||
: It seems that there is no way to check the keyholder | : It seems that there is no way to check the keyholder name; GetContainerNumSlots and GetBagName returns 32 and nil while bagID is -2. | ||
:: GetBagName(-2) - returns nil | :: GetBagName(-2) - returns nil | ||
:: GetContainerNumSlots(-2) - returns | :: GetContainerNumSlots(-2) - always returns 32 | ||
Latest revision as of 04:45, 15 August 2023
← WoW API < GetBagName
- Arguments
-
- (bagID)
-
- bagID
- number - number of the bag the item is in, 0 is your backpack, 1-4 are the four additional bags, numbered right to left. Actually, for this method, this parameter is valid as API_ContainerIDToInventoryID.
- Returns
- bagName
- bagName - the name of the specified bag (example "Green Woolen Bag")
- Examples
local bagName = GetBagName(0); -- Returns localized "Backpack".
- Result
- bagName will contain the name of the specified bag if the bag number is 0-4 otherwise it will be nil, unless when the bank is opened, in which case GetBagName(-1) (for the bank) is nil and GetBagName(5) will give the name of the first bank bag, GetBagName(6) the name of the second bank bag, etc ... When coding, use the global variables (NUM_BAG_SLOTS, etc, ...) instead of hard coding these numbers, in case they change in the future. For details, see BagId.
- Notes
- It seems that there is no way to check the keyholder name; GetContainerNumSlots and GetBagName returns 32 and nil while bagID is -2.
- GetBagName(-2) - returns nil
- GetContainerNumSlots(-2) - always returns 32