/*------------------------------ Copyright (c) 2025 PotatoDragon Released under the MIT License. https://opensource.org/license/mit ------------------------------*/ /*: @target MZ @url https://raw.githubusercontent.com/pota-gon/RPGMakerMZ/refs/heads/main/plugins/System/Name/NameCommand.js @plugindesc Name Command Ver0.5.1 (2025/1/18) @author PotatoDragon @license MIT License @help English Help Translator: munokura This is an unofficial English translation of the plugin help, created to support global RPG Maker users. Feedback is welcome to improve translation quality (see: https://github.com/munokura/PotatoDragon-MZ-plugins ). Original plugin by PotatoDragon. Please check the latest official version at: https://github.com/pota-gon/RPGMakerMZ/wiki ----- ## Overview Provides plugin commands referenced by name. ## Usage ### Member Swap 1. Call the plugin command. 2. Select the command name "Member Swap." 3. Enter the actor's name in the "Name" parameter. 4. Select "Add" or "Remove" for the "Operation (Add or Remove)" parameter. 5. Select "Initialize when adding a member" for the "Initialize" parameter. @command swap_actor @text Member replacement @desc Swap members by name @arg name @desc Name of the member you want to replace @type string @arg actor @text For actor name search @desc This parameter is not used as data. @type actor @parent name @arg operation @text Operation (add or remove) @desc Member swap operation (add or remove) @type boolean @on Add @off remove @default true @arg init @text Initialization @desc Do you want to initialize the device when a member joins? @type boolean @on Initialize @off Do not initialize @default false @parent operation */ /*:ja @plugindesc 名前コマンド Ver0.5.1(2025/1/18) @url https://raw.githubusercontent.com/pota-gon/RPGMakerMZ/refs/heads/main/plugins/System/Name/NameCommand.js @target MZ @author ポテトードラゴン ・アップデート情報 Ver0.5.1: 名前検索用のパラメータ追加 Ver0.5.0: 開発版を公開 Copyright (c) 2025 ポテトードラゴン Released under the MIT License. https://opensource.org/license/mit @help ## 概要 名前で参照するプラグインコマンドを提供します ## 使い方 ### メンバーの入れ替え 1. プラグインコマンドを呼び出します 2. コマンド名『メンバーの入れ替え』を選択します 3. 引数の『名前』に「アクターの名前」を入力します 4. 引数の『操作(加える OR 外す)』で、「加える」か「外す」を選択します 5. 引数の『初期化』で、「メンバーを加えるときに初期化するか」を選択します @command swap_actor @text メンバーの入れ替え @desc 名前でメンバーの入れ替えをします @arg name @type string @text 名前 @desc 入れ替えたいメンバーの名称 @arg actor @parent name @type actor @text アクター名検索用 @desc このパラメータはデータとしては使用しません @arg operation @type boolean @text 操作(加える OR 外す) @desc メンバーの入れ替えの操作(加える OR 外す) @on 加える @off 外す @default true @arg init @parent operation @type boolean @text 初期化 @desc メンバーの加入時に初期化するか @on 初期化する @off 初期化しない @default false */ (() => { 'use strict'; // ベースプラグインの処理 function Potadra_getPluginName(extension = 'js') { const reg = new RegExp(".+\/(.+)\." + extension); return decodeURIComponent(document.currentScript.src).replace(reg, '$1'); } function Potadra_convertBool(bool) { if (bool === "false" || bool === '' || bool === undefined) { return false; } else { return true; } } function Potadra_search(data, id, column = "name", search_column = "id", val = "", initial = 1) { if (!id) return val; for (let i = initial; i < data.length; i++) { if (!data[i]) continue; if (search_column && data[i][search_column] == id) { val = column ? data[i][column] : data[i]; break; } else if (i == id) { val = data[i]; break; } } return val; } function Potadra_nameSearch(data, name, column = "id", search_column = "name", val = "", initial = 1) { return Potadra_search(data, name, column, search_column, val, initial); } // パラメータ用変数 const plugin_name = Potadra_getPluginName(); // プラグインコマンド(メンバーの入れ替え) PluginManager.registerCommand(plugin_name, 'swap_actor', function(args) { const name = String(args.name); const operation = Potadra_convertBool(args.operation) ? 0 : 1; const init = Potadra_convertBool(args.operation); this.command129([Potadra_nameSearch($dataActors, name), operation, init]); }); })();