コモンイベントを名前で呼び出すプラグイン

フォーラムルール
素材の利用規約を決めたいけど、どんなことを書けばいいのか分からない場合は、
素材のテンプレートをご利用下さい。
おのき
記事: 14
登録日時: 2017年8月28日(月) 18:07
連絡を取る:

コモンイベントを名前で呼び出すプラグイン

投稿記事by おのき » 2017年9月18日(月) 17:28

お邪魔します。
制作中の副産物ですが公開しておきます。
すでにあるかもしれないですね。

コード: 全て選択

/*:
@plugindesc コモンイベントを名前で呼び出します。
@author おのき

@help コモン番号の末尾から検索するので同名があれば後ろ優先で呼び出します。
一度呼び出すことでハッシュに登録して検索の手間を省いています。

プラグインコマンドから実行してください。
callのあとに半角スペースを入れてコモンイベント名を続けてください。
call コモンイベント名

間違いがあればご指摘ください。
可能であれば対応させていただきます。
*/
(function() {
  'use strict';// 厳格モード

  var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  Game_Interpreter.prototype.pluginCommand = function(command, args) {
    _Game_Interpreter_pluginCommand.apply(this, arguments);
    if (command === 'call' && args.length > 0) {
      this._commonEventsHash = new Object();
      if (!(args[0] in this._commonEventsHash)) {
        for (var i = $dataCommonEvents.length - 1; i > 0; --i) {
          if ($dataCommonEvents[i].name === args[0]) {
            this._commonEventsHash[args[0]] = i;
            break;
          } else if (i === 1) {
            throw new Error('The pluginCommand \"' + command + ' ' + args + '\" is invalid');
          }
        }
      }
      var event = $dataCommonEvents[this._commonEventsHash[args[0]]];
      var eventId = this.isOnCurrentMap() ? this._eventId : 0;
      this.setupChild(event.list, eventId);
    }
  };

})();
添付ファイル
CallCommonByName.js
(1.54 KiB) ダウンロード数: 38 回

“MV:プラグイン素材” へ戻る