Kryzeth Standard Library

entity.inventory

Methods8

function Inventory.each(inventory: LuaInventory, func: function, ...: any[opt]) -> LuaItemStack | nil

Given a function, apply it to each slot in the given inventory. Passes the index of a slot as the second argument to the given function. <p>Iteration is aborted if the applied function returns true for any element during iteration.

Parameters
inventoryLuaInventory

the inventory to iterate

funcfunction

the function to apply to values

...any[opt]

additional arguments passed to the function

Returns
LuaItemStack | nil

the slot where the iteration was aborted OR nil if not aborted

function Inventory.each_reverse(inventory: LuaInventory, func: function, ...: any[opt]) -> LuaItemStack | nil

Given a function, apply it to each slot in the given inventory. Passes the index of a slot as the second argument to the given function. <p>Iteration is aborted if the applied function returns true for any element during iteration. <p>Iteration is performed from last to first in order to support dynamically sized inventories.

Parameters
inventoryLuaInventory

the inventory to iterate

funcfunction

the function to apply to values

...any[opt]

additional arguments passed to the function

Returns
LuaItemStack | nil

the slot where the iteration was aborted OR nil if not aborted

function Inventory.copy_as_simple_stacks(src: LuaInventory, dest: LuaInventory, clear: boolean[opt]) -> ItemStackDefinition[]

Copies the contents of source inventory to destination inventory by using @{ItemStackDefinition}.

Parameters
srcLuaInventory

the source inventory

destLuaInventory

the destination inventory

clearboolean[opt]
Returns
ItemStackDefinition[]

an array of left over items that could not be inserted into the destination

function Inventory.get_blueprint(stack: LuaItemStack, is_bp_setup: nil | boolean, no_book: nil | boolean) -> LuaItemStack | nil

Return a blueprint stack from either stack or blueprint_book

Parameters
stackLuaItemStack
is_bp_setupnil | boolean

[opt]

no_booknil | boolean

[opt]

Returns
LuaItemStack | nil
function Inventory.is_named_bp(stack: LuaItemStack, label: string) -> boolean

Is the stack a blueprint whose label begins with the specified text?

function Inventory.get_item_or_filter(inventory: LuaInventory, idx: integer, item_only: nil | boolean, filter_only: nil | boolean) -> any

Returns either the item at a position, or the filter at the position if there isn't an item there.

Parameters
inventoryLuaInventory
idxinteger
item_onlynil | boolean

[opt]

filter_onlynil | boolean

[opt]

Returns
any

the item or filter

function Inventory.transfer_inventory(source: LuaInventory, destination: LuaInventory, source_filters: table[opt]) -> nil | table

Transfer items from 1 inventory to another.

Parameters
sourceLuaInventory
destinationLuaInventory
source_filterstable[opt]
Returns
nil | table

the filters if the destination does not support filters

function Inventory.swap_inventory(source: LuaInventory, destination: LuaInventory) -> nil

Swap items from 1 inventory to another.

Fields2

Inventory.__class: string = "Inventory"
Inventory.__index : StdLib.Core