| Method | Description |
|---|---|
getAddress() | Gets the PostBox's address |
getConfiguration() | Gets the PostBox's configuration |
getItemDetail() | Gets detailed information about an item in the PostBox's given slot |
list() | Lists all items in the PostBox's inventory |
setAddress(address) | Sets the PostBox's address |
setConfiguration(configuration) | Sets the PostBox's configuration |
| Event | Description |
|---|---|
package_sent | Triggers when a package is sent |
package_received | Triggers when a package is received |
getAddress()
Gets the PostBox's address.
Returns
stringWith the address currently in use.
getConfiguration()
Gets the PostBox's configuration.
Returns
stringWith either"send_recieve"or"send"as the configuration.
getItemDetail(slot)
Get detailed information about an item in the PostBox's inventory.
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 out of range.
Returns
tableInformation about the item in this slot, ornilif it is empty, like:
{
tags = {
[ "create:packages" ] = true,
},
maxCount = 1,
name = "create:cardboard_package_12x10",
itemGroups = {},
count = 1,
nbt = "ceed8ad969b49055bc14042fc07b6892",
displayName = "Cardboard Package",
package = { -- Packages come with this field, which points to the Package Object
getAddress(), --function: 38260b86
getItemDetail(), -- function: 7de9d189
getOrderData(), -- function: 6d149c07
isValid(), -- function: 3a6300d3
list(), -- function: 1c7bc70
setAddresS(), -- function: 1c7bc70
}
}list()
List all items in the PostBox's inventory. 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 sparse, so empty slots will be nil - it is recommended to loop over using pairs rather than ipairs.
Returns
tablewith basic item information like:
{
{
nbt = "ceed8ad969b49055bc14042fc07b6892",
count = 1,
name = "create:cardboard_package_12x10",
},
{
nbt = "c04232dbe75de33196e9d261136f7a27",
count = 1,
name = "create:cardboard_package_10x8",
},
},setAddress(address)
Sets the PostBox's address to the given variable.
If the address arg is nil, it'll unset the address.
Parameters
- address:
stringWill grab packages addressed toaddress.
setConfiguration(configuration)
Sets the PostBox's configuration to either "send_recieve" or "send", represented by the bottoms on the bottom left of it's gui.
"send_recieve"will only send out packages that don't match the PostBox's address, and it will recieve packages that match it's address."send"will send out all packages and not recieve any packages.
Parameters
- address:
stringThe desired configuration, either"send_recieve"or"send".
Events
The following are events that can be accessed with os.pullEvent(filter).
Event: package_sent
Triggers when a package is deposited onto a train.
Returns
tablePackage Object of the sent package.
Event: package_received
Triggers when a package is extracted from a train.
Returns
tablePackage Object of the received package.