Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*:ja
- * @plugindesc サンプル
- * @author
- *
- * @param 呼び出すイベント名
- * @desc 呼び出されるイベントの名称
- * @default Called_Event
- *
- * @help
- * パラメータで指定した名称のイベントをプラグインコマンドから呼び出します。
- *
- * パラメータで指定した名称のイベントのページ[1]を呼び出します。
- * Call_Event_from_this_map 1
- *
- */
- (function() {
- 'use strict';
- // プラグインパラメータを取ります。
- var parameter = PluginManager.parameters('Call_to_each_map');
- var eventName = String(parameter['呼び出すイベント名']) || 'Called_Event';
- // プラグインコマンドの実行
- var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
- Game_Interpreter.prototype.pluginCommand = function(command, args) {
- _Game_Interpreter_pluginCommand.apply(this, arguments);
- if (command === 'Call_Event_from_this_map') {
- var pageIndex = parseInt(args[0]);
- console.log(eventName);
- this.callMapEventByName(pageIndex, eventName);
- }
- };
- // 指定された名前に一致するイベントの呼び出し
- Game_Interpreter.prototype.callMapEventByName = function(pageIndex, eventName) {
- var event = DataManager.searchDataItem($dataMap.events, 'name', eventName);
- if (event) {
- this.setupAnotherList(event.id, event.pages, pageIndex);
- }
- };
- // イベント実行内容のセットアップ
- Game_Interpreter.prototype.setupAnotherList = function(eventId, pages, pageIndex) {
- var page = pages[pageIndex - 1 || this._pageIndex] || pages[0];
- if (!eventId) eventId = this.isOnCurrentMap() ? this._eventId : 0;
- this.setupChild(page.list, eventId);
- };
- // データベースから条件に一致するデータを検索
- DataManager.searchDataItem = function(dataArray, columnName, columnValue) {
- var result = 0;
- dataArray.some(function(dataItem) {
- if (dataItem && dataItem[columnName] === columnValue) {
- result = dataItem;
- return true;
- }
- return false;
- });
- return result;
- };
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement