diff --git a/.vitepress/sidebars/users.ts b/.vitepress/sidebars/users.ts index d9a8b6e..db63e32 100644 --- a/.vitepress/sidebars/users.ts +++ b/.vitepress/sidebars/users.ts @@ -37,6 +37,39 @@ export default { text: "Create's Computercraft Integration", collapsed: true, items: [ + { + text: "Logistics", + items: [ + { + text: "Packager", + link: "/users/cc-tweaked-integration/logistics/packager", + }, + { + text: "Re-Packager", + link: "/users/cc-tweaked-integration/logistics/repackager", + }, + { + text: "Stock Ticker", + link: "/users/cc-tweaked-integration/logistics/stock-ticker", + }, + { + text: "Redstone Requester", + link: "/users/cc-tweaked-integration/logistics/redstone-requester", + }, + { + text: "Table Cloth", + link: "/users/cc-tweaked-integration/logistics/table-cloth", + }, + { + text: "Package Frogport", + link: "/users/cc-tweaked-integration/logistics/package-frogport", + }, + { + text: "Postbox", + link: "/users/cc-tweaked-integration/logistics/postbox", + } + ], + }, { text: "Trains", items: [ diff --git a/users/cc-tweaked-integration/logistics/package-frogport.md b/users/cc-tweaked-integration/logistics/package-frogport.md new file mode 100644 index 0000000..28e5532 --- /dev/null +++ b/users/cc-tweaked-integration/logistics/package-frogport.md @@ -0,0 +1,28 @@ +| Method | Description | +| -------------------------------------- | ------------------------------------------------------------ | +| [`getAddress()`](#getAddress) | Gets the Frogport's address | +| [`setAddress([address])`](#setAddress) | Sets the Frogport's address | + +--- + + +### `getAddress()` {#getAddress} + +Gets the Frogport's address. + +**Returns** + +- `string` With the address currently in use. + +--- + +### `setAddress([address])` {#setAddress} + +Sets the Frogport's address to the given variable. + +If the address arg is nil, it'll unset the address. + +**Parameters** + +- _address?:_ `string = nil` Will grab packages addressed to `address`. Unsets if address is `nil`. + diff --git a/users/cc-tweaked-integration/logistics/packager.md b/users/cc-tweaked-integration/logistics/packager.md new file mode 100644 index 0000000..92abea7 --- /dev/null +++ b/users/cc-tweaked-integration/logistics/packager.md @@ -0,0 +1,131 @@ +| Method | Description | +| -------------------------------------- | ------------------------------------------------------------ | +| [`getAddress()`](#getAddress) | Gets the packager's address | +| [`setAddress([address])`](#setAddress) | Sets the packager's address | +| [`getItemCount()`](#getItemCount) | Counts the number of items in the connected inventory | +| [`list()`](#list) | Lists all items in the connected inventory | +| [`listDetailed()`](#listDetailed) | Lists all items in the connected inventory with details (slower) | +| [`makePackage()`](#makePackage) | Makes a package | +| [`getPackageItems()`](#getPackageItems) | Checks the contents of the currently held package | + +--- + + +### `getAddress()` {#getAddress} + +Gets the Packager's address. + +**Returns** + +- `string` With the address currently in use. + +--- + +### `setAddress([address])` {#setAddress} + +Sets the Packager's address to the given variable until it tries to make a package with no computer attached, at which point it forgets about it and goes back to normal behavior. +If you want to programatically assign it an address every time, it's a good idea to put .setAddress in a startup.lua file, so it applies the address you want on chunkload. + +If the address arg is nil, it'll go back to the default sign-based behavior again. + +**Parameters** + +- _address?:_ `string = nil` Force every package to be addressed to `address`. Goes back to default if address is `nil`. + +--- + +### `getItemCount()` {#getItemCount} + +Counts the number of items in the connected inventory. + +**Returns** + +- `number` The number of items in the connected inventory. + +--- + +### `list()` {#list} + +Lists basic information about all items in the connected inventory. + +**Returns** + +- `table` with basic item information like: +```lua +{ + { + name = "minecraft:apple", + count = 1, + }, + { + name = "minecraft:stick", + count = 1, + }, +} +``` + +--- + + +### `listDetailed()` {#listDetailed} + +Lists detailed information about all items in the connected inventory. + +**Returns** + +- `table` with detailed item information like: +```lua + { + count = 1, + itemGroups = { + { + id = "minecraft:food_and_drinks", + displayName = "Food & Drinks", + }, + }, + tags = { + [ "c:foods/fruit" ] = true, + [ "c:animal_foods" ] = true, + [ "minecraft:horse_food" ] = true, + [ "c:foods" ] = true, + }, + name = "minecraft:apple", + maxCount = 64, + displayName = "Apple", + }, + { + enchantments = { + { + level = 2, + name = "minecraft:knockback", + displayName = "Knockback II", + }, + }, + name = "minecraft:stick", + itemGroups = {}, + tags = { + [ "c:rods/wooden" ] = true, + [ "c:rods" ] = true, + }, + count = 1, + maxCount = 64, + displayName = "Stick", + }, +} +``` + +--- + +### `makePackage()` {#makePackage} + +Activates the packager like if it was powered by redstone. It operates by the same rule as a button press, but unlike a redstone signal, returns a value on if it actually succeeded at making a package. + +**Returns** +- `boolean` whether a new package was made successfuly. + +--- + +### `getPackageItems()` {#getPackageItems} + +**Returns** +- `table` with detailed item information or `nil` if there's no package. diff --git a/users/cc-tweaked-integration/logistics/postbox.md b/users/cc-tweaked-integration/logistics/postbox.md new file mode 100644 index 0000000..9cdcfd7 --- /dev/null +++ b/users/cc-tweaked-integration/logistics/postbox.md @@ -0,0 +1,29 @@ +| Method | Description | +| -------------------------------------- | ------------------------------------------------------------ | +| [`getAddress()`](#getAddress) | Gets the Postbox's address | +| [`setAddress([address])`](#setAddress) | Sets the Postbox's address | + +--- + + +### `getAddress()` {#getAddress} + +Gets the Postbox's address. + +**Returns** + +- `string` With the address currently in use. + +--- + +### `setAddress([address])` {#setAddress} + +Sets the Postbox's address to the given variable. + +If the address arg is nil, it'll unset the address. + +**Parameters** + +- _address?:_ `string = nil` Will receive packages addressed to `address`. Unsets if address is `nil`. + + diff --git a/users/cc-tweaked-integration/logistics/redstone-requester.md b/users/cc-tweaked-integration/logistics/redstone-requester.md new file mode 100644 index 0000000..5f82488 --- /dev/null +++ b/users/cc-tweaked-integration/logistics/redstone-requester.md @@ -0,0 +1,88 @@ +| Method | Description | +| -------------------------------------- | ------------------------------------------------------------ | +| [`getAddress()`](#getAddress) | Gets the Redstone Requester's address | +| [`setAddress([address])`](#setAddress) | Sets the Redstone Requester's address | +| [`getConfiguration()`](#getConfiguration) | Gets the Redstone Requester's configuration | +| [`configure([{[name = string], [count = number]}...])`](#configure) | Sets the Redstone Requester's configuration | +| [`request()`](#request) | Requests a package for the network | + +--- + + +### `getAddress()` {#getAddress} + +Gets the Redstone Requester's address. + +**Returns** + +- `string` With the address currently in use. + +--- + +### `setAddress([address])` {#setAddress} + +Sets the Redstone Requester's address to the given variable. + +If the address arg is nil, it'll unset the address. + +**Parameters** + +- _address?:_ `string = nil` Addresses requested packages to `address`. Unsets if address is `nil`. + + +--- + +### `getConfiguration()` {#getConfiguration} + +Gets the Redstone Requester's configuration. + +**Returns** + +- `table` Table of itemDetails. + +--- + +### `configure([{[name = string], [count = number]}]...)` {#configure} + +Sets the packagers configuration, the same one as the one available in the GUI. +- Each argument represents a slot of the configuration and is a table of the item `name`, like `create:wrench` or `apple` and the `count`, between `1` and `256`. +- nil argument or a table with an unspecified `name` equates to an empty slot. +- Unspecified `count` equates to `1` + + +**Parameters** + +- _item:_ `table` Table of `name = string` and `count = number`. + +**Usage** +```lua +redstoneRequester = peripheral.find("Create_RedstoneRequester") +redstoneRequester.configure( + { name = "minecraft:diamond", count = nil }, -- defaults to 1 + -- "diamond", -- this would error + { name = "minecraft:diamond", count = "yay" }, -- defaults to 1 + { name = "diamond", count = 1 }, -- skipping "minecraft:" works for vanilla items + { name = "minecraft:air" }, -- sets an empty slot + { name = "minecraft:stick" }, + nil, -- also sets an empty slot + {}, -- also also sets an empty slot + { name = "minecraft:stick" }, + -- not providing args at the end also sets an empty slot +) +redstoneRequester.setAddress("crafter") +redstoneRequester.request() +``` +Will request a package that crafts into a Diamond Pickaxe when provided to properly set up auto-crafters. + +While: +```lua +redstoneRequester.configure() +``` +will clear the configuration. + +--- + +### `request()` {#request} + +Requests for a package in the network using the Redstone Requester's configuration. + diff --git a/users/cc-tweaked-integration/logistics/repackager.md b/users/cc-tweaked-integration/logistics/repackager.md new file mode 100644 index 0000000..b440323 --- /dev/null +++ b/users/cc-tweaked-integration/logistics/repackager.md @@ -0,0 +1,53 @@ +| Method | Description | +| -------------------------------------- | ------------------------------------------------------------ | +| [`getAddress()`](#getAddress) | Gets the Re-Packager's address | +| [`setAddress([address])`](#setAddress) | Sets the Re-Packager's address | +| [`makePackage()`](#makePackage) | Makes a package | +| [`getPackageItems()`](#getPackageItems) | Checks the contents of the currently held package | +| [`getPackageAddress()`](#getPackageAddress) | Checks the address of the currently held package | + +--- + +### `getAddress()` {#getAddress} + +Gets the Re-Packager's address. + +**Returns** + +- `string` With the address currently in use. + +--- + +### `setAddress([address])` {#setAddress} + +Sets the Re-Packager's address to the given variable until it tries to make a package with no computer attached, at which point it forgets about it and goes back to normal behavior. +If you want to programatically assign it an address every time, it's a good idea to put .setAddress in a startup.lua file, so it applies the address you want on chunkload. + +If the address arg is nil, it'll go back to the default sign-based behavior again. + +**Parameters** + +- _address?:_ `string = nil` Force every package to be addressed to `address`. Goes back to default if address is `nil`. + +--- + +### `makePackage()` {#makePackage} + +Activates the Re-Packager as if it is powered by redstone. It operates by the same rule as a button press, but unlike a redstone signal, returns a value on if it actually succeeded at making a package. + +**Returns** +- `boolean` whether a new package was made successfuly. + +--- + +### `getPackageItems()` {#getPackageItems} + +**Returns** +- `table` with detailed item information or `nil` if there's no package. + +--- + +### `getPackageAddress()` {#getPackageAddress} + +**Returns** +- `string` with the package's address or `nil` if there's no package. diff --git a/users/cc-tweaked-integration/logistics/stock-ticker.md b/users/cc-tweaked-integration/logistics/stock-ticker.md new file mode 100644 index 0000000..165838b --- /dev/null +++ b/users/cc-tweaked-integration/logistics/stock-ticker.md @@ -0,0 +1,170 @@ +| Method | Description | +| -------------------------------------- | ------------------------------------------------------------ | +| [`getItemCount()`](#getItemCount) | Counts the number of items in the network | +| [`list()`](#list) | Lists all items in the network | +| [`listDetailed()`](#listDetailed) | Lists all items in the network with details (slower) | +| [`requestFiltered(filter, [address])`](#requestFiltered) | Requests a package from the network | +| [`listPaymentInventory()`](#listPaymentInventory) | Lists all items kept by the Stock Ticker | + +--- + +### `getItemCount()` {#getItemCount} + +Counts the number of items in the network. + +**Returns** + +- `number` The number of items in the system. + +--- + +### `list()` {#list} + +Lists basic information about all items in the network. + +**Returns** + +- `table` with basic item information like: +```lua +{ + { + name = "minecraft:apple", + count = 1, + }, + { + name = "minecraft:stick", + count = 1, + }, +} +``` + +--- + + +### `listDetailed()` {#listDetailed} + +Lists detailed information about all items in the network. + +**Returns** + +- `table` with detailed item information like: +```lua + { + count = 1, + itemGroups = { + { + id = "minecraft:food_and_drinks", + displayName = "Food & Drinks", + }, + }, + tags = { + [ "c:foods/fruit" ] = true, + [ "c:animal_foods" ] = true, + [ "minecraft:horse_food" ] = true, + [ "c:foods" ] = true, + }, + name = "minecraft:apple", + maxCount = 64, + displayName = "Apple", + }, + { + enchantments = { + { + level = 2, + name = "minecraft:knockback", + displayName = "Knockback II", + }, + }, + name = "minecraft:stick", + itemGroups = {}, + tags = { + [ "c:rods/wooden" ] = true, + [ "c:rods" ] = true, + }, + count = 1, + maxCount = 64, + displayName = "Stick", + }, +} +``` + +--- + + +### `requestFiltered(filter, [address])` {#requestFiltered} + +Requests for a package in the network with the given filter. The filter is a table of item traits that's evaluated as follows: + +for all items in the network (until the `count` parameter is reached): +- If a string under `name`/`nbt` is provided, it will only pick an item with a matching `name`/`nbt`. +- If a number under `damage`/`durability`/`maxDamage`/`maxCount` is provided, it will only pick an item with a matching `damage`/`durability`/`maxDamage`/`maxCount`. +- If a table under `tags` is provied, it will only pick items that have **at least** all of the given tags +- If a table under `enchantments` is provied, it will only pick items that have **exactly** one enchantment per set of `name`, `displayName` and/or `level`. The filters are executed in order. + +The candidates that pass the filter are then passed on to be requested manually by the network, like if you opened the Stock Keeper's ui. + +**Parameters** + +- _filter:_ `table` Table of values to filter items by, similar to that of [Inventory.getItemDetail()](https://tweaked.cc/generic_peripheral/inventory.html#v:getItemDetail). +- _address?:_ `string = ""` Target address given to the package. + +**Returns** +- `number` Number of items requested with the given filter. + +**Usage** +```lua +stockTicker = peripheral.find("Create_StockTicker") +stockTicker.request( + { + name = "minecraft:enchanted_book", -- name of the item. fills in "minecraft:" at the start if mod name isn't provided + tags = { -- required tags for the item to pass + ["minecraft:bookshelf_books"] = true, -- any item that doesn't have this tag gets excluded + }, + enchantments = { -- the item has exactly: + { -- 1 enchant that: + name = "minecraft:unbreaking", -- has this name (Doesn't need to be specified) + level = 1, -- and has this level (Doesn't need to be specified) + --displayName = "Unbreaking I" -- has this display name (Doesn't need to be specified) + }, -- 1 other enchant that: + { + --is any enchant + } + }, + --damage = 0, -- how much damage has the item's durability taken + --durability = 1, -- how hard is it for the item to take durability damage + --maxDamage = 64, -- how much durability damage the item can take before breaking + maxCount = 1, -- max stack size + --nbt = "dbe2b6a18b578d3118ebc849409d46f5", -- hashed nbt of the item. + count = 3 -- how many items you want to request + }, "MyAddress" -- shipping address +) +``` +Should request up to three Unbreaking I enchantment books that also have another enchant, like Unbreaking I+Soul Speed II, Unreaking I+Protection I and Sharpness I+Unbreaking I. + +While: +```lua +stockTicker.request({}) +``` +Would request all items in the network, because all items would pass the empty filter. + +--- + +### `listPaymentInventory()` {#listPaymentInventory} + +Lists basic information about the items inside the Stock Ticker (not the network!). + +**Returns** + +- `table` with basic item information like: +```lua +{ + { + name = "minecraft:apple", + count = 1, + }, + { + name = "minecraft:stick", + count = 1, + }, +} + diff --git a/users/cc-tweaked-integration/logistics/table-cloth.md b/users/cc-tweaked-integration/logistics/table-cloth.md new file mode 100644 index 0000000..f970ae9 --- /dev/null +++ b/users/cc-tweaked-integration/logistics/table-cloth.md @@ -0,0 +1,127 @@ +| Method | Description | +| -------------------------------------- | ------------------------------------------------------------ | +| [`isShop()`](#isShop) | Returns true if it's a store | +| [`getAddress()`](#getAddress) | Gets the Table Cloth's address | +| [`setAddress([address])`](#setAddress) | Sets the Table Cloth's address | +| [`getPriceTagItem()`](#getPriceTagItem) | Gets the pricetag item | +| [`setPriceTagItem([name])`](#setPriceTagItem) | Sets the pricetag item | +| [`getPriceTagCount()`](#getPriceTagCount) | Gets the pricetag item count| +| [`setPriceTagCount([count])`](#setPriceTagCount) | Sets the pricetag item count| +| [`getWares()`](#getWares) | Gets the items being sold | +| [`setWares([{[name = string], [count = number]}...])`](#setWares) | Sets the items being sold with their counts | + +--- +::: danger Important! +The Table Cloth is only available as a peripheral if it's a store or if there's items on it. It will remain a peripheral as long as there is a computer/modem/turtle attached to it, even if it is emptied. +::: + +### `isShop()` {#isShop} + +Checks if the Table Cloth is a shop or not. + +**Returns** + +- `boolean`, True if it's a shop. + +--- + +### `getAddress()` {#getAddress} + +Gets the Table Cloth's address. + +**Returns** + +- `string` With the address currently in use. + +--- + +### `setAddress([address])` {#setAddress} + +Sets the Table Cloth's address to the given variable. + +If the address arg is nil, it'll unset the address. + +**Parameters** + +- _address?:_ `string = nil` Addresses processed pruchases to `address`. Unsets if address is `nil`. + + +--- + +### `getPriceTagItem()` {#getPriceTagItem} + +Gets the Item used for the Table Cloth's price tag. + +**Returns** + +- `table` Table of itemDetails. + +--- + + +### `setPriceTagItem([name])` {#setPriceTagItem} + +Sets the Item used for the Table Cloth's price tag. + +**Parameters** + +- name?:_ `string = nil` Sets the Item to `name`. Unsets if name is `nil`. + +--- + +### `getPriceTagCount()` {#getPriceTagCount} + +Gets the Table Cloth's Pricetag item count. + +**Returns** + +- `number` Number of items. + +--- + + +### `setPriceTagCount([count])` {#setPriceTagCount} + +Sets the Table Cloth's Pricetag item count. + +**Parameters** + +- count?:_ `count = 1` Sets the count to `count`. + + +--- + +### `getWares()` {#getWares} + +Gets the list of items requested on purchase. + +**Returns** + +- `table` Table of itemDetails. + +--- + +### `setWares([{[name = string], [count = number]}]...)` {#setWares} + +Sets the Table Cloth's wares that get requested on purchase. +- Each argument represents an item to be requested and is a table of the item `name`, like `create:wrench` or `apple` and the `count`, between `1` and `256`. +- nil argument or a table with an unspecified `name` equates to an empty slot. +- Unspecified `count` equates to `1` +- If no items are provided, the tablecloth stops being a shop, and goes back to normal behaviour. + +**Parameters** + +- _item:_ `table` Table of `name = string` and `count = number`. + +**Usage** +```lua +tableCloth = peripheral.find("Create_TableCloth") +if tableCloth.isShop() then +tableCloth.setWares( + { name = "minecraft:diamond"}, -- defaults to 1 + { name = "redstone", count = 30 } +) +tableCloth.setPriceTagItem("gold_ingot") +tableCloth.setPriceTagCount(2) +end +```