The Item class represents all things a creature can hold in its hands and which can be stored in an inventory.
The Item class is a subtype of the Object class and inherits all its properties and functions.
Here is an overview of the Item properties:
Property | Type | read / write |
---|---|---|
count | number (int) | r/w |
damage | number (int) | r/w |
displayName | string | r/w |
id | string | r |
nbt | table | r |
repairCost | number (int) | r/w |
Here is an overview of the Item functions:
Function | Parameters | Results |
---|---|---|
putNbt | nbt | nil |
Below you find short descriptions about each of the properties and some examples about how to use them in your spells.
When this item is stackable, this is the number of items stacked.
This is the numerical damage value of this item.
The higher the value, the more damaged this item is.
A value of 0 means the item is not damaged.
This is the name of the item.
The ‘id’ indentifies the type of this item.
The ‘nbt’ value (short for Named Binary Tag) is a table of item-specifc key-value pairs.
This is the number of enchantment levels to add to the base level cost when repairing, combining, or renaming this item with an anvil.
If this value is negative, it will effectively lower the cost. However, the total cost will never fall below zero.
Below you find short descriptions about each of the functions and some examples about how to use them in your spells.
The ‘putNbt’ function inserts the given table entries into this item’s nbt property.
Setting the lore (description) of the item in the wizard’s hand.
local text1 = "Very important magical stuff."
local text2 = "Use with caution!"
local loreTbl = { text1, text2}
local item = spell.owner.mainhand
item:putNbt({tag={display={Lore=loreTbl}}})