In this chapter you will learn how to use ItemStacks.
- Creating ItemStacks
- Name and Count
- Adding and Taking Items
- Lua Tables
- More Methods
An item stack is a… stack of items. It’s basically just an item type with
a count of items in the stack.
You can create a stack like so:
You could alternatively create a blank ItemStack and fill it using methods:
And you can copy stacks like this:
Name and Count
Adding and Taking Items
add_item to add items to an ItemStack.
An ItemStack of the items that could not be added is returned.
The following code takes up to 100.
If there aren’t enough items in the stack, it will take as much as it can.
ItemStacks also have wear on them. Wear is a number out of 65535, the higher it is,
the more wear.
When digging a node, the amount of wear a tool gets may depends on the node
being dug. So max_uses varies depending on what is being dug.
ItemStacks can also have a single field of metadata attached to
Have a look at the
list of methods for an ItemStack.
There are a lot more available than talked about here.