Containers
Before using any container methods (add_item, remove_item, has_item, etc.), you must first retrieve the container object using the following export:
local container = exports.list_inventory:get_container(id)This returns the active container object for the given id, complete with all public methods.
Then you can use the methods below on the container like so:
local container = exports.list_inventory:get_container("some_container_id")
if not container then
print("No container found for that ID")
return
end
container:add_item("bandage", 2)get_data
Get a specific field or the full container data.
Params
key(string, optional): The key to fetch
Returns
Value of the key or full data table
set_data
Set a custom field on the container.
Params
key(string): Field namevalue(any): Value to store
Returns
true
get_items
Returns a table of all items in the container.
Returns
table: All container items indexed by slot
get_item
Returns the first matching item by slot, ID, or metadata.
Params
lookup(number|string|table): Slot number, item ID, or metadata table
Returns
Item object or
nil
has_item
Checks if container contains an item by slot, ID, or metadata.
Params
lookup(number|string|table): Slot number, item ID, or metadata tableamount(number): Amount required (default: 1)
Returns
trueif found, otherwisefalse
add_item
Adds an item to the container.
Params
id(string): Item IDamount(number): Quantityitem_data(table, optional): Item metadata (e.g., quality, custom props)
Returns
trueon success, orfalse, reasonon failure
remove_item
Removes item(s) by slot, ID, or metadata.
Params
lookup(number|string|table): Slot number, item ID, or metadata tableamount(number): Amount to remove
Returns
trueon success,falseotherwise
split_item
Splits a stack in one slot into a new slot.
Params
slot(number|string): Source slotamount(number): Amount to split
Returns
trueon success,falseotherwise
clear_items
Removes all items from the container.
Returns
true
save
Persists the container to the database (if marked as persistent).
Returns
trueon success,falseon failure
sync
Sends container inventory state to all clients.
Last updated