Violet

Cash Shop

On this page

Use core.cash_shop to inspect the Cash Shop and transfer eligible cash items through the locker.

Cash Shop state required

Locker reads return nil when the locker is unavailable. Transfer actions return false when the Cash Shop is closed, the locker is busy, or the selected item is not eligible.

on_tick(stage) continues running while the Cash Shop is open. Use core.stage.CASH_SHOP to run Cash Shop-specific logic without also running it in other stages.

A true action result means the request was submitted, not completed. Wait for state to update before relying on the result.

Malformed transfer arguments raise a Lua error. Deposits also reject stale or non-cash inventory records. Pass records returned by Violet rather than constructing them manually.

Locker Item Structure

core.cash_shop.locker.get_items() returns locker item records:

PropertyTypeDescription
cash_snnumberOpaque locker identifier carried by the item record
idnumberItem ID
tab_idnumberDestination inventory category
namestring?Display name when available
locationstringCurrent location; "locker" for these records
is_in_lockerbooleantrue for a current locker record
is_in_inventorybooleanfalse for a current locker record
owner_account_idnumber?Account that owns the current locker item

Pass the complete record back to withdraw_regular(); do not construct locker records manually.

Functions

core.cash_shop.is_open() -> boolean

Returns whether the Cash Shop is currently open and supported.


core.cash_shop.enter() -> boolean

Requests entry into the Cash Shop. Returns false outside a supported field state or when it is already open.


core.cash_shop.leave() -> boolean

Requests departure from the Cash Shop. Returns false when it is closed or the locker is busy.


core.cash_shop.locker.is_busy() -> boolean

Returns whether the locker is waiting for an earlier transfer to finish.


core.cash_shop.locker.get_items() -> table<locker_item> | nil

Returns the items currently visible in the locker.


core.cash_shop.locker.withdraw_regular(item: locker_item, destination_slot: number) -> boolean

Withdraws an eligible locker item into destination_slot. Pass an item returned by get_items().


core.cash_shop.locker.deposit(inventory_item: table) -> boolean

Deposits an eligible cash item from the character inventory into the locker. It accepts two call forms.

Call formParameters
deposit(inventory_item)A cash item record from core.inventory.get_cash_items(). It must contain id (item ID), tab_id (the cash inventory type, 5 or 6) and position (1-based slot).
deposit(cash_sn, item_id, inventory_type, source_slot)Four positive integers. inventory_type must be 5 or 6. cash_sn is re-checked against the serial currently in source_slot and the call fails if it no longer matches.

Both forms validate the record against live inventory, so a stale record is rejected rather than acted on. Malformed arguments raise a Lua error instead of returning false; a false return means the Cash Shop was closed, the locker was busy, or the item was not eligible.

lua
function on_tick(stage)
    if stage ~= core.stage.CASH_SHOP then return end

    local locker = core.cash_shop.locker
    local items = locker.get_items()
    if items and items[1] and not locker.is_busy() then
        locker.withdraw_regular(items[1], 1)
    end
end