Class Models.Container
This model represents bags, bank bags, the player's self backpack, and any other container capable of holding items.
Local Functions
models.container.getContainerItemInfo (slot) | Gets the item information for a specific slot in the container using the game's C_Container.GetContainerItemInfo API method. |
Methods
models.container:flagOutdated () | Marks the container as outdated, meaning that the container's items need to be refreshed, mapped again, to reflect the current state of the player items in the container. |
models.container:getItems () | Gets the container's items. |
models.container:getNumSlots () | Gets the number of slots in the container. |
models.container:hasItem (The) | Determines whether the container has a specific item. |
models.container:mapItems () | Scans the container represented by self.slot and updates its internal list of items. |
models.container:refresh () | This is just a facade for the mapItems() method to improve readability. |
models.container:setSlot (value) | Sets the container slot. |
Metamethods
models.container:__construct () | Container constructor. |
Local Functions
Methods- models.container.getContainerItemInfo (slot)
-
Gets the item information for a specific slot in the container using the
game's C_Container.GetContainerItemInfo API method.
Parameters:
- slot int The internal container slot to get the item information from
Returns:
-
table[string] or nil
The item information (if any) in a specific slot
Methods
- models.container:flagOutdated ()
-
Marks the container as outdated, meaning that the container's items need
to be refreshed, mapped again, to reflect the current state of the player
items in the container.
It's important to mention that this flag is named "outdated" instead of "updated" because as a layer above the game's API, the library will do the best it can to keep the container's items updated, but it's not guaranteed considering the fact that it can miss some specific events. One thing it can be sure is when the container is outdated when the BAG_UPDATE event is triggered.
Returns:
-
Models.Container
self
- models.container:getItems ()
-
Gets the container's items.
Important note: this method may scan the container for items only once. After that, it will return the cached list of items. It's necessary to call self:refresh() to update the list of items in case the caller needs the most up-to-date list, unless there's an event listener updating them automatically.
Returns:
-
table[Models.Item]
the container's items
- models.container:getNumSlots ()
-
Gets the number of slots in the container.
Returns:
-
int
the number of slots in the container
- models.container:hasItem (The)
-
Determines whether the container has a specific item.
Parameters:
- The int or Models.Item item ID or item instance to search for
Returns:
-
boolean
- models.container:mapItems ()
-
Scans the container represented by self.slot and updates its internal
list of items.
Returns:
-
Models.Container
self
- models.container:refresh ()
-
This is just a facade for the mapItems() method to improve readability.
The refresh method just updates the container's internal list of items to reflect the current state of the player's container.
Returns:
-
Models.Container
self
See also:
- models.container:setSlot (value)
-
Sets the container slot.
The slot represents the container's position in the player's inventory. A list of slots can be found with "/dump Enum.BagIndex" in game.
Parameters:
- value int the container's slot
Returns:
-
Models.Container
self