设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2584|回复: 9
打印 上一主题 下一主题

[已经解决] 无耻的过来讨教一个、关于选项的问题。。。。

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
15 小时
注册时间
2016-6-14
帖子
8
跳转到指定楼层
1
发表于 2016-10-7 22:54:35 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
目前想做一个选项窗口。这个窗口里面的选项使用条件来控制出不出现。
比方说一个选项,满足#1变量大于10,并且A开关为关,它就在窗口里面显示并可以被选择。
本来是想用事件里自带的流程控制来做。。。然后发现好像太复杂,光凭事件做不了??

好吧其实之前是想用商店控制库存来替代的,完了发现似乎不太合适就想直接用选项来试试了。

Lv2.观梦者

梦石
0
星屑
311
在线时间
204 小时
注册时间
2007-2-4
帖子
1817
2
发表于 2016-10-7 23:18:28 | 只看该作者
本帖最后由 玄天 于 2016-10-7 23:22 编辑

用这个吧,具体用法看注释

◆条件によって、項目を表示させない

    選択肢の文章中に if(条件) と書くことで、その条件が偽になると項目が表示されなくなります。
    s でスイッチを参照できます。
    (例: if(s[3]) でスイッチ番号 3 が ON のとき項目が表示されます
    v で変数を参照できます。
    (例 : if(v[5] >= 4) で変数番号 5 が 4 以上のとき項目が表示されます
    この機能により『デフォルト』や『キャンセル』の項目が表示されない場合、なしや禁止と同じ処理をします。


JAVASCRIPT 代码复制下载
  1. //=============================================================================
  2. // MPP_ChoiceEX.js
  3. //=============================================================================
  4. // Copyright (c) 2016 Mokusei Penguin
  5. // Released under the MIT license
  6. // [url]http://opensource.org/licenses/mit-license.php[/url]
  7. //=============================================================================
  8.  
  9. /*:
  10.  * @plugindesc 【ver.3.3】選択肢の機能拡張
  11.  * @author 木星ペンギン
  12.  *
  13.  * @help
  14.  * プラグインコマンド:
  15.  *   ChoicePos x y row      # 選択肢の位置(x,y)と行数(row)指定
  16.  *                            rowが未設定の場合、すべての選択肢を表示する
  17.  *   ChoiceVariableId n     # 選択肢のデフォルト位置を変数n番にする
  18.  *                            選択中の位置を変数n番にいれる
  19.  *
  20.  * 注釈:
  21.  *   選択肢ヘルプ             # 各項目の下に設定することで、ヘルプメッセージを表示させる
  22.  *
  23.  * ●選択肢を増やす
  24.  *  イベントコマンド『選択肢の表示』を続けて配置すると
  25.  *  一つの選択肢にまとめられます。
  26.  *  まとめたくない場合は、間に注釈などを入れることで通常通り分けることができます。
  27.  *
  28.  *  『デフォルト』の処理は、なし以外を設定したものが適用されます。
  29.  *  『デフォルト』の処理が複数ある場合、
  30.  *  後に設定された選択肢のものが適用されます。
  31.  *
  32.  *  『キャンセル』の処理は、禁止以外を設定したものが適用されます。
  33.  *  『キャンセル』の処理が複数ある場合、
  34.  *  後に設定された選択肢のものが適用されます。
  35.  *
  36.  * 『背景』と『ウィンドウ位置』は後の選択肢のものが適用されます。
  37.  *
  38.  *
  39.  * ●項目が表示される条件の設定
  40.  *  選択肢の文章中に
  41.  *    if(条件)
  42.  *  と入れ、その条件が偽になると項目が表示されなくなります。
  43.  *
  44.  *  条件内では s でスイッチ、v で変数を参照できます。
  45.  *  (例:if(s[1]) とした場合、スイッチ1番がONで表示、OFFで非表示となります)
  46.  *
  47.  *  『デフォルト』や『キャンセル』の項目が表示されない場合、
  48.  *  なしや禁止と同じ処理をします。
  49.  *
  50.  *
  51.  * ●項目を半透明で表示する条件の設定
  52.  *  選択肢の文章中に
  53.  *    en(条件)
  54.  *  と入れ、その条件が偽になると項目が半透明で表示されます。
  55.  *  半透明となった項目は選択できなくなります。
  56.  *
  57.  *  条件は上の『項目が表示される条件の設定』と同じです。
  58.  *
  59.  *  『キャンセル』の項目が半透明の場合、ブザーが鳴ります。
  60.  *
  61.  *
  62.  * ●選択肢のカーソル位置指定と保存
  63.  *  イベントコマンドの【プラグインコマンド】にて以下のように入力すると
  64.  *  次に表示する選択肢のデフォルト位置を変数の値にして、
  65.  *  決定またはキャンセル時にカーソル位置をその変数に入れます。
  66.  *
  67.  *   ChoiceVariableId n
  68.  *     n : 変数番号
  69.  *
  70.  * カーソル位置は最初の選択肢が上から0~5、次の選択肢は10~15と、
  71.  * 選択肢毎に+10されます。
  72.  *
  73.  * 変数に入った値の項目がない場合、なしと同じ処理をします。
  74.  *
  75.  *
  76.  * ●プラグインコマンドの実行タイミング
  77.  *  上記のプラグインコマンドを使用する場合、【選択肢の表示】の前に実行するのが
  78.  *  好ましいです。
  79.  *  ただし、メッセージウィンドウを表示したまま選択肢の処理を実行したい場合、
  80.  *  【文章の表示】より前にプラグインコマンドを実行してください。
  81.  *
  82.  * ●ヘルプメッセージの表示
  83.  *  各選択肢項目の下に注釈で以下の文字列を入れると、
  84.  *  続きの文章をヘルプメッセージとしてカーソルを合わせたときに標示させることができます。
  85.  *  
  86.  *    選択肢ヘルプ
  87.  *
  88.  *  ※注意点
  89.  *   ヘルプメッセージは[文章の表示]と同じ機能を使っているため、制御文字が使用できます。
  90.  *   ただし、\!と\^は使用できません。
  91.  *  
  92.  * ================================
  93.  * 制作 : 木星ペンギン
  94.  * URL : [url]http://woodpenguin.blog.fc2.com/[/url]
  95.  *
  96.  * @param maxPageRow
  97.  * @desc 1ページに表示される行数
  98.  * @default 6
  99.  *
  100.  */
  101.  
  102. (function() {
  103.  
  104. var parameters = PluginManager.parameters('MPP_ChoiceEX');
  105.  
  106. var maxPageRow = Number(parameters['maxPageRow']);
  107.  
  108. var Alias = {};
  109.  
  110. //-----------------------------------------------------------------------------
  111. // Game_Message
  112.  
  113. //332
  114. Alias.GaMe_clear = Game_Message.prototype.clear;
  115. Game_Message.prototype.clear = function() {
  116.     Alias.GaMe_clear.call(this);
  117.     this._choiceEnables = [];
  118.     this._choiceResults = [];
  119.     this._helpTexts = [];
  120.     this._choiceX = -1;
  121.     this._choiceY = -1;
  122.     this._choiceMaxRow = maxPageRow;
  123.     this._choiceVariableId = 0;
  124. };
  125.  
  126. Game_Message.prototype.setChoiceEnables = function(enables) {
  127.     this._choiceEnables = enables;
  128. };
  129.  
  130. Game_Message.prototype.choiceEnables = function() {
  131.     return this._choiceEnables;
  132. };
  133.  
  134. Game_Message.prototype.setChoiceResults = function(results) {
  135.     this._choiceResults = results;
  136. };
  137.  
  138. Game_Message.prototype.setChoiceHelpTexts = function(texts) {
  139.     this._helpTexts = texts;
  140. };
  141.  
  142. Game_Message.prototype.isHelp = function() {
  143.     return this._helpTexts.length > 0;
  144. };
  145.  
  146. Game_Message.prototype.setChoicePos = function(x, y, row) {
  147.     this._choiceX = x;
  148.     this._choiceY = y;
  149.     this._choiceMaxRow = row;
  150. };
  151.  
  152. Game_Message.prototype.setChoiceVariableId = function(id) {
  153.     this._choiceVariableId = id;
  154. };
  155.  
  156. //-----------------------------------------------------------------------------
  157. // Game_Interpreter
  158.  
  159. //9062
  160. Game_Interpreter.prototype.setupChoices = function(params) {
  161.     var data = {
  162.         choices: [],
  163.         enables: [],
  164.         results: [],
  165.         helpTexts: [],
  166.         cancelType: -1,
  167.         defaultType: -1,
  168.         positionType: 0,
  169.         background: 0
  170.     };
  171.     data = this.addChoices(params, this._index, data, 0);
  172.     if (data.choices.length > 0) {
  173.         var helpTexts = [];
  174.         if (data.helpTexts.length > 0) {
  175.             helpTexts = data.results.map(function(i) {
  176.                 return data.helpTexts[i];
  177.             });
  178.         }
  179.         var cancelType = -1;
  180.         if (data.cancelType.mod(10) === 8 || data.results.contains(data.cancelType)) {
  181.             data.results.push(data.cancelType);
  182.             cancelType = data.choices.length;
  183.         }
  184.         var defaultType = -1;
  185.         if ($gameMessage._choiceVariableId > 0) {
  186.             var index = $gameVariables.value($gameMessage._choiceVariableId);
  187.             defaultType = data.results.indexOf(index);
  188.         } else {
  189.             defaultType = data.results.indexOf(data.defaultType);
  190.         }
  191.         $gameMessage.setChoices(data.choices, defaultType, cancelType);
  192.         $gameMessage.setChoiceEnables(data.enables);
  193.         $gameMessage.setChoiceResults(data.results);
  194.         $gameMessage.setChoiceHelpTexts(helpTexts);
  195.         $gameMessage.setChoiceBackground(data.background);
  196.         $gameMessage.setChoicePositionType(data.positionType);
  197.         $gameMessage.setChoiceCallback(function(n) {
  198.             this._branch[this._indent] = data.results[n];
  199.         }.bind(this));
  200.     } else {
  201.         this._branch[this._indent] = -1;
  202.     }
  203. };
  204.  
  205. Game_Interpreter.prototype.addChoices = function(params, i, data, d) {
  206.     var regIf = /\s*if\(([^\)]+)\)/;
  207.     var regEn = /\s*en\(([^\)]+)\)/;
  208.     for (var n = 0; n < params[0].length; n++) {
  209.         var str = params[0][n];
  210.         if (regIf.test(str)) {
  211.             str = str.replace(regIf, '');
  212.             if (RegExp.$1 && !this.evalChoice(RegExp.$1)) continue;
  213.         }
  214.         var enable = true;
  215.         if (regEn.test(str)) {
  216.             str = str.replace(regEn, '');
  217.             enable = this.evalChoice(RegExp.$1);
  218.         }
  219.         data.choices.push(str);
  220.         data.enables.push(enable);
  221.         data.results.push(n + d);
  222.     }
  223.     var cancelType = params[1];
  224.     if (cancelType !== -1) {
  225.         data.cancelType = cancelType + d;
  226.     }
  227.     var defaultType = params.length > 2 ? params[2] : 0;
  228.     if (defaultType >= 0) {
  229.         data.defaultType = defaultType + d;
  230.     }
  231.     data.positionType = params.length > 3 ? params[3] : 2;
  232.     data.background = params.length > 4 ? params[4] : 0;
  233.     for (;;) {
  234.         i++;
  235.         if (this._list[i].indent === this._indent) {
  236.             if (this._list[i].code === 402) {
  237.                 this.getHelpText(this._list[i].parameters[0] + d, i + 1, data);
  238.             } else if (this._list[i].code === 404) {
  239.                 break;
  240.             }
  241.         }
  242.     }
  243.     if (this._list[i + 1].code === 102) {
  244.         this.addChoices(this._list[i + 1].parameters, i + 1, data, d + 10);
  245.     }
  246.     return data;
  247. };
  248.  
  249. Game_Interpreter.prototype.getHelpText = function(c, i, data) {
  250.     if (this._list[i].code === 108 && this._list[i].parameters[0] === '選択肢ヘルプ') {
  251.         var texts = [];
  252.         while (this._list[i + 1].code === 408) {
  253.             i++;
  254.             texts.push(this._list[i].parameters[0]);
  255.         }
  256.         data.helpTexts[c] = texts;
  257.     }
  258. };
  259.  
  260. Game_Interpreter.prototype.evalChoice = function(formula) {
  261.     try {
  262.         var s = $gameSwitches._data;
  263.         var v = $gameVariables._data;
  264.         return !!eval(formula);
  265.     } catch (e) {
  266.         alert("条件エラー \n\n " + formula);
  267.         return true;
  268.     }
  269. };
  270.  
  271. //9088
  272. Game_Interpreter.prototype.command403 = function() {
  273.     if (this._branch[this._indent] !== -2) {
  274.         this.skipBranch();
  275.     }
  276.     return true;
  277. };
  278.  
  279. Game_Interpreter.prototype.command404 = function() {
  280.     if (this.nextEventCode() === 102) {
  281.         this._branch[this._indent] -= 10;
  282.         this._index++;
  283.     }
  284.     return true;
  285. };
  286.  
  287. //10449
  288. Alias.GaIn_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  289. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  290.     Alias.GaIn_pluginCommand.call(this, command, args);
  291.     switch (command) {
  292.     case 'ChoicePos':
  293.         var x = Number(args[0]);
  294.         var y = Number(args[1]);
  295.         var row = Number(args[2] || 99);
  296.         $gameMessage.setChoicePos(x, y, row);
  297.         break;
  298.     case 'ChoiceVariableId':
  299.         $gameMessage.setChoiceVariableId(Number(args[0]));
  300.         break;
  301.     }
  302.     return true;
  303. };
  304.  
  305. //-----------------------------------------------------------------------------
  306. // Window_ChoiceList
  307.  
  308. Alias.WiChLi_close = Window_ChoiceList.prototype.close;
  309. Window_ChoiceList.prototype.close = function() {
  310.     if ($gameMessage.isHelp()) this._messageWindow.onShowFast();
  311.     Alias.WiChLi_close.call(this);
  312. };
  313.  
  314. Alias.WiChLi_update = Window_ChoiceList.prototype.update;
  315. Window_ChoiceList.prototype.update = function() {
  316.     var lastIndex = this.index();
  317.     Alias.WiChLi_update.call(this);
  318.     var variableId = $gameMessage._choiceVariableId;
  319.     if (lastIndex !== this.index() && variableId > 0) {
  320.         var results = $gameMessage._choiceResults;
  321.         $gameVariables.setValue(variableId, results[this.index()]);
  322.     }
  323. };
  324.  
  325. //34
  326. Alias.WiChLi_updatePlacement = Window_ChoiceList.prototype.updatePlacement;
  327. Window_ChoiceList.prototype.updatePlacement = function() {
  328.     Alias.WiChLi_updatePlacement.call(this);
  329.     if ($gameMessage._choiceX >= 0 && $gameMessage._choiceY >= 0) {
  330.         this.x = Math.min($gameMessage._choiceX, Graphics.boxWidth - this.width);
  331.         this.y = Math.min($gameMessage._choiceY, Graphics.boxHeight - this.height);
  332.     }
  333. };
  334.  
  335. //67
  336. Window_ChoiceList.prototype.numVisibleRows = function() {
  337.     return Math.min($gameMessage.choices().length, $gameMessage._choiceMaxRow);
  338. };
  339.  
  340. //103
  341. Window_ChoiceList.prototype.makeCommandList = function() {
  342.     var choices = $gameMessage.choices();
  343.     var enables = $gameMessage._choiceEnables;
  344.     for (var i = 0; i < choices.length; i++) {
  345.         this.addCommand(choices[i], 'choice', enables[i]);
  346.     }
  347. };
  348.  
  349. //110
  350. Alias.WiChLi_drawItem = Window_ChoiceList.prototype.drawItem;
  351. Window_ChoiceList.prototype.drawItem = function(index) {
  352.     this.changePaintOpacity(this.isCommandEnabled(index));
  353.     Alias.WiChLi_drawItem.call(this, index);
  354. };
  355.  
  356. //123
  357. Alias.WiChLi_callOkHandler = Window_ChoiceList.prototype.callOkHandler;
  358. Window_ChoiceList.prototype.callOkHandler = function() {
  359.     Alias.WiChLi_callOkHandler.call(this);
  360.     this._messageWindow.forceClear();
  361. };
  362.  
  363. //129
  364. Alias.WiChLi_callCancelHandler = Window_ChoiceList.prototype.callCancelHandler;
  365. Window_ChoiceList.prototype.callCancelHandler = function() {
  366.     Alias.WiChLi_callCancelHandler.call(this);
  367.     this._messageWindow.forceClear();
  368. };
  369.  
  370. Alias.WiChLi_processCancel = Window_ChoiceList.prototype.processCancel;
  371. Window_ChoiceList.prototype.processCancel = function() {
  372.     var type = $gameMessage.choiceCancelType();
  373.     var results = $gameMessage._choiceResults;
  374.     var index = results.indexOf(results[type]);
  375.     if (this.isCancelEnabled() && index !== type && !this.isCommandEnabled(index)) {
  376.         this.playBuzzerSound();
  377.     } else {
  378.         Alias.WiChLi_processCancel.call(this);
  379.     }
  380. };
  381.  
  382. Window_ChoiceList.prototype.callUpdateHelp = function() {
  383.     if (this.active && this._messageWindow && $gameMessage.isHelp()) {
  384.         this.updateHelp();
  385.     }
  386. };
  387.  
  388. Window_ChoiceList.prototype.updateHelp = function() {
  389.     this._messageWindow.forceClear();
  390.     var texts = $gameMessage._helpTexts[this.index()];
  391.     $gameMessage._texts = texts ? texts.clone() : [''];
  392.     this._messageWindow.startMessage();
  393. };
  394.  
  395.  
  396. //-----------------------------------------------------------------------------
  397. // Window_Message
  398.  
  399. //65
  400. //Window_Message.prototype.update = function() {
  401. //    this.checkToNotClose();
  402. //    Window_Base.prototype.update.call(this);
  403. //    while (!this.isOpening() && !this.isClosing()) {
  404. //        if (this.updateWait()) {
  405. //            return;
  406. //        } else if (this.updateLoading()) {
  407. //            return;
  408. //        } else if (!this.pause && this.updateMessage()) {
  409. //            return;
  410. //        } else if (this.updateInput()) {
  411. //            return;
  412. //        } else if (this.canStart()) {
  413. //            this.startMessage();
  414. //        } else {
  415. //            this.startInput();
  416. //            return;
  417. //        }
  418. //    }
  419. //};
  420.  
  421. //148
  422. Alias.WiMe_updateInput = Window_Message.prototype.updateInput;
  423. Window_Message.prototype.updateInput = function() {
  424.     if ($gameMessage.isHelp() && this._textState) {
  425.         return false;
  426.     }
  427.     return Alias.WiMe_updateInput.call(this);
  428. };
  429.  
  430. //206
  431. Alias.WiMe_startInput = Window_Message.prototype.startInput;
  432. Window_Message.prototype.startInput = function() {
  433.     if (this._choiceWindow.active) {
  434.         return true;
  435.     }
  436.     return Alias.WiMe_startInput.call(this);
  437. };
  438.  
  439. Window_Message.prototype.forceClear = function() {
  440.     this._textState = null;
  441.     this.close();
  442.     this._goldWindow.close();
  443. };
  444.  
  445. Window_Message.prototype.onShowFast = function() {
  446.     this._showFast = true;
  447. };
  448.  
  449.  
  450. })();
新しい誕生祝いだッ!
回复 支持 1 反对 0

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
15 小时
注册时间
2016-6-14
帖子
8
3
 楼主| 发表于 2016-10-7 23:43:40 | 只看该作者
玄天 发表于 2016-10-7 23:18
用这个吧,具体用法看注释

嗷谢谢,
我去试试看
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
21932
在线时间
8564 小时
注册时间
2011-12-31
帖子
3362
4
发表于 2016-10-7 23:47:06 | 只看该作者
SupponShopStock.js
* @plugindesc
在庫システム
を有するお店を設定します。version 1.02
* @author Suppon
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
15 小时
注册时间
2016-6-14
帖子
8
5
 楼主| 发表于 2016-10-8 00:04:51 | 只看该作者
tseyik 发表于 2016-10-7 23:47
SupponShopStock.js
* @plugindesc [fold=在庫システム]//============================================ ...

谢谢,我之前用的就是这个插件,不过因为金钱的原因和原本的设计不太一样。
现在问题已经解决啦谢啦~
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
15 小时
注册时间
2016-6-14
帖子
8
6
 楼主| 发表于 2016-10-8 00:22:23 | 只看该作者
玄天 发表于 2016-10-7 23:18
用这个吧,具体用法看注释

那个。。。再请教一下。。
if(s[3])是开关3打开的时候显示,那要想让开关3关闭的时候显示要怎么设置?

点评

試試if(s[3]=0)  发表于 2016-10-8 11:51
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
311
在线时间
204 小时
注册时间
2007-2-4
帖子
1817
7
发表于 2016-10-8 01:06:27 | 只看该作者
一坨鲜花 发表于 2016-10-8 00:22
那个。。。再请教一下。。
if(s[3])是开关3打开的时候显示,那要想让开关3关闭的时候显示要怎么设置? ...

好像并没有这个功能。

如果你实在想要关闭时显示的话,那干脆转个思路用变量来判断的吧。1=ON 2=OFF,这样同样也能做出来。

点评

好吧,看来只能这样了  发表于 2016-10-8 15:27
新しい誕生祝いだッ!
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
301
在线时间
37 小时
注册时间
2019-8-4
帖子
25
8
发表于 2021-2-25 18:14:52 | 只看该作者
本帖最后由 vodgabongd 于 2021-2-26 15:05 编辑
玄天 发表于 2016-10-7 23:18
用这个吧,具体用法看注释


这个插件之前的版本显示帮助有时候失灵,去作者官网下载最新版就好了,官网讲解很详细还有图片。(作者官网要相信科学)
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-29 03:06

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表