paint_map
Paint tiles on RPG Maker maps using batch operations to create terrain, roads, walls, and decorations efficiently with single read/write cycles.
Instructions
Paint tiles on a map using batch operations (fill rectangles or draw outlines). Efficient for creating terrain, roads, walls, and decorations in one call. Reads/writes map data only once regardless of operation count.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mapId | Yes | The ID of the map to paint | |
| operations | Yes | Array of paint operations. Each paints a rectangular area. |
Implementation Reference
- src/tools/mapTools.ts:350-384 (handler)Implementation of the paintMap function which batch paints tiles on a map.
export async function paintMap( projectPath: string, mapId: number, operations: PaintOperation[] ): Promise<{ painted: number }> { const map = await getMap(projectPath, mapId); let painted = 0; for (const op of operations) { const { x1, y1, x2, y2, layer, tileId } = op; const isOutline = op.type === 'outline'; // Bounds check const cx1 = Math.max(0, Math.min(x1, x2)); const cy1 = Math.max(0, Math.min(y1, y2)); const cx2 = Math.min(map.width - 1, Math.max(x1, x2)); const cy2 = Math.min(map.height - 1, Math.max(y1, y2)); if (layer < 0 || layer > 5) continue; for (let y = cy1; y <= cy2; y++) { for (let x = cx1; x <= cx2; x++) { if (isOutline && x !== cx1 && x !== cx2 && y !== cy1 && y !== cy2) continue; const index = (layer * map.height + y) * map.width + x; map.data[index] = tileId; painted++; } } } const mapPath = getMapPath(projectPath, mapId); await writeJsonFile(mapPath, map); return { painted }; } - src/tools/mapTools.ts:337-345 (schema)Input schema definition for paintMap operations.
export interface PaintOperation { type?: 'fill' | 'outline'; x1: number; y1: number; x2: number; y2: number; layer: number; tileId: number; }