Wizards of Lua

The Art of Spell Crafting


Item - Things You can Carry Around

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

Properties

Below you find short descriptions about each of the properties and some examples about how to use them in your spells.


count : number (int)

When this item is stackable, this is the number of items stacked.


damage : number (int)

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.


displayName : string

This is the name of the item.


id : string

The ‘id’ indentifies the type of this item.


nbt : table

The ‘nbt’ value (short for Named Binary Tag) is a table of item-specifc key-value pairs.


repairCost : number (int)

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.


Functions

Below you find short descriptions about each of the functions and some examples about how to use them in your spells.


putNbt (nbt) -> nil

The ‘putNbt’ function inserts the given table entries into this item’s nbt property.

Example

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}}})