Violet

Trade

On this page

Use core.trade to inspect and control the active player-trade dialog.

Trade must be open

Actions return false when no trade is open or the current trade stage does not allow the requested action.

Functions

core.trade.is_open() -> boolean

Returns whether a player-trade dialog is currently open.


core.trade.is_accept_pending() -> boolean

Returns whether an earlier accept action is still pending.


core.trade.get_state() -> number | nil

Returns the current trade-stage identifier, or nil when no trade is open. Treat the value as observational; use the action return values to determine whether an operation is currently allowed.


core.trade.accept() -> boolean

Accepts the current trade when another accept action is not already pending.


core.trade.cancel() -> boolean

Cancels the current trade.


core.trade.add_meso_ui() -> boolean

Opens the trade dialog's Meso-entry action when the current trade stage allows changes.

lua
if core.trade.is_open() and not core.trade.is_accept_pending() then
    local submitted = core.trade.accept()
end