ptr_utilities

Create Numismatics — CC:Tweaked API Reference

Version: 1.1.0 (NeoForge 1.21.1 port) Last updated: 2026-08-19


Peripherals

Numismatics exposes 4 peripheral types to CC:Tweaked computers:

Peripheral type stringSource blockDescription
Numismatics_BankTerminalBank TerminalBank account queries and transfers
Numismatics_VendorVendorPrice configuration for vendor blocks
Numismatics_DepositorBrass DepositorPrice configuration for depositors
Numismatics_SalepointSalepointFull salepoint automation (pricing, purchases, transactions)

Bank Terminal (Numismatics_BankTerminal)

A singleton peripheral (BankTerminalPeripheral.INSTANCE). Wrap any Bank Terminal block to access it.

Methods

getAccounts() -> string[]

Returns a list of all bank account UUIDs (players AND blaze bankers) as strings.

  • Threadsafe: yes (not mainThread)
  • Returns: Array of UUID strings
  • Example:
local bank = peripheral.find("Numismatics_BankTerminal")
local accounts = bank.getAccounts()
-- ["550e8400-e29b-41d4-a716-446655440000", "61398f1c-6859-41d3-a62c-6d3ffc1474ef", ...]

getAccountLabel(string accountID) -> string

Returns the display name of the account.

  • For player accounts: returns the player’s name (resolved via Mojang API or local cache). May return the translation key "block.numismatics.bank_terminal" if the name hasn’t resolved yet on the server side.
  • For blaze banker accounts: returns the custom label set by the owner.
  • Throws: "Invalid UUID" if the UUID string is malformed; "Account not found" if no account exists.
  • Example:
local label = bank.getAccountLabel("61398f1c-6859-41d3-a62c-6d3ffc1474ef")
-- "Petroid_"

isPlayerOwned(string accountID) -> boolean

Returns true if the account is a player account (as opposed to a blaze banker account).

  • Throws: "Invalid UUID", "Account not found"
  • Example:
if bank.isPlayerOwned(accountID) then
    print("This is a player account")
end

getBalance(string accountID) -> int

Returns the account balance in spurs (the smallest denomination).

  • Throws: "Invalid UUID", "Account not found"
  • Note: 1 cog = 64 spurs. See Coin denominations below.
  • Example:
local spurs = bank.getBalance(accountID)
local cogs = math.floor(spurs / 64)
local rem  = spurs % 64
print(string.format("%d cogs and %d spurs", cogs, rem))

getSubAccounts(string accountID) -> string[]

Returns a list of sub-account authorization UUIDs for the given account.

  • Requires: getSubAccountsCommand config option to be enabled (false by default).
  • Throws: "Function disabled by config", "Invalid UUID", "Account not found", "No sub accounts"
  • Example:
local subAccounts = bank.getSubAccounts(accountID)
-- ["a1b2c3d4-...", "e5f6g7h8-..."]

getSubAccountLabel(string accountID, string authorizationID) -> string

Returns the label of a specific sub-account.

  • Throws: "Invalid UUID", "Account not found", or a sub-account-specific error.
  • Example:
local label = bank.getSubAccountLabel(accountID, authorizationID)
-- "Daily Spending"

getMaxAvailableWithdrawal(string accountID, string authorizationID) -> int

Returns the maximum amount (in spurs) that can be withdrawn from the sub-account identified by authorizationID.

  • Throws: "Invalid UUID", "Account not found", "Deductor not found"
  • Example:
local max = bank.getMaxAvailableWithdrawal(accountID, authorizationID)
-- 6400 (spurs)

transfer(string fromAccountID, string fromAuthorizationID, string toAccountID, int amount)

Transfers amount spurs from a sub-account to another account. Must run on the main thread (mainThread = true).

  • fromAccountID: The parent bank account UUID (where the sub-account lives)
  • fromAuthorizationID: The sub-account’s authorization UUID (the one stored on an authorized card)
  • toAccountID: The destination account UUID (any account — player or blaze banker)
  • amount: Amount in spurs
  • Throws: "Invalid UUID", "Account not found", "Insufficient funds", or other deduction errors.
  • Important: This requires a sub-account authorization ID. Bank cards alone (which store only the account UUID) cannot use this method — you need an authorized card’s AuthorizationID.
  • Example:
bank.transfer(fromAccountID, fromAuthorizationID, toAccountID, 640)
-- Transfers 10 cogs (640 spurs) from the sub-account to the destination

Vendor (Numismatics_Vendor)

Attached to Vendor blocks. Allows programmatic price configuration.

Methods

setCoinAmount(string coinName, int amount)

Sets the count of a specific coin denomination that makes up the vendor’s price. Main thread only.

  • coinName: One of "spur", "bevel", "sprocket", "cog", "crown", "sun" (case-insensitive).
  • amount: How many of that coin (0–128).
  • Throws: "incorrect coin name" if the name doesn’t match any coin.
  • Example:
vendor.setCoinAmount("cog", 2)   -- Price is 2 cogs (128 spurs)
vendor.setCoinAmount("spur", 10) -- Price is 2 cogs and 10 spurs (138 spurs total)

setTotalPrice(int spurAmount)

Sets the total price in spurs. Automatically breaks it down into coin denominations. Main thread only.

  • Example:
vendor.setTotalPrice(138) -- Same as 2 cogs + 10 spurs

getTotalPrice() -> int

Returns the current total price in spurs.

getPrice(string coinName) -> int

Returns how many of the given coin denomination is in the price.

  • Throws: "incorrect coin name"

Brass Depositor (Numismatics_Depositor)

Attached to Brass Depositor blocks. Identical API to Vendor.

Methods

Same as Vendor methods:

  • setCoinAmount(coinName, amount) — main thread
  • setTotalPrice(spurAmount) — main thread
  • getTotalPrice() -> int
  • getPrice(coinName) -> int

Salepoint (Numismatics_Salepoint)

Attached to Salepoint blocks. The most feature-rich peripheral — allows full automation of purchases.

Methods

setCoinAmount(string coinName, int amount)

Sets the per-unit price in terms of a specific coin. Main thread only.

  • Same semantics as Vendor’s setCoinAmount.

setTotalPrice(int spurAmount)

Sets the per-unit total price in spurs. Main thread only.

getTotalPrice() -> int

Returns the per-unit total price in spurs.

getPrice(string coinName) -> int

Returns the count of the given coin in the per-unit price.

getSaleObject() -> table

Returns a table describing what the salepoint is selling (its filter/buffer contents).

  • Throws: "Salepoint is not initialized" if the salepoint has no bound state.
  • Return structure depends on salepoint type:
    • Item: { type = "item", item = "<item id>", count = <n> }
    • Fluid: { type = "fluid", fluid = "<fluid id>", amount = <mB> }
    • Energy: { type = "energy", amount = <FE> }
  • Example:
local obj = salepoint.getSaleObject()
-- { type = "item", item = "minecraft:dirt", count = 1 }

getTransaction() -> table

Returns details about the currently active transaction. Main thread only.

  • Throws: "No transaction is currently active"
  • Return structure:
{
    object = { ... },      -- same as getSaleObject()
    unitPrice = <int>,     -- price per unit in spurs
    targetCount = <int>,    -- how many units to buy
    currentCount = <int>   -- how many units processed so far
}

startTransaction(string accountID, string authorizationID, int count)

Starts a purchase transaction. Main thread only.

  • accountID: The buyer’s bank account UUID.
  • authorizationID: The buyer’s sub-account authorization UUID.
  • count: Number of units to purchase (must be ≥ 1).
  • Throws: "Count must be at least 1", "Invalid UUID", "Account not found", sub-account errors, "Failed to start transaction".
  • Note: Like transfer(), this requires a sub-account authorization ID. Use an authorized card’s AuthorizationID.
  • Example:
salepoint.startTransaction(accountID, authorizationID, 5)
-- Starts buying 5 units

cancelTransaction()

Cancels the currently active transaction. Main thread only.

  • Money already deducted is not refunded.
  • Example:
salepoint.cancelTransaction()

Card Item Data (via getItemDetail())

When you call getItemDetail() on a container slot holding a Numismatics card, the returned table includes a numismatics key with card-specific data.

Bank Card (numismatics:<color>_card)

{
    name = "numismatics:red_card",
    count = 1,
    -- ... vanilla fields ...
    numismatics = {
        card = {
            AccountID = "550e8400-e29b-41d4-a716-446655440000"
        }
    }
}
  • AccountID: The bank account UUID this card is bound to. For player accounts, this is the player’s UUID.

Authorized Card (numismatics:<color>_authorized_card)

{
    name = "numismatics:red_authorized_card",
    count = 1,
    -- ... vanilla fields ...
    numismatics = {
        card = {
            AccountID = "550e8400-e29b-41d4-a716-446655440000",
            AuthorizationID = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
        }
    }
}
  • AccountID: The parent bank account UUID.
  • AuthorizationID: The sub-account’s authorization UUID. Use this for transfer() and startTransaction().

ID Card (numismatics:<color>_id_card)

{
    name = "numismatics:red_id_card",
    count = 1,
    -- ... vanilla fields ...
    numismatics = {
        card = {
            ID = "550e8400-e29b-41d4-a716-446655440000"
        }
    }
}
  • ID: The player’s UUID. Used for trust list management, not for banking.

Unbound cards

If a card is blank (not bound), the numismatics key is simply absent from the detail table.


Coin Denominations

CoinName (for API)Value (spurs)
Spurspur1
Bevelbevel8
Sprocketsprocket16
Cogcog64
Crowncrown512
Sunsun4096

Important Notes

Sub-Accounts and Authorization IDs

  • The transfer() and startTransaction() methods require an authorization ID (a sub-account UUID).
  • Bank cards only store an account ID — they don’t have an authorization ID.
  • Only authorized cards have both AccountID and AuthorizationID.
  • To use transfer() or startTransaction() with a bank card, you’d need to add a server-side method that creates a one-time authorization (like the vendor/salepoint purchase flow does).

Name Resolution

  • getAccountLabel() may return "block.numismatics.bank_terminal" for player accounts on the server side, because the name lookup is async and may not have completed.
  • For reliable name resolution, use the Mojang session API: https://sessionserver.mojang.com/session/minecraft/profile/<uuid-without-dashes> — returns JSON with a name field.
  • This only works for online-mode servers. Offline-mode servers generate UUIDs that Mojang doesn’t know about.

Thread Safety

  • Methods marked main thread only (mainThread = true) must not be called from CC:Tweaked coroutines that yield. They run synchronously on the server thread.
  • These methods: transfer(), setCoinAmount(), setTotalPrice(), getTransaction(), startTransaction(), cancelTransaction().

Config Dependency

  • getSubAccounts() and getSubAccountLabel() require the getSubAccountsCommand config option to be true (it defaults to false).