A storage of item stacks.
clear() | Make this inventory empty. |
can_insert(items) → boolean | Can at least some items be inserted? |
insert(items) → uint | Insert items into this inventory. |
remove(items) → uint | Remove items from this inventory. |
get_item_count(item) → uint | Get the number of all or some items in this inventory. |
is_empty() → boolean | Does this inventory contain nothing? |
get_contents() → dictionary[string → uint] | Get counts of all items in this inventory. |
supports_bar() → boolean | Does this inventory support a bar? |
get_bar() → uint | Get the current bar. |
set_bar(bar) | Set the current bar. |
supports_filters() → boolean | If this inventory supports filters. |
is_filtered() → boolean | If this inventory supports filters and has at least 1 filter set. |
can_set_filter(index, filter) → boolean | If the given inventory slot filter can be set to the given filter. |
get_filter(index) → string | Gets the filter for the given item stack index. |
set_filter(index, filter) → boolean | Sets the filter for the given item stack index. |
find_item_stack(item) → LuaItemStack | Gets the first LuaItemStack in the inventory that matches the given item name. |
find_empty_stack(item) → LuaItemStack | Finds the first empty stack. |
count_empty_stacks(include_filtered) → uint | Counts the number of empty stacks. |
get_insertable_count(item) | Gets the number of the given item that can be inserted into this inventory. |
sort_and_merge() | Sorts and merges the items in this inventory. |
resize(size) | Resizes the inventory. |
destroy() | Destroys this inventory. |
operator # :: uint [R] | Get the number of slots in this inventory. |
index :: defines.inventory [R] | The inventory index this inventory uses, or nil if the inventory doesn't have an index. |
entity_owner :: LuaEntity [R] | The entity that owns this inventory or nil if this isn't owned by an entity. |
player_owner :: LuaPlayer [R] | The player that owns this inventory or nil if this isn't owned by a player. |
equipment_owner :: LuaEquipment [R] | The equipment that owns this inventory or nil if this isn't owned by an equipment. |
mod_owner :: string [R] | The mod that owns this inventory or nil if this isn't owned by a mod. |
operator [] :: LuaItemStack [R] | The indexing operator. |
valid :: boolean [R] | Is this object valid? |
object_name :: string [R] | The class name of this object. |
help() → string | All methods and properties that this object supports. |
Make this inventory empty.
Can at least some items be inserted?
true
if at least a part of the given items could be inserted into this inventory.Insert items into this inventory.
Remove items from this inventory.
Get the number of all or some items in this inventory.
Does this inventory contain nothing?
Get counts of all items in this inventory.
Does this inventory support a bar? Bar is the draggable red thing, found for example on chests, that limits the portion of the inventory that may be manipulated by machines.
Get the current bar. This is the index at which the red area starts.
Set the current bar.
If this inventory supports filters.
If this inventory supports filters and has at least 1 filter set.
Gets the filter for the given item stack index.
Gets the first LuaItemStack in the inventory that matches the given item name.
nil
if none match.Finds the first empty stack. Filtered slots are excluded unless a filter item is given.
nil
if there aren't any empty stacks.Counts the number of empty stacks.
Gets the number of the given item that can be inserted into this inventory.
Sorts and merges the items in this inventory.
Resizes the inventory.
Destroys this inventory.
Get the number of slots in this inventory.
game.player.print(#game.player.get_main_inventory())
The inventory index this inventory uses, or nil
if the inventory doesn't have an index.
The entity that owns this inventory or nil
if this isn't owned by an entity.
The player that owns this inventory or nil
if this isn't owned by a player.
The equipment that owns this inventory or nil
if this isn't owned by an equipment.
The mod that owns this inventory or nil
if this isn't owned by a mod.
The indexing operator.
game.player.get_main_inventory()[1]