Inventory Item Object
The inventory_item object represents an item stored in a player’s inventory.
It is obtained through the function player:getInventoryItems(), which returns a list of all inventory items.
Functions
inventory_item:getItemID()
Returns the item ID of the inventory entry.
-- Example:
local items = player:getInventoryItems()
for _, item in pairs(items) do
local id = item:getItemID()
player:onConsoleMessage("Item ID: " .. id)
endinventory_item:getItemCount()
Returns the quantity of that item in the inventory slot.
-- Example:
local items = player:getInventoryItems()
for _, item in pairs(items) do
local count = item:getItemCount()
player:onTalkBubble(player:getNetID(),"Item Count: " .. count,0)
endExample Usage
onPlayerEnterWorldCallback(function(world, player)
local inventory = player:getInventoryItems()
for _, item in pairs(inventory) do
local id = item:getItemID()
local count = item:getItemCount()
player:onTalkBubble(player:getNetID(),"You have " .. count .. " of item ID " .. id,0)
end
end)ℹ️
Inventory Management
Use player:getInventoryItems() to iterate through a player’s entire inventory and check item IDs and quantities.