Advanced Digitizer¶
The advanced digitizer moves items, fluids, and energy between attached storage and durable digital identifiers.
- Peripheral type
advanced_digitizer- Storage
- Items, fluids, energy
- Failure style
- Recoverable result pairs
The advanced digitizer can extract from its internal inventory with source
self, or from an attached inventory/item storage by peripheral name. The
source defaults to self.
Mode matters: an identifier belongs to exactly one of
item,fluid, orenergy. Always use the same mode when inspecting, refreshing, or restoring it.
Item filters may be:
- A one-based slot number. This requires slotted storage.
- A namespaced item string such as
minecraft:oak_log. - A query table using fields such as
name,displayName,tag,nbt,and,or,not, ornone. nil/null, which accepts any item.
Digitize and accumulate¶
const chest = peripheral.find("minecraft:chest");
assert(chest != null, "chest not attached");
const chestName = peripheral.getName(chest);
const [id, createError] = digitizer.digitize(
"item", chestName, "minecraft:oak_log", 32
);
if (id == null) error(createError, 0);
const [sameID, mergeError] = digitizer.digitize(
"item", chestName, { tag: "minecraft:logs" }, 32, id
);
if (sameID == null) error(mergeError, 0);
local chest = peripheral.find("minecraft:chest")
assert(chest, "chest not attached")
local chestName = peripheral.getName(chest)
local id, createErr = digitizer.digitize(
"item", chestName, "minecraft:oak_log", 32
)
if not id then error(createErr, 0) end
local sameID, mergeErr = digitizer.digitize(
"item", chestName, { tag = "minecraft:logs" }, 32, id
)
if not sameID then error(mergeErr, 0) end
The optional destination is an existing binary digital ID, not a peripheral
name. A merge succeeds only when the extracted stack can stack with the stored
item. It refreshes the destination and returns the same ID.
An explicit limit must be from 1 through itemStackLimit / 2. When merging
without a limit, that half-limit is the default per call, further reduced by
remaining room. Accumulation cannot exceed itemStackLimit. A new ID created
without a limit asks the source for all matching available content; do not
assume the configured accumulation limit is an implicit cap for that call.
Rematerialize¶
const [moved, moveError] = digitizer.rematerialize("item", id, 64, chestName);
if (moved == null) error(moveError, 0);
print(`Moved ${moved}`);
local moved, moveErr = digitizer.rematerialize("item", id, 64, chestName)
if not moved then error(moveErr, 0) end
print("Moved " .. moved)
Omitting destination rematerializes items into self. Omitting limit
requests all stored content. Success reports the amount actually inserted.
Destinations that accept no content return nil, error without consuming the
ID; a peripheral with the wrong storage API throws instead.
Peripheral methods¶
The reference below is generated from the published TypeScript interface.
digitize("item", source, filter, limit, destination)¶
Digitizes items from the internal inventory or an attached item storage.
| Parameter | Type | Description |
|---|---|---|
mode |
"item" |
The item storage mode. |
source? |
string \| null \| undefined |
Peripheral name to extract from, or self. Defaults to self. |
filter? |
string \| number \| LuaTable<AnyNotNil, any> \| null \| undefined |
One-based slot, item name, or item query table. Defaults to any item. |
limit? |
number \| null \| undefined |
Optional amount from 1 through half of itemStackLimit. |
destination? |
string \| null \| undefined |
Existing item identifier to merge into; omit to create a new identifier. |
Returns: On success, [id, null]; for an operational failure, [null, message].
Throws: A Lua error for an invalid mode, filter, limit, source, or incompatible storage.
digitize("fluid" | "energy", source, filter, limit, destination)¶
Digitizes fluid or energy from an attached storage peripheral.
| Parameter | Type | Description |
|---|---|---|
mode |
"fluid" \| "energy" |
The fluid or energy storage mode. |
source? |
string \| null \| undefined |
Attached peripheral name. The default self is unsupported for these modes. |
filter? |
string \| null \| undefined |
Fluid name or energy unit; omit to accept the first available content. |
limit? |
number \| null \| undefined |
Optional mB or energy-unit amount from 1 through half of the mode's configured stack limit. |
destination? |
string \| null \| undefined |
Existing same-mode identifier to merge into; omit to create a new identifier. |
Returns: On success, [id, null]; for an operational failure, [null, message].
Throws: A Lua error for an invalid mode, limit, peripheral, storage type, or use of self.
rematerialize(mode, id, limit, destination)¶
Rematerializes items, fluid, or energy into a destination storage.
| Parameter | Type | Description |
|---|---|---|
mode |
"item" \| "fluid" \| "energy" |
Storage mode associated with id. |
id |
string |
Opaque binary identifier. |
limit? |
number \| null \| undefined |
Optional amount from 1 through half of the mode's configured stack limit; defaults to all stored content. |
destination? |
string \| null \| undefined |
Peripheral name to insert into, or self for items. Defaults to self. |
Returns: On success, [amount, null]; for an operational failure, [null, message].
Throws: A Lua error for invalid arguments, inaccessible or incompatible storage, or fluid/energy use of self.
refresh(mode, id)¶
Refreshes an identifier's decay deadline.
| Parameter | Type | Description |
|---|---|---|
mode |
"item" \| "fluid" \| "energy" |
Storage mode associated with id. |
id |
string |
Opaque binary identifier. |
Returns: true when refreshed, or false when the identifier is missing or decayed.
Throws: A Lua error if mode is unsupported.
get("item", id)¶
Reads an item identifier.
| Parameter | Type | Description |
|---|---|---|
mode |
"item" |
The item storage mode. |
id |
string |
Opaque binary item identifier. |
Returns: Current metadata, or null when the identifier is missing, exhausted, or decayed.
Throws: A Lua error if mode is unsupported.
get("fluid", id)¶
Reads a fluid identifier.
| Parameter | Type | Description |
|---|---|---|
mode |
"fluid" |
The fluid storage mode. |
id |
string |
Opaque binary fluid identifier. |
Returns: Current metadata, or null when the identifier is missing, exhausted, or decayed.
Throws: A Lua error if mode is unsupported.
get("energy", id)¶
Reads an energy identifier.
| Parameter | Type | Description |
|---|---|---|
mode |
"energy" |
The energy storage mode. |
id |
string |
Opaque binary energy identifier. |
Returns: Current metadata, or null when the identifier is missing, exhausted, or decayed.
Throws: A Lua error if mode is unsupported.
pushItems(toName, fromSlot, limit, toSlot)¶
Inherited from InventoryAPI.
| Parameter | Type | Description |
|---|---|---|
toName |
string |
|
fromSlot |
number |
|
limit? |
number \| undefined |
|
toSlot? |
number \| undefined |
pullItems(fromName, fromSlot, limit, toSlot)¶
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(slot)¶
Inherited from InventoryViewAPI.
| Parameter | Type | Description |
|---|---|---|
slot |
number |
getItemLimit(slot)¶
Inherited from InventoryViewAPI.
| Parameter | Type | Description |
|---|---|---|
slot |
number |
getConfiguration()¶
Inherited from ConfigurationAPI.