add_event_command
Insert commands into RPG Maker MZ event pages to control game actions like displaying text, transferring players, or managing variables.
Instructions
Add a command to an event page (e.g., show text, transfer player, etc.)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Command code (e.g., 101=Show Text, 201=Transfer Player, 122=Control Variables) | |
| event_id | Yes | Event ID | |
| map_id | Yes | Map ID | |
| page_index | Yes | Page index (0-based) | |
| parameters | Yes | Command parameters | |
| project_path | Yes | Path to the RPG Maker MZ project directory |
Implementation Reference
- src/game-creation-tools.ts:212-238 (handler)Core handler function that loads the map JSON, finds the event page, inserts the new command before the end command (code 0), and saves the map file.export async function addEventCommand( projectPath: string, mapId: number, eventId: number, pageIndex: number, command: { code: number; indent: number; parameters: any[] } ) { const mapFilename = `Map${String(mapId).padStart(3, "0")}.json`; const mapPath = path.join(projectPath, "data", mapFilename); const mapContent = await fs.readFile(mapPath, "utf-8"); const map = JSON.parse(mapContent); if (!map.events[eventId]) { throw new Error(`Event ${eventId} not found`); } const page = map.events[eventId].pages[pageIndex]; if (!page) { throw new Error(`Page ${pageIndex} not found`); } // Insert before the end command (code 0) page.list.splice(page.list.length - 1, 0, command); await fs.writeFile(mapPath, JSON.stringify(map, null, 0), "utf-8"); return { success: true }; }
- src/index.ts:324-357 (registration)Tool registration in the ListTools response, defining the tool name, description, and input schema for MCP clients.{ name: "add_event_command", description: "Add a command to an event page (e.g., show text, transfer player, etc.)", inputSchema: { type: "object", properties: { project_path: { type: "string", description: "Path to the RPG Maker MZ project directory", }, map_id: { type: "number", description: "Map ID", }, event_id: { type: "number", description: "Event ID", }, page_index: { type: "number", description: "Page index (0-based)", }, code: { type: "number", description: "Command code (e.g., 101=Show Text, 201=Transfer Player, 122=Control Variables)", }, parameters: { type: "array", description: "Command parameters", }, }, required: ["project_path", "map_id", "event_id", "page_index", "code", "parameters"], }, },
- src/index.ts:1192-1204 (handler)MCP server tool call dispatcher that parses input arguments, constructs the command object (with indent:0), calls the core addEventCommand handler, and returns the result as text content.case "add_event_command": { const projectPath = args.project_path as string; const mapId = args.map_id as number; const eventId = args.event_id as number; const pageIndex = args.page_index as number; const code = args.code as number; const parameters = args.parameters as any[]; const command = { code, indent: 0, parameters }; const result = await addEventCommand(projectPath, mapId, eventId, pageIndex, command); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }