Shop System

Learn how to use and customize the shop UI system with buy/sell functionality.

Overview

The shop system consists of two main components:

  • ShopScreen.tsx - Main shop container and state management

  • ShopTradeList.tsx - Item list with quantity controls

Shop Screen Structure

┌─────────────────────────────────────┐
│  Shop Screen                        │
├───────┬─────────────────────────────┤
│ Buy   │ Item List                   │
│>Sell  │ ┌─────────────────────────┐ │
│ Leave │ │ Potion    Have:5  Qty:1 │ │
│       │ │ Hi-Potion Have:2  Qty:1 │ │
│       │ └─────────────────────────┘ │
│ Gold  │ Description: Restores HP    │
│ 1000G │ Stats: (equip changes)      │
└───────┴─────────────────────────────┘

Basic Usage

Opening a Shop

From RMMZ events, the shop command automatically triggers ShopScreen:

Component Structure

Buy/Sell Mode Switching

The shop shows different item lists based on mode:

Important: Use useMemo to prevent recreating the array every render, which would break Chooser selection.

Quantity Management

Quantities are tracked per-item using a keyed state object:

Sell Confirmation

When selling, show a confirmation dialog:

Equipment Stats Preview

For weapons/armor, show stat changes:

Price Calculation

Disabling Options

Disable Continue when no save files:

Customization Examples

Custom Shop Theme

Adding Shop Keeper Dialog

Discounts/Sales

Common Issues

Selection doesn't work in sell mode

Cause: sellItems array recreated every render

Fix: Wrap in useMemo:

Quantity resets when switching items

Cause: Quantity state not persisted per-item

Fix: Use keyed quantities object as shown above

Equipment preview shows wrong stats

Cause: Modifying live actor instead of copy

Fix: Create actor copy first:

See Also

Last updated