Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. /*:ja
  2. * @plugindesc サンプル
  3. * @author
  4. *
  5. * @param 呼び出すイベント名
  6. * @desc 呼び出されるイベントの名称
  7. * @default Called_Event
  8. *
  9. * @help
  10. * パラメータで指定した名称のイベントをプラグインコマンドから呼び出します。
  11. *
  12. * パラメータで指定した名称のイベントのページ[1]を呼び出します。
  13. * Call_Event_from_this_map 1
  14. *
  15. */
  16.  
  17. (function() {
  18. 'use strict';
  19.  
  20. // プラグインパラメータを取ります。
  21. var parameter = PluginManager.parameters('Call_to_each_map');
  22. var eventName = String(parameter['呼び出すイベント名']) || 'Called_Event';
  23.  
  24. // プラグインコマンドの実行
  25. var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  26. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  27. _Game_Interpreter_pluginCommand.apply(this, arguments);
  28. if (command === 'Call_Event_from_this_map') {
  29. var pageIndex = parseInt(args[0]);
  30. console.log(eventName);
  31. this.callMapEventByName(pageIndex, eventName);
  32. }
  33. };
  34.  
  35. // 指定された名前に一致するイベントの呼び出し
  36. Game_Interpreter.prototype.callMapEventByName = function(pageIndex, eventName) {
  37. var event = DataManager.searchDataItem($dataMap.events, 'name', eventName);
  38. if (event) {
  39. this.setupAnotherList(event.id, event.pages, pageIndex);
  40. }
  41. };
  42.  
  43. // イベント実行内容のセットアップ
  44. Game_Interpreter.prototype.setupAnotherList = function(eventId, pages, pageIndex) {
  45. var page = pages[pageIndex - 1 || this._pageIndex] || pages[0];
  46. if (!eventId) eventId = this.isOnCurrentMap() ? this._eventId : 0;
  47. this.setupChild(page.list, eventId);
  48. };
  49.  
  50. // データベースから条件に一致するデータを検索
  51. DataManager.searchDataItem = function(dataArray, columnName, columnValue) {
  52. var result = 0;
  53. dataArray.some(function(dataItem) {
  54. if (dataItem && dataItem[columnName] === columnValue) {
  55. result = dataItem;
  56. return true;
  57. }
  58. return false;
  59. });
  60. return result;
  61. };
  62. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement