Basic Digitizer¶

The basic digitizer turns physical item stacks into portable digital identifiers and restores them through its internal inventory.
- Peripheral type
digitizer- Storage
- Items
- Failure style
- Lua errors
Slots are one-based and default to slot 1. digitize() removes the complete
stack; digitizeAmount() requires an exact positive amount no greater than the
physical stack.
Inherited inventory API:
size,list,getItemDetail,getItemLimit,pushItems, andpullItemsare also available on this peripheral.
Round trip a partial stack¶
import { digitizerProvider } from "@siredvin/typed-peripheral-digitalitems/digitizer";
const digitizer = digitizerProvider.findOrThrow();
const id = digitizer.digitizeAmount(16, 1);
const info = digitizer.getIDInfo(id);
print(`${info.item.count} ${info.item.name}`);
const inserted = digitizer.rematerializeAmount(id, 8);
print(`Inserted ${inserted}`);
local digitizer = peripheral.find("digitizer")
assert(digitizer, "digitizer not attached")
local id = digitizer.digitizeAmount(16, 1)
local info = digitizer.getIDInfo(id)
print(('%d %s'):format(info.item.count, info.item.name))
local inserted = digitizer.rematerializeAmount(id, 8)
print("Inserted " .. inserted)
Errors and remaining items¶
All failures throw. Empty slots, non-positive amounts, requesting more than the physical or digital count, and unknown or decayed identifiers are errors.
rematerialize() requests the entire digital count, while
rematerializeAmount() requests a chosen count. Both insert only what the
internal inventory can accept and return the actual inserted item count. If
space is limited, the uninserted remainder stays digital under the same ID.
Use the inherited inventory API to inspect and move physical stacks. For
example, list() reports occupied slots and pullItems() can fill the
digitizer from another attached inventory before digitization.
Peripheral methods¶
The reference below is generated from the published TypeScript interface.
getDecayEnabled¶
Returns: Whether identifier decay is currently enabled by server configuration.
getDecayTicks¶
Returns: The configured lifetime after creation or refresh, in server ticks.
digitize¶
Removes the complete stack from an internal inventory slot and digitizes it.
| Parameter | Type | Description |
|---|---|---|
slot? |
number \| undefined |
One-based inventory slot. Defaults to slot 1. |
Returns: A new opaque 16-byte binary identifier.
Throws: A Lua error if the slot is empty or the slot is invalid.
rematerialize¶
Rematerializes as much of an item identifier as the internal inventory can accept.
| Parameter | Type | Description |
|---|---|---|
id |
string |
Opaque binary identifier returned by a digitize method. |
Returns: The number of items inserted. The identifier remains valid if items remain.
Throws: A Lua error if the identifier is unknown or has decayed.
digitizeAmount¶
Removes and digitizes an exact number of items from an internal slot.
| Parameter | Type | Description |
|---|---|---|
amount |
number |
Positive number of items to remove. |
slot? |
number \| undefined |
One-based inventory slot. Defaults to slot 1. |
Returns: A new opaque 16-byte binary identifier.
Throws: A Lua error if amount is not positive, the slot is empty, or fewer items are present.
rematerializeAmount¶
Attempts to insert an exact requested portion into the internal inventory.
| Parameter | Type | Description |
|---|---|---|
id |
string |
Opaque binary item identifier. |
amount |
number |
Positive number of items requested; it cannot exceed the stored count. |
Returns: The number actually inserted, which may be lower when inventory space is limited.
Throws: A Lua error for an invalid or decayed identifier, invalid amount, or insufficient stored count.
refresh¶
Resets an identifier's decay deadline to current game time plus getDecayTicks().
| Parameter | Type | Description |
|---|---|---|
id |
string |
Opaque binary item identifier. |
Throws: A Lua error if the identifier is unknown or has decayed.
getIDInfo¶
Reads the current item and timing metadata for an identifier.
| Parameter | Type | Description |
|---|---|---|
id |
string |
Opaque binary item identifier. |
Returns: Identifier timing metadata and full item details.
Throws: A Lua error if the identifier is unknown or has decayed.
pushItems¶
Inherited from InventoryAPI.
| Parameter | Type | Description |
|---|---|---|
toName |
string |
|
fromSlot |
number |
|
limit? |
number \| undefined |
|
toSlot? |
number \| undefined |
pullItems¶
Inherited from InventoryAPI.
| Parameter | Type | Description |
|---|---|---|
fromName |
string |
|
fromSlot |
number |
|
limit? |
number \| undefined |
|
toSlot? |
number \| undefined |
size¶
Inherited from InventoryViewAPI.
list¶
Inherited from InventoryViewAPI.
getItemDetail¶
Inherited from InventoryViewAPI.
| Parameter | Type | Description |
|---|---|---|
slot |
number |
getItemLimit¶
Inherited from InventoryViewAPI.
| Parameter | Type | Description |
|---|---|---|
slot |
number |
getConfiguration¶
Inherited from ConfigurationAPI.