Class Models.Inventory
This model represents the group of all player containers condensed as a single concept.
It's a concept because the game doesn't have a visual inventory, but it shows the items inside bags, bank slots, keyring, etc, that are mapped as containers, while the inventory is the "sum" of all these containers.
Local Functions
models.inventory.maybeMapContainers () | May map the containers if the inventory is outdated. |
Methods
models.inventory:flagOutdated () | Marks the inventory as outdated, meaning that the container's items need to be refreshed, mapped again, in which container inside this inventory instance to reflect the current state of the player items in all containers. |
models.inventory:getItems () | Gets all items from the inventory. |
models.inventory:hasItem (The) | Determines whether the inventory has a specific item. |
models.inventory:mapContainers () | Maps all player containers in the inventory internal list. |
models.inventory:refresh () | Iterates over all containers in the inventory and refreshes their items. |
Metamethods
models.inventory:__construct () | Inventory constructor. |
Local Functions
Methods- models.inventory.maybeMapContainers ()
-
May map the containers if the inventory is outdated.
Returns:
-
Models.Inventory
self
Methods
- models.inventory:flagOutdated ()
-
Marks the inventory as outdated, meaning that the container's items need
to be refreshed, mapped again, in which container inside this inventory
instance to reflect the current state of the player items in all
containers.
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.Inventory
self
See also:
- models.inventory:getItems ()
-
Gets all items from the inventory.
This method will return all items from all containers mapped in the inventory.
Make sure to call this method after any actions that trigger the inventory mapping (refresh), to get the most updated items.
- models.inventory:hasItem (The)
-
Determines whether the inventory has a specific item.
Parameters:
- The int or Models.Item item ID or item instance to search for
Returns:
-
boolean
- models.inventory:mapContainers ()
-
Maps all player containers in the inventory internal list.
This method will also trigger the mapping of the containers slot, so it's expected to have the player items synchronized after this method is called.
Returns:
-
Models.Inventory
self
- models.inventory:refresh ()
-
Iterates over all containers in the inventory and refreshes their items.
Returns:
-
Models.Inventory
self