2 Digitizer
Blake Rain edited this page 2024-01-29 14:42:01 +00:00

The Digitizer is a block that works with CC:Tweaked to convert a stack of items into a UUID, for a fairly hefty amount of FE. The items can then be materialized from the UUID using a Digitizer for the same amount of FE. Items do not need to be digitized or materialized by the same block. Items can stay in their digitized state for five Minecraft days: a Minecraft day IRL is 20 minutes, so items will last for 1 hour and 40 minutes. Items that are digitized can be "refreshed" to reset their expiry at a small cost in FE.

Crafting

The Digitizer block can be crafted from the following ingredients:

Ingredient Count ID
[Paper] 1 minecraft:paper
[Tungesten Ingot] 4 utamacraft:tungsten_ingot
[Redstone] 1 minecraft:redstone
[PCB] 1 utamacraft:pcb

Usage

The digitizer receives and stores FE, has a single inventory slot, and provides a CC:Tweaked peripheral. An example setup might a digitizer attached to a power source, some storage transport, and a computer.

Interface

The digitizer interface is extremely simple, as all of its tasks are intended to be driven via the peripheral interface. A later version may include additional functionality.

The following UI items are labelled:

  1. The current level of FE stored in the digitizer.
  2. The single inventory slot of the digitizer.

Energy Usage

Energy can be provided via any side of the digitizer block. The block energy storage and charge rates are defined as a function of the per-item digitization/materialization cost as follows:

Description Value
Digitization energy required 1024 FE
Refresh energy required 64 FE
Maximum energy stored Digitization energy * 64 = 65,536 FE
Energy draw rate Maximum stored / (20 * 10) = ~327 FE

The block will recharge at a rate of ~327 FE/t, reaching its maximum stored charge of 65,6536 FE after ten seconds (200 ticks). Digitizing/materializing a full 64 stack of items will completely deplete the digitizer.

The cost of digitizing or materializing an item does not change based on the item type, nor on the size of any tags attached to the item. For example, digitizing a [Shulker Box] full of [Obsidian] will cost the same amount in FE as digitizing a [Potato].

Peripheral Interface

The peripheral interface provided by the digitizer has the following methods:

Method Description
getEnergy(): number Return the current stored energy level
getEnergyCapacity(): number Return the maximum amount of energy that can be stored
size(): number Return the size of the inventory (currently: 1 slot)
getEnergyRequiredPerItem(): number Return the per-item digitization cost
getItemLimit(slot: number): number Return the maximum number of items stored in the given slot
getItemDetail(slot: number): table Return details about the items in the given slot
digitize(count?: number, simulate?: boolean): table Perform (or simulate) digitization
materialize(uuid: string, simulate?: boolean): table Perform (or simulate) materialization
query(uuid: string): table Get details about a digitized item
refresh(uuid: string): table Refresh a digitized item
list(): table List all currently digitized items

getEnergy

getEnergy(): number

The getEnergy() method returns the current energy level in FE of the digitizer block. As the block receives energy this value will increase until it reaches the maximum (obtained via the getEnergyCapacity() method).

getEnergyCapacity

getEnergyCapacity(): number

The getEnergyCapacity() method returns the maximum amount of FE the digitizer block can store. This is currently computed by taking the digitization cost and multiplying it by 64 (standard maximum stack size), giving a value of 65,536 FE.

getDigitizationCost

getDigitizationCost(): number

This method returns the amount of energy required to digitize or materialize an item. This is a per-item cost in FE, which is multiplied by the size of the stack.

The cost of digitizing or materializing an item does not change based on the item type, nor on the size of any tags attached to the item. For example, digitizing a [Shulker Box] full of [Obsidian] will cost the same amount in FE as digitizing a [Potato].

getRefreshCost

getRefreshCost(): number

This method returns the amount of energy required to refresh a digitized item. This is a per-item cost in FE, which is multiplied by the size of the stack.

The cost of refreshing an item does not change based on the item type, nor on the size of any tags attached to the item. For example, digitizing a [Shulker Box] full of [Obsidian] will cost the same amount in FE as refreshing a [Potato].

getItemLimit

getItemLimit(slot: number): number

Returns the number of items that can be stored in the given slot. The number given in slot should be the 1-indexed slot. As the digitizer only has a single slot, the slot argument should always be 1.

This function is useful when items are already in the digitizer's inventory slot, and you wish to know the maximum number the items can stack to.

Parameters

  1. slot : number the inventory slot to inspect.

Returns

  1. number giving the maximum number of items that can be held in the given slot.

Throws

  • If the inventory slot given in slot parameter is out of range.

getItemDetail

getItemDetail(slot: number): table

This function returns details about the item in the given inventory slot. The number given in slot should be the 1-indexed slot number. As the digitizer only has a single slot, the slot argument should always be 1.

This function returns a table that contains details about the contents of the slot, or nil if there is nothing currently in the slot. Below is an example of the return table:

{
    displayName = "Redstone",
    name = "minecraft:redstone",
    count = 15,
    maxCount = 64
}

Parameters

  1. slot : number the inventory slot to inspect.

Returns

  1. table giving details of the item in the given inventory slot.

Or

  1. nil if there are no items in the given inventory slot.

Throws

  • If the inventory slot given in slot parameter is out of range.

digitize

digitize([count: number] [, simulate: boolean]): table

The table returned upon successful digitization (simulated or actual) will contain the following fields:

Field Type Description
simulation boolean Whether the digitization was simulated or not
requested number The number of items requested to be digitized
available number The number of items available in the inventory slot
count number The number of items that were (or would have been) digitized
cost number The cost (in FE) of the digitization
item table or nil The digitized item (if not simulated)

If the digitization was not a simulation, the FE given in cost will be deducted from the digitizer block's stored energy. If the required energy is not present in the digitizer block, this method will return nil.

If the digitization was not a simulation, the returned table will include an item field. This field is the item stack digitization descriptor, and is used by other methods in this peripheral to communicate the state of a digitized item stack. The table has the following fields:

Field Type Description
id string The UUID of this digitized item stack
name string The name of the item that was digitized (e.g. minecraft:redstone)
count number The number of items that were digitized in the stack
maxCount number The maximum number of items that can be held in the stack
createdAt number The time at which the digitized item stack was digitized
expiresAt number The time at which the digitized item stack will expire
age number The age of the digitized item stack (in ticks)
isExpired boolean Indication whether the digitized item stack has expired
remainingTime number The remaining ticks until expiration

Parameters

  1. count : number optionally giving the number of items that should be digitized from the inventory. The actual number of items digitized will be either is value or the number of items in the inventory slot, whichever is smallest. If this parameter is not specified or is nil, the entire stack will be digitized.
  2. simulate : boolean optionally giving a boolean indicating whether to simulate the digitization. Simulation will mean that the item stack is not digitized and energy will not be used. This is useful to ascertain the cost of the digitization.

Returns

  1. table giving details of the digitization process and the digitized item stack descriptor.

Or

  1. nil indicating digitization was not completed,
  2. string giving an error message.

Throws

  • If the first parameter is not nil or a number
  • If the second parameter is not nil or a boolean

Cost

The cost of digitizing the item stack is the number of items that were digitized multiplied by the per-item digitization cost. Currently the item digitization cost is 1024 FE. The number of items that were digitized is given in the count field of the returned table, and the total cost of digitization is given, in FE, in the cost field.

materialize

materialize(uuid: string, simulate?: boolean): table

Converts a digitized item stack back into an item stack and places the item stack into the inventory slot of the digitizer block. Once successful, the items that were materialized are placed into the digitizer block's inventory slot and a Lua table is returned detailing the materialization process.

The returned table contains the following fields:

Field Type Description
simulation boolean Whether the materialization was simulated or not
requested number The number of items requsted
available number The number of items available in the digitized item stack
remainder number The number of items remaining digitized
materialized number The number of items that were actually materialized
materializeCost number The cost (in FE) of the materialization
refreshCost number The cost (in FE) of the digitized item stack refresh
cost number The total cost of this operation
item table The digitized item stack descriptor

Partial Materialization

If the items to be materialized cannot be added to the item stack already present in the digitizer block's inventory slot, a partial materialization will take place. In a partial materialization, as many items as can be materialized from the digitized item stack are placed into the digitizer block's inventory. Any remaining items remain in the digitized item stack and the lifetime is extended.

For example, if a stack of 32 blocks of iron were already present in the digitizer block's inventory, attempting to materialize a stack of 64 iron blocks will result in only 32 iron blocks being materialized. The remaining 32 unmaterialized iron blocks will remain in the digitized item, and the item will be refreshed.

The cost of partial materialization is the cost of materialization times the number of items that were materialized, plus the remaining items times the cost of refresh.

Parameters

  1. uuid : string the UUID of the digitized item stack to materialize.
  2. count : number optionally giving the number of items that should be materialized. The actual number of items materialized will be either this value, the number of items in the digitized item stack, or the number of items that can be placed into the inventory slot of the digitizer block; whichever is smallest. If this parameter is not specified or is nil, the method will attempt to materialize the entire digitized item stack.
  3. simulate : boolean optionally giving a boolean indicating whether to simulate the digitization. Simulation will mean that the item stack is not digitized and energy will not be used. This is useful to ascertain the cost of the digitization.

Returns

  1. table containing details of the materialization.

Or

  1. nil indicating materialization could not be completed,
  2. a string describing the error.

Throws

  • If the first parameter is not a string and a valid UUID.
  • If the second parameter is not nil or a number.
  • If the third parameter is not nil or a boolean.

Cost

Materialization costs the same per-item energy as digitization. The full cost of materialization is given by the number of items materialized multiplied by the per-item digitization cost. Currently the item digitization cost is 1024 FE.

Materialization includes an additional cost, in FE, for any item refresh required due to partial materialization. In this case, the refresh cost (currently 64 FE) is multiplied by the number of items that remained digitized.

Cost = Materialized Items * 1024 + Refreshed Items * 64

The full cost is described by the cost, materializedCost and refreshCost fields of the returned table.

query

query(uuid: string): table

This method will query the digitized item stack for the given UUID and, so long as the items exist and have not already expired, will return a Lua table containing the digitized item descriptor (as returned from the digitize() method).

Parameters

  1. uuid : string the UUID that uniquely identifies the digitized item stack. If this is not a valid UUID string, this method will raise an exception.

Returns

  1. table giving the digitized item stack descriptor as returned from the digitize() method.

Or

  1. nil if there was an error
  2. string giving the error that arose

Throws

  • If the string specified in the first parameter is not a valid UUID.

Cost

There is no cost to querying an item

refresh

refresh(uuid: string [, simulate: boolean]): table

This method will refresh the given items, so long as the item exists and has not already expired.

When completed successfully, this method will return a Lua table containing the digitized item descriptor, as returned from the digitize() method. This will include the updated expiresAt time.

On successful refresh, the table returned will have the following fields:

Field Type Description
simulation boolean Whether the refresh was a simulation
cost number The computed cost (in FE) of the refresh
item table The digitized item descriptor

If the refresh was successful and was not a simulation, the expiresAt field of the returned item will show the new expiration time.

Parameters

  1. uuid : string the UUID that uniquely identifies the digitized item stack. If this is not a valid UUID string, this method will raise an exception.
  2. Optional simulate : boolean which, when true, will cause the refresh to be simulated rather than performed. This can be useful to ascertain the cost of the refresh without actually performing the refresh.

Returns

  1. table giving information about the refresh process, if successful.

Or

  1. nil if the digitized item stack with the given UUID does not exist or has expired.
  2. string an error message describing the problem.

Throws

  • If the string specified in the first parameter is not a valid UUID.
  • If the value given in the second parameter is not nil or a boolean.

Cost

The cost of refreshing the digitized item stack is computed by taking the per-item refresh cost and multiplying it by the number of items in the stack.

The cost of refreshing an item does not change based on the item type, nor on the size of any tags attached to the item. For example, digitizing a [Shulker Box] full of [Obsidian] will cost the same amount in FE as refreshing a [Potato].

list

list(): table

This method lists all the digitized items that are currently stored in the world. This will return a table where each element of the table is a digitized item descriptor, as returned by the digitize() method.

There is no cost to listing digitized items.