查看: 3311|回复: 9

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

[复制链接]
梦石
0
星屑
50
在线时间
15 小时
注册时间
2016-6-14
回帖
6
发表于 2016-10-7 22:54:35 | 显示全部楼层 |阅读模式

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

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

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

好吧其实之前是想用商店控制库存来替代的,完了发现似乎不太合适就想直接用选项来试试了。
梦石
0
星屑
311
在线时间
204 小时
注册时间
2007-2-4
回帖
1772
发表于 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 以上のとき項目が表示されます)
    この機能により『デフォルト』や『キャンセル』の項目が表示されない場合、なしや禁止と同じ処理をします。


[pre lang="javascript" file="MPP_ChoiceEX.js"]//=============================================================================
// MPP_ChoiceEX.js
//=============================================================================
// Copyright (c) 2016 Mokusei Penguin
// Released under the MIT license
// http://opensource.org/licenses/mit-license.php
//=============================================================================

/*:
* @plugindesc 【ver.3.3】選択肢の機能拡張
* @author 木星ペンギン
*
* @help
* プラグインコマンド:
*   ChoicePos x y row      # 選択肢の位置(x,y)と行数(row)指定
*                            rowが未設定の場合、すべての選択肢を表示する
*   ChoiceVariableId n     # 選択肢のデフォルト位置を変数n番にする
*                            選択中の位置を変数n番にいれる
*
* 注釈:
*   選択肢ヘルプ             # 各項目の下に設定することで、ヘルプメッセージを表示させる
*
* ●選択肢を増やす
*  イベントコマンド『選択肢の表示』を続けて配置すると
*  一つの選択肢にまとめられます。
*  まとめたくない場合は、間に注釈などを入れることで通常通り分けることができます。
*
*  『デフォルト』の処理は、なし以外を設定したものが適用されます。
*  『デフォルト』の処理が複数ある場合、
*  後に設定された選択肢のものが適用されます。
*
*  『キャンセル』の処理は、禁止以外を設定したものが適用されます。
*  『キャンセル』の処理が複数ある場合、
*  後に設定された選択肢のものが適用されます。
*
* 『背景』と『ウィンドウ位置』は後の選択肢のものが適用されます。
*
*
* ●項目が表示される条件の設定
*  選択肢の文章中に
*    if(条件)
*  と入れ、その条件が偽になると項目が表示されなくなります。
*
*  条件内では s でスイッチ、v で変数を参照できます。
*  (例:if(s[1]) とした場合、スイッチ1番がONで表示、OFFで非表示となります)
*
*  『デフォルト』や『キャンセル』の項目が表示されない場合、
*  なしや禁止と同じ処理をします。
*
*
* ●項目を半透明で表示する条件の設定
*  選択肢の文章中に
*    en(条件)
*  と入れ、その条件が偽になると項目が半透明で表示されます。
*  半透明となった項目は選択できなくなります。
*
*  条件は上の『項目が表示される条件の設定』と同じです。
*
*  『キャンセル』の項目が半透明の場合、ブザーが鳴ります。
*
*
* ●選択肢のカーソル位置指定と保存
*  イベントコマンドの【プラグインコマンド】にて以下のように入力すると
*  次に表示する選択肢のデフォルト位置を変数の値にして、
*  決定またはキャンセル時にカーソル位置をその変数に入れます。
*
*   ChoiceVariableId n
*     n : 変数番号
*
* カーソル位置は最初の選択肢が上から0~5、次の選択肢は10~15と、
* 選択肢毎に+10されます。
*
* 変数に入った値の項目がない場合、なしと同じ処理をします。
*
*
* ●プラグインコマンドの実行タイミング
*  上記のプラグインコマンドを使用する場合、【選択肢の表示】の前に実行するのが
*  好ましいです。
*  ただし、メッセージウィンドウを表示したまま選択肢の処理を実行したい場合、
*  【文章の表示】より前にプラグインコマンドを実行してください。
*
* ●ヘルプメッセージの表示
*  各選択肢項目の下に注釈で以下の文字列を入れると、
*  続きの文章をヘルプメッセージとしてカーソルを合わせたときに標示させることができます。
*  
*    選択肢ヘルプ
*
*  ※注意点
*   ヘルプメッセージは[文章の表示]と同じ機能を使っているため、制御文字が使用できます。
*   ただし、\!と\^は使用できません。
*  
* ================================
* 制作 : 木星ペンギン
* URL : http://woodpenguin.blog.fc2.com/
*
* @param maxPageRow
* @desc 1ページに表示される行数
* @default 6
*
*/

(function() {

var parameters = PluginManager.parameters('MPP_ChoiceEX');

var maxPageRow = Number(parameters['maxPageRow']);

var Alias = {};

//-----------------------------------------------------------------------------
// Game_Message

//332
Alias.GaMe_clear = Game_Message.prototype.clear;
Game_Message.prototype.clear = function() {
    Alias.GaMe_clear.call(this);
    this._choiceEnables = [];
    this._choiceResults = [];
    this._helpTexts = [];
    this._choiceX = -1;
    this._choiceY = -1;
    this._choiceMaxRow = maxPageRow;
    this._choiceVariableId = 0;
};

Game_Message.prototype.setChoiceEnables = function(enables) {
    this._choiceEnables = enables;
};

Game_Message.prototype.choiceEnables = function() {
    return this._choiceEnables;
};

Game_Message.prototype.setChoiceResults = function(results) {
    this._choiceResults = results;
};

Game_Message.prototype.setChoiceHelpTexts = function(texts) {
    this._helpTexts = texts;
};

Game_Message.prototype.isHelp = function() {
    return this._helpTexts.length > 0;
};

Game_Message.prototype.setChoicePos = function(x, y, row) {
    this._choiceX = x;
    this._choiceY = y;
    this._choiceMaxRow = row;
};

Game_Message.prototype.setChoiceVariableId = function(id) {
    this._choiceVariableId = id;
};

//-----------------------------------------------------------------------------
// Game_Interpreter

//9062
Game_Interpreter.prototype.setupChoices = function(params) {
    var data = {
        choices: [],
        enables: [],
        results: [],
        helpTexts: [],
        cancelType: -1,
        defaultType: -1,
        positionType: 0,
        background: 0
    };
    data = this.addChoices(params, this._index, data, 0);
    if (data.choices.length > 0) {
        var helpTexts = [];
        if (data.helpTexts.length > 0) {
            helpTexts = data.results.map(function(i) {
                return data.helpTexts;
            });
        }
        var cancelType = -1;
        if (data.cancelType.mod(10) === 8 || data.results.contains(data.cancelType)) {
            data.results.push(data.cancelType);
            cancelType = data.choices.length;
        }
        var defaultType = -1;
        if ($gameMessage._choiceVariableId > 0) {
            var index = $gameVariables.value($gameMessage._choiceVariableId);
            defaultType = data.results.indexOf(index);
        } else {
            defaultType = data.results.indexOf(data.defaultType);
        }
        $gameMessage.setChoices(data.choices, defaultType, cancelType);
        $gameMessage.setChoiceEnables(data.enables);
        $gameMessage.setChoiceResults(data.results);
        $gameMessage.setChoiceHelpTexts(helpTexts);
        $gameMessage.setChoiceBackground(data.background);
        $gameMessage.setChoicePositionType(data.positionType);
        $gameMessage.setChoiceCallback(function(n) {
            this._branch[this._indent] = data.results[n];
        }.bind(this));
    } else {
        this._branch[this._indent] = -1;
    }
};

Game_Interpreter.prototype.addChoices = function(params, i, data, d) {
    var regIf = /\s*if\(([^\)]+)\)/;
    var regEn = /\s*en\(([^\)]+)\)/;
    for (var n = 0; n < params[0].length; n++) {
        var str = params[0][n];
        if (regIf.test(str)) {
            str = str.replace(regIf, '');
            if (RegExp.$1 && !this.evalChoice(RegExp.$1)) continue;
        }
        var enable = true;
        if (regEn.test(str)) {
            str = str.replace(regEn, '');
            enable = this.evalChoice(RegExp.$1);
        }
        data.choices.push(str);
        data.enables.push(enable);
        data.results.push(n + d);
    }
    var cancelType = params[1];
    if (cancelType !== -1) {
        data.cancelType = cancelType + d;
    }
    var defaultType = params.length > 2 ? params[2] : 0;
    if (defaultType >= 0) {
        data.defaultType = defaultType + d;
    }
    data.positionType = params.length > 3 ? params[3] : 2;
    data.background = params.length > 4 ? params[4] : 0;
    for (;;) {
        i++;
        if (this._list.indent === this._indent) {
            if (this._list.code === 402) {
                this.getHelpText(this._list.parameters[0] + d, i + 1, data);
            } else if (this._list.code === 404) {
                break;
            }
        }
    }
    if (this._list[i + 1].code === 102) {
        this.addChoices(this._list[i + 1].parameters, i + 1, data, d + 10);
    }
    return data;
};

Game_Interpreter.prototype.getHelpText = function(c, i, data) {
    if (this._list.code === 108 && this._list.parameters[0] === '選択肢ヘルプ') {
        var texts = [];
        while (this._list[i + 1].code === 408) {
            i++;
            texts.push(this._list.parameters[0]);
        }
        data.helpTexts[c] = texts;
    }
};

Game_Interpreter.prototype.evalChoice = function(formula) {
    try {
        var s = $gameSwitches._data;
        var v = $gameVariables._data;
        return !!eval(formula);
    } catch (e) {
        alert("条件エラー \n\n " + formula);
        return true;
    }
};

//9088
Game_Interpreter.prototype.command403 = function() {
    if (this._branch[this._indent] !== -2) {
        this.skipBranch();
    }
    return true;
};

Game_Interpreter.prototype.command404 = function() {
    if (this.nextEventCode() === 102) {
        this._branch[this._indent] -= 10;
        this._index++;
    }
    return true;
};

//10449
Alias.GaIn_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
    Alias.GaIn_pluginCommand.call(this, command, args);
    switch (command) {
    case 'ChoicePos':
        var x = Number(args[0]);
        var y = Number(args[1]);
        var row = Number(args[2] || 99);
        $gameMessage.setChoicePos(x, y, row);
        break;
    case 'ChoiceVariableId':
        $gameMessage.setChoiceVariableId(Number(args[0]));
        break;
    }
    return true;
};

//-----------------------------------------------------------------------------
// Window_ChoiceList

Alias.WiChLi_close = Window_ChoiceList.prototype.close;
Window_ChoiceList.prototype.close = function() {
    if ($gameMessage.isHelp()) this._messageWindow.onShowFast();
    Alias.WiChLi_close.call(this);
};

Alias.WiChLi_update = Window_ChoiceList.prototype.update;
Window_ChoiceList.prototype.update = function() {
    var lastIndex = this.index();
    Alias.WiChLi_update.call(this);
    var variableId = $gameMessage._choiceVariableId;
    if (lastIndex !== this.index() && variableId > 0) {
        var results = $gameMessage._choiceResults;
        $gameVariables.setValue(variableId, results[this.index()]);
    }
};

//34
Alias.WiChLi_updatePlacement = Window_ChoiceList.prototype.updatePlacement;
Window_ChoiceList.prototype.updatePlacement = function() {
    Alias.WiChLi_updatePlacement.call(this);
    if ($gameMessage._choiceX >= 0 && $gameMessage._choiceY >= 0) {
        this.x = Math.min($gameMessage._choiceX, Graphics.boxWidth - this.width);
        this.y = Math.min($gameMessage._choiceY, Graphics.boxHeight - this.height);
    }
};

//67
Window_ChoiceList.prototype.numVisibleRows = function() {
    return Math.min($gameMessage.choices().length, $gameMessage._choiceMaxRow);
};

//103
Window_ChoiceList.prototype.makeCommandList = function() {
    var choices = $gameMessage.choices();
    var enables = $gameMessage._choiceEnables;
    for (var i = 0; i < choices.length; i++) {
        this.addCommand(choices, 'choice', enables);
    }
};

//110
Alias.WiChLi_drawItem = Window_ChoiceList.prototype.drawItem;
Window_ChoiceList.prototype.drawItem = function(index) {
    this.changePaintOpacity(this.isCommandEnabled(index));
    Alias.WiChLi_drawItem.call(this, index);
};

//123
Alias.WiChLi_callOkHandler = Window_ChoiceList.prototype.callOkHandler;
Window_ChoiceList.prototype.callOkHandler = function() {
    Alias.WiChLi_callOkHandler.call(this);
    this._messageWindow.forceClear();
};

//129
Alias.WiChLi_callCancelHandler = Window_ChoiceList.prototype.callCancelHandler;
Window_ChoiceList.prototype.callCancelHandler = function() {
    Alias.WiChLi_callCancelHandler.call(this);
    this._messageWindow.forceClear();
};

Alias.WiChLi_processCancel = Window_ChoiceList.prototype.processCancel;
Window_ChoiceList.prototype.processCancel = function() {
    var type = $gameMessage.choiceCancelType();
    var results = $gameMessage._choiceResults;
    var index = results.indexOf(results[type]);
    if (this.isCancelEnabled() && index !== type && !this.isCommandEnabled(index)) {
        this.playBuzzerSound();
    } else {
        Alias.WiChLi_processCancel.call(this);
    }
};

Window_ChoiceList.prototype.callUpdateHelp = function() {
    if (this.active && this._messageWindow && $gameMessage.isHelp()) {
        this.updateHelp();
    }
};

Window_ChoiceList.prototype.updateHelp = function() {
    this._messageWindow.forceClear();
    var texts = $gameMessage._helpTexts[this.index()];
    $gameMessage._texts = texts ? texts.clone() : [''];
    this._messageWindow.startMessage();
};


//-----------------------------------------------------------------------------
// Window_Message

//65
//Window_Message.prototype.update = function() {
//    this.checkToNotClose();
//    Window_Base.prototype.update.call(this);
//    while (!this.isOpening() && !this.isClosing()) {
//        if (this.updateWait()) {
//            return;
//        } else if (this.updateLoading()) {
//            return;
//        } else if (!this.pause && this.updateMessage()) {
//            return;
//        } else if (this.updateInput()) {
//            return;
//        } else if (this.canStart()) {
//            this.startMessage();
//        } else {
//            this.startInput();
//            return;
//        }
//    }
//};

//148
Alias.WiMe_updateInput = Window_Message.prototype.updateInput;
Window_Message.prototype.updateInput = function() {
    if ($gameMessage.isHelp() && this._textState) {
        return false;
    }
    return Alias.WiMe_updateInput.call(this);
};

//206
Alias.WiMe_startInput = Window_Message.prototype.startInput;
Window_Message.prototype.startInput = function() {
    if (this._choiceWindow.active) {
        return true;
    }
    return Alias.WiMe_startInput.call(this);
};

Window_Message.prototype.forceClear = function() {
    this._textState = null;
    this.close();
    this._goldWindow.close();
};

Window_Message.prototype.onShowFast = function() {
    this._showFast = true;
};


})();
[/pre]
新しい誕生祝いだッ!
回复 1 0

使用道具 举报

梦石
0
星屑
50
在线时间
15 小时
注册时间
2016-6-14
回帖
6
 楼主| 发表于 2016-10-7 23:43:40 | 显示全部楼层
玄天 发表于 2016-10-7 23:18
用这个吧,具体用法看注释

嗷谢谢,
我去试试看
回复

使用道具 举报

梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2016-10-7 23:47:06 | 显示全部楼层
SupponShopStock.js
* @plugindesc
在庫システム[pre lang="javascript"]//=============================================================================
// SupponShopStock.js
//=============================================================================

/*:
* @plugindesc 在庫システムを有するお店を設定します。version 1.02
* @author Suppon
*
* @param Label of stock Number
* @desc 在庫数の表記を設定します
* @default 在庫数
*
* @param Label of sold out
* @desc 売り切れの表記を設定します
* @default 売り切れ
*
* @help
* このプラグインを使用するときは以下のようにプラグインコマンドを入力してください。
*
* <ショップの作成例>
* SupponSS makeShop 1 2
* IDが1、ショップタイプが2のショップを作ります。IDにはabcのような文字も使えます。
* ショップタイプ0は購買専門(売却不可)
* ショップタイプ1は購買、売却可能
* ショップタイプ2は購買、売却可能、全ての売却品がショップの商品に加わります。
* ショップタイプを省略した場合は1になります。
*
* <アイテムの追加例>
* SupponSS addItem 1 2 3 4
* IDが1のショップにアイテムIDが2のアイテムを加えます。
* 在庫数はID3の変数に割り当て、在庫を4個に設定します。
* 3の部分を-1にすると変数は使わず、在庫は内部のデータで処理されます。
* 最後の4の部分を省略すると現在の変数が適用されます。
*
* <武器の追加例>
* SupponSS addWeapon 1 2 3 4
*
* <防具の追加例>
* SupponSS addArmor 1 2 3 4
*
* <アイテムの削除例>
* SupponSS removeItem 1 2
* IDが1のショップのアイテムIDが2のアイテムを削除します。
*
* <武器の削除例>
* SupponSS removeWeapon 1 2
*
* <防具の削除例>
* SupponSS removeArmor 1 2
*
* <ショップの起動例>
* SupponSS openShop 1
* IDが1のショップを起動します。
*
* <ショップの削除例>
* SupponSS deleteShop 1
* IDが1のショップを削除します。
*
*
*/

(function() {
    var parameters = PluginManager.parameters('SupponShopStock');
    var StockLabel = String(parameters['Label of stock Number']||'在庫数');
    var SoldOutLabel = String(parameters['Label of sold out']||'売り切れ');
   
    var _Game_Interpreter_pluginCommand =Game_Interpreter.prototype.pluginCommand;
    Game_Interpreter.prototype.pluginCommand = function(command1, args) {
        _Game_Interpreter_pluginCommand.call(this, command1, args);
        args = args.filter(function(n){
            return n!=='';
        });
        if(!$gameSystem._supponSS){$gameSystem._supponSS=[]};
        if (command1 === 'SupponSS') {
            var command2 = args.shift();
            switch (command2) {
            case 'makeShop':
                $gameSystem.supponSSmakeShop(args);
                break;
            case 'addItem':
                args.splice(1,0,0);
                $gameSystem.supponSSaddGoods(args);
                break;
            case 'addWeapon':
                args.splice(1,0,1);
                $gameSystem.supponSSaddGoods(args);
                break;
            case 'addArmor':
                args.splice(1,0,2);
                $gameSystem.supponSSaddGoods(args);
                break;
            case 'removeItem':
                args.splice(1,0,0);
                $gameSystem.supponSSremoveGoods(args);
                break;
            case 'removeWeapon':
                args.splice(1,0,1);
                $gameSystem.supponSSremoveGoods(args);
                break;
            case 'removeArmor':
                args.splice(1,0,2);
                $gameSystem.supponSSremoveGoods(args);
                break;
            case 'deleteShop':
                $gameSystem.supponSSdeleteShop(args);
                break;
            case 'openShop':
                $gameSystem.supponSSopenShop(args);
                break;
            }
        }
    };
   
   
    Game_System.prototype.supponSScheckData = function(){
        this._supponSS = this._supponSS || [];
    }

    Game_System.prototype.supponSSmakeShop = function(args){
        this.supponSScheckData();
        var redundancy = this._supponSS.some(function(element){
            return element[0] === args[0];
        })
        if(redundancy){return};
        if(!args[1]){args[1]=1};
        this._supponSS.push([args[0],[],args[1]]);//[shopid, goods, shoptype]
    }
   
    //args => [shopId, 種類, itemId, 変数id]
    //shop => [id, goods, type]
    //good => [種類, itemId, 価格指定, 価格, 変数id, 在庫数]
    Game_System.prototype.supponSSaddGoods = function(args){
        var shop = this.supponSSsearchShop(args);
        args.shift();
        args.splice(2,0,0,0);
        if(shop){
            var redundancy = false;
            shop[1].forEach(function(element){
                if(element[0]==args[0] && element[1]==args[1]){
                    element = args;
                    redundancy = true;
                }
            })
            if(args[5]){
                args[4]>0 ? $gameVariables.setValue(Number(args[4]),Number(args[5])) :0;
            } else {
                args[5] = 0;
            }
            if(!redundancy){shop[1].push(args)}
        }
    }
   
    Game_System.prototype.supponSSremoveGoods = function(args){
        var shop = this.supponSSsearchShop(args);
        if(!shop){return};
        //shop[1] => goods
        shop[1] = shop[1].filter(function(element){
            return !(args[1]==element[0] && args[2]==element[1]);
        })
    }
   
    Game_System.prototype.supponSSsearchShop = function(args){
        this.supponSScheckData();
        var shop = null;
        this._supponSS.forEach(function(element){
            if(args[0]===element[0]){shop=element}
        })
        if(!shop){
            console.log('Not exist shop of '+args[0]+' !!');
        }
        return shop;
    }
   
    Game_System.prototype.supponSSdeleteShop = function(args){
        this._supponSS = this._supponSS.filter(function(element){
            return !(element[0]==args[0]);
        })
    }
   
    Game_System.prototype.supponSSopenShop = function(args){
        var shop = this.supponSSsearchShop(args);
        if(shop){
            SceneManager.push(Scene_supponSSshop);
            var purchaseOnly = shop[2]==0;
            SceneManager.prepareNextScene(shop, purchaseOnly);   
        }
        
    }
   
    function Scene_supponSSshop() {
        this.initialize.apply(this, arguments);
    };
   
    SceneManager.isSupponSS = function(){
        return this._scene.constructor === Scene_supponSSshop;
    }

    Scene_supponSSshop.prototype = Object.create(Scene_Shop.prototype);
    Scene_supponSSshop.prototype.constructor = Scene_supponSSshop;

    Scene_supponSSshop.prototype.initialize = function() {
        Scene_Shop.prototype.initialize.call(this);
        this._trade = '';// 'buy' or 'sell';
    };
   
    Scene_supponSSshop.prototype.prepare = function(shop, purchaseOnly) {
        this._shop = shop;
        this._goods = this._shop[1];
        this._purchaseOnly = purchaseOnly;
        this._item = null;
    };
   
    Scene_supponSSshop.prototype.commandBuy = function() {
        this._trade = 'buy';
        Scene_Shop.prototype.commandBuy.call(this);
    };
   
    Scene_supponSSshop.prototype.commandSell = function() {
        this._trade = 'sell';
        Scene_Shop.prototype.commandSell.call(this);
    };
   
    Scene_supponSSshop.prototype.stockNumber = function(){
        if (this._trade == 'buy'){
            return this._buyWindow.stockNumber();
        } else if (this._trade == 'sell'){
            var goodsElement = this.goodsElement();
            if(goodsElement){
                if(goodsElement[4] > 0){
                    return $gameVariables.value(Number(goodsElement[4]));
                } else if (goodsElement[4] == -1) {
                    return goodsElement[5];
                }
            } else {
                return null;
            }
        }
    }
   
    Scene_supponSSshop.prototype.stockId = function(){
        if (this._trade == 'buy'){
            return this._buyWindow.stockId();
        } else if (this._trade == 'sell'){
            var goodsElement = this.goodsElement()
            if (goodsElement){
                if(goodsElement[4] > 0){
                    return goodsElement[4];
                }
            }
        }
    }
   
    Scene_supponSSshop.prototype.goodsElement = function(){
        if (this._trade == 'buy'){
            return this._goods[this._buyWindow.index()];
        } else if (this._trade == 'sell'){
            return this.searchGoodsElement();
        }
    }
   
    Scene_supponSSshop.prototype.searchGoodsElement = function(){
        var type = this.itemTypeAndId()[0];
        var id = this.itemTypeAndId()[1];
        var goodsElement = null;
        this._goods.forEach(function(element){
            if(element[0]==type && element[1]==id){
                goodsElement = element;
            }
        })
        return goodsElement;
    }
   
    Scene_supponSSshop.prototype.itemTypeAndId = function(){
        if(DataManager.isItem(this._item)){
            var type = 0;
        } else if (DataManager.isWeapon(this._item)){
            var type = 1;
        } else if (DataManager.isArmor(this._item)){
            var type = 2;
        } else {
            var type = null;
        }
        return [type, (this._item ? this._item.id : null)];
    }
   
    Scene_supponSSshop.prototype.makeGoodsElement = function(){
        var type = this.itemTypeAndId()[0];
        var id = this.itemTypeAndId()[1];
        return [type, id, 0, 0, -1, 0];
    }

    Scene_supponSSshop.prototype.doBuy = function(number) {
        Scene_Shop.prototype.doBuy.call(this, number);
        this.processStockBuy(number);
        //gameVariables.setValue(this._stockId, this.itemStock()-number);
    };
   
    Scene_supponSSshop.prototype.processStockBuy = function(number){
        var element = this.goodsElement();
        if(this.stockId() > 0){
            $gameVariables.setValue(this.stockId(), this.stockNumber()-number)
        } else if (this.stockId() == -1){
            var lastStock = element[5];
            element[5] = lastStock-number;
        }
    }
   
    Scene_supponSSshop.prototype.maxBuy = function() {
        var max = $gameParty.maxItems(this._item) - $gameParty.numItems(this._item);
        max = Math.min(max, this.stockNumber());
        var price = this.buyingPrice();
        if (price > 0) {
            return Math.min(max, Math.floor(this.money() / price));
        } else {
            return max;
        }
    };

    Scene_supponSSshop.prototype.doSell = function(number) {
        $gameParty.gainGold(number * this.sellingPrice());
        $gameParty.loseItem(this._item, number);
        this.processStockSell(number);
    };
   
    Scene_supponSSshop.prototype.processStockSell = function(number){
        var goodsElement = this.goodsElement();
        if (goodsElement){
            if(goodsElement[4]>0){
                var lastNumber = $gameVariables.value(goodsElement[4]);
                $gameVariables.setValue(goodsElement[4],lastNumber+number);
            } else if (goodsElement[4] == -1){
                goodsElement[5] = goodsElement[5]+number;
            }
        } else if (this._shop[2]==2){
            goodsElement = this.makeGoodsElement();
            goodsElement[5]=number;
            this._goods.push(goodsElement);
        }
    }
   
    Window_ShopBuy.prototype.stockId = function() {
        if (this._shopGoods.length>0){
            return this._shopGoods[this._index][4];
        } else {
            return null
        }
    };
   
    Window_ShopBuy.prototype.stockNumber = function() {
        if (this.stockId()>0){
            return $gameVariables.value(this.stockId());
        } else if (this.stockId() == -1){
            return this._shopGoods[this._index][5];
        }
    };
   
    var _Window_ShopBuy_drawItem = Window_ShopBuy.prototype.drawItem;
    Window_ShopBuy.prototype.drawItem = function(index) {
        if(!SceneManager.isSupponSS()){
            _Window_ShopBuy_drawItem.call(this, index);
            return;
        }
        var item = this._data[index];
        var rect = this.itemRect(index);
        var priceWidth = 96;
        rect.width -= this.textPadding();
        if(this._shopGoods[index][4]>0){
            var stockNumber = $gameVariables.value(this._shopGoods[index][4]);
        } else if (this._shopGoods[index][4] == -1){
            var stockNumber = this._shopGoods[index][5]
        }        
        this.changePaintOpacity(this.isEnabled(item) && stockNumber>0 );
        this.drawItemName(item, rect.x, rect.y, rect.width - priceWidth);
        var text = (stockNumber>0 ? this.price(item) : SoldOutLabel);
        this.drawText(text, rect.x + rect.width - priceWidth,
                      rect.y, priceWidth, 'right');
        this.changePaintOpacity(true);
    };
   
    var _Window_ShopBuy_isCurrentItemEnabled = Window_ShopBuy.prototype.isCurrentItemEnabled;
    Window_ShopBuy.prototype.isCurrentItemEnabled = function() {
        if(SceneManager.isSupponSS()){
            return (_Window_ShopBuy_isCurrentItemEnabled.call(this) && this.stockNumber()>0)
        } else {
            return _Window_ShopBuy_isCurrentItemEnabled.call(this)
        }
    };
   
    var _Window_ShopBuy_updateHelp = Window_ShopBuy.prototype.updateHelp;
    Window_ShopBuy.prototype.updateHelp = function() {
        if (this._statusWindow && SceneManager.isSupponSS()) {
            this._statusWindow.setStock(this.stockNumber());
        }
        _Window_ShopBuy_updateHelp.call(this);
    };
   
    var _Window_ShopStatus_initialize = Window_ShopStatus.prototype.initialize;
    Window_ShopStatus.prototype.initialize = function(x, y, width, height) {
        this._stockNumber = null;
        _Window_ShopStatus_initialize.call(this, x, y, width, height);
    };
   
    Window_ShopStatus.prototype.setStock = function(number) {
        this._stockNumber = number;
    };
   
    Window_ShopStatus.prototype.stockNumber = function(){
        return SceneManager._scene.stockNumber();
    }
   
    var _Window_ShopStatus_drawPossession = Window_ShopStatus.prototype.drawPossession;
    Window_ShopStatus.prototype.drawPossession = function(x, y) {
        _Window_ShopStatus_drawPossession.call(this, x, y);
        if(!SceneManager.isSupponSS() || !this._stockNumber){return}
        var width = this.contents.width - this.textPadding() - x;
        var possessionWidth = this.textWidth('0000');
        this.changeTextColor(this.systemColor());
        this.drawText(StockLabel, x, y+this.lineHeight(), width - possessionWidth);
        this.resetTextColor();
        this.drawText(this._stockNumber, x, y+this.lineHeight(), width, 'right');
    };
   
})();
[/pre]
を有するお店を設定します。version 1.02
* @author Suppon
回复

使用道具 举报

梦石
0
星屑
50
在线时间
15 小时
注册时间
2016-6-14
回帖
6
 楼主| 发表于 2016-10-8 00:04:51 | 显示全部楼层
tseyik 发表于 2016-10-7 23:47
SupponShopStock.js
* @plugindesc [fold=在庫システム]//============================================ ...

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

使用道具 举报

梦石
0
星屑
50
在线时间
15 小时
注册时间
2016-6-14
回帖
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
回复

使用道具 举报

梦石
0
星屑
311
在线时间
204 小时
注册时间
2007-2-4
回帖
1772
发表于 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
新しい誕生祝いだッ!
回复

使用道具 举报

梦石
0
星屑
306
在线时间
38 小时
注册时间
2019-8-4
回帖
22
发表于 2021-2-25 18:14:52 | 显示全部楼层
本帖最后由 vodgabongd 于 2021-2-26 15:05 编辑
玄天 发表于 2016-10-7 23:18
用这个吧,具体用法看注释


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

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部