| Method | Description |
|---|---|
getAddress() | Gets the package's address |
getItemDetail(slot) | Gets detailed information about an item in the package |
getOrderData() | Gets the orderData object associated with the package |
isEditable() | Checks if the package is editable |
list() | Lists all items in the package |
setAddress(address) | Sets the package's address |
Mutability
Package Objects are snapshots of the package in the moment.
You can get your packageObject by either using .getItemDetail on a package (it'll expose a package field, which is this object), or by using a packager/re-packager's getPackage.
If by any means the package has its data changed, be it by an addon or by another computer using the setAddress function, the snapshot will not be notified, and it'll be outdated.
When a package is held within a packager/re-packager, if you call it using getPackage, it's isEditable function should return true until it leaves the (re)packager. In this state you change it's address with setAddress on the fly.
getAddress()
Gets the package's address.
If the package isEditable, then it'll also update the snapshot's address, in case it has changed.
Returns
stringWith the address currently in use.
getItemDetail(slot)
Get detailed information about an item in the package.
The returned information contains the same information as each item in list, as well as additional details like the display name (displayName), and item durability (damage, maxDamage, durability).
Some items include more information (such as enchantments) - it is recommended to print it out using textutils.serialize or in the Lua REPL, to explore what is available.
Parameters
- slot:
numberThe slot to get information about.
Throws
- If the slot is not between 1 and 9.
Returns
tableInformation about the item in this slot, ornilif it is empty, like:
{
name = "minecraft:apple",
itemGroups = {},
tags = {},
count = 1,
maxCount = 64,
displayName = "Apple",
}getOrderData()
Gets the orderData object of the package if it's an encoded package.
Returns
orderDataof the package, ornilif none is present, like:
{
getCrafts(), -- function: 52d1c058
getIndex(), -- function: 1f03a979
getItemDetail(), -- function: 4782ee89
getLinkIndex(), -- function: 3dfc0241
getOrderID(), -- function: 625c4b8e
isFinal(), -- function: 4953530c
isFinalLink(), -- function: 19750a09
list(), -- function: 4446fd6c
}isEditable()
Tells you if the package is sitting inside a packager/repackager you called this object from, if you called it via getPackage.
otherwise returns false.
Returns
booleanthat'strueif the package is editable,falseotherwise.
list()
List all items inside the package. This returns a table, with an entry for each slot.
Each item in the inventory is represented by a table containing some basic information. More information can be fetched with getItemDetail. The table contains the item name, the count and a (potentially nil) hash of the item's nbt. This NBT data doesn't contain anything useful, but allows you to distinguish identical items.
The returned table is never sparse, so you can iterate over it with ipairs just fine.
Returns
tablewith basic item information like:
{
{
name = "minecraft:apple",
count = 1,
},
{
name = "minecraft:stick",
count = 1,
},
{
nbt = "ce5c752cf2df5cf4ffb17d7b7bfacad7",
count = 1,
name = "minecraft:enchanted_book",
},
}setAddress(address)
Sets the package's address to the given value if it isEditable (so, inside the packager/repackager it was called from using specifically getPackage)
This also updates the package object's getAddress to the return the new address.
Parameters
- address:
stringWill change the package's address toaddress.
Throws
- If
isEditableisfalse.