Custom Item Selection Scene

Rink27

Veteran
Veteran
Joined
Jul 18, 2014
Messages
222
Reaction score
13
First Language
English
Primarily Uses
RMMV
Hello.

I am trying to create a custom window/scene (via a custom plugin) similar to the window used for the event command [Select Item].
I would like this scene to show the item selection window and an additional window next to it (above/below) that gives relevant info depending on the currently highlighted item. I plan to use note tag variables (from item database) to be displayed in this additional descriptive window.

So... from rpg_windows I found coding for Window_EventItem from line 4161.
So I could try to play around with that for the select item window part. However, I would need to include coding for the scene part as well right? I'm not finding the relevant scene for selecting an item from rpg_scenes. The closest, I think, I'm finding is Scene_Item from line 1011.

Am I thinking this right? Is there coding for the item selection scene? I'm still a noob at javascript, so I could be terribly wrong.
I'm not sure what window/scene I should use as a template for the additional window as well (I could probably find something eventually, but in case anyone can cut my searching that'll be nice).
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,956
First Language
English
Primarily Uses
RMMV
There isn't actually a scene for that event command, the instance of Window_EventItem is created in the createSubWindows function of Window_Message, which is itself created in Scene_Map in the createMessageWindow function.

If you want to achieve the same thing with a plugin, just create a new Window_EventItem in a script call or add it as a subwindow in Scene_Map and then make it visible when you need to show it.
 

Rink27

Veteran
Veteran
Joined
Jul 18, 2014
Messages
222
Reaction score
13
First Language
English
Primarily Uses
RMMV
There isn't actually a scene for that event command, the instance of Window_EventItem is created in the createSubWindows function of Window_Message, which is itself created in Scene_Map in the createMessageWindow function.

If you want to achieve the same thing with a plugin, just create a new Window_EventItem in a script call or add it as a subwindow in Scene_Map and then make it visible when you need to show it.
I'm not sure what to put in a script call, especially with the limited space, so I tried to make a plugin for it. I'm getting a "Cannot read property 'apply' of undefined" error. My code is:

Code:
(function(){



    var _Scene_Map_createMessageWindow = Scene_Map.prototype.createMessageWindow;
    Scene_Map.prototype.createMessageWindow = function() {
        _Scene_Map_createMessageWindow.call(this);

        this._myRefineWindow = new My_RefineWindow(30, 100);     //Create window by creating a private variable from scene map
        this.addWindow(this._myRefineWindow);                     //Adds window to scene map class
    };

    function My_RefineWindow(){
        this.initialize.apply(this, arguments);
    }

    My_Window.prototype = Object.create(Window_Message.prototype);
    My_Window.prototype.constructor = My_RefineWindow;

    My_Window.prototype.initialize = function(x, y){
        Window_Message.prototype.initialize.call(this, x, y, 100, 100); // 100 = width, height
    }

})();
The full code (same as above, but includes commented out stuff):

Code:
(function(){



    var _Scene_Map_createMessageWindow = Scene_Map.prototype.createMessageWindow;
    Scene_Map.prototype.createMessageWindow = function() {
        _Scene_Map_createMessageWindow.call(this);

        /*this._messageWindow = new Window_Message();
        this.addWindow(this._messageWindow);
        this._messageWindow.subWindows().forEach(function(window) {
            this.addWindow(window);
        }, this);*/

        this._myRefineWindow = new My_RefineWindow(30, 100);     //Create window by creating a private variable from scene map
        this.addWindow(this._myRefineWindow);                     //Adds window to scene map class
    };

    //var _Scene_Map_start = Scene_Map.prototype.start;
    //Scene_Map.prototype.start = function() {
    //    _Scene_Map_start.call(this);

        /*Scene_Base.prototype.start.call(this);
        SceneManager.clearStack();
        if (this._transfer) {
            this.fadeInForTransfer();
            this._mapNameWindow.open();
            $gameMap.autoplay();
        } else if (this.needsFadeIn()) {
            this.startFadeIn(this.fadeSpeed(), false);
        }
        this.menuCalling = false;*/

    //    this._myWindow = new My_Window(30, 100);     //Create window by creating a private variable from scene map
    //    this.addWindow(this._myWindow);             //Adds window to scene map class
    //};

    function My_RefineWindow(){
        this.initialize.apply(this, arguments);
    }

    My_Window.prototype = Object.create(Window_Message.prototype);
    My_Window.prototype.constructor = My_RefineWindow;

    My_Window.prototype.initialize = function(x, y){
        Window_Message.prototype.initialize.call(this, x, y, 100, 100); // 100 = width, height
    }



// instance of Window_EventItem is created in the createSubWindows function of Window_Message, which is itself
// created in Scene_Map in the createMessageWindow function
/*
    Window_Message.prototype.createSubWindows = function() {
        this._goldWindow = new Window_Gold(0, 0);
        this._goldWindow.x = Graphics.boxWidth - this._goldWindow.width;
        this._goldWindow.openness = 0;
        this._choiceWindow = new Window_ChoiceList(this);
        this._numberWindow = new Window_NumberInput(this);
        this._itemWindow = new Window_EventItem(this);
    };

    Scene_Map.prototype.createMessageWindow = function() {
        this._messageWindow = new Window_Message();
        this.addWindow(this._messageWindow);
        this._messageWindow.subWindows().forEach(function(window) {
            this.addWindow(window);
        }, this);
    };
*/

})();

Edit: Added three lines to the createMessageWindow part. Same error, though.

Code:
    var _Scene_Map_createMessageWindow = Scene_Map.prototype.createMessageWindow;
    Scene_Map.prototype.createMessageWindow = function() {
        _Scene_Map_createMessageWindow.call(this);

        /*this._messageWindow = new Window_Message();
        this.addWindow(this._messageWindow);
        this._messageWindow.subWindows().forEach(function(window) {
            this.addWindow(window);
        }, this);*/

        this._myRefineWindow = new My_RefineWindow(30, 100);     //Create window by creating a private variable from scene map
        this.addWindow(this._myRefineWindow);                     //Adds window to scene map class
            this._myRefineWindow.subWindows().forEach(function(window) {
            this.addWindow(window);
        }, this);
    };
 
Last edited:

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,956
First Language
English
Primarily Uses
RMMV
The reason you're getting the error is that you're trying to call the initialize function of My_RefineWindow but then the one you actually wrote is for an object called My_Window. They need to be called the same thing.
 

Rink27

Veteran
Veteran
Joined
Jul 18, 2014
Messages
222
Reaction score
13
First Language
English
Primarily Uses
RMMV
The reason you're getting the error is that you're trying to call the initialize function of My_RefineWindow but then the one you actually wrote is for an object called My_Window. They need to be called the same thing.
Ohhh. Alright. Well I fixed it and the game doesn't get any errors now. However, the window doesn't show up. I assume this is because I'm working with Window_Message and not Window_Base (the latter makes it appear automatically?).

Can you guide me to how I can toggle its appearance?
Edit: Would it be something with calling it? Like Scene_Map.prototype.callMenu ?
Edit 2: Or I guess it involves using Window_Message.prototype.createSubWindows...?

Code:
(function(){

    var _Scene_Map_createMessageWindow = Scene_Map.prototype.createMessageWindow;
    Scene_Map.prototype.createMessageWindow = function() {
        _Scene_Map_createMessageWindow.call(this);

        this._myRefineWindow = new My_RefineWindow(30, 100);     //Create window by creating a private variable from scene map
        this.addWindow(this._myRefineWindow);                     //Adds window to scene map class
            this._myRefineWindow.subWindows().forEach(function(window) {
            this.addWindow(window);
        }, this);
    };

    function My_RefineWindow(){
        this.initialize.apply(this, arguments);
    }

    My_RefineWindow.prototype = Object.create(Window_Message.prototype);
    My_RefineWindow.prototype.constructor = My_RefineWindow;

    My_RefineWindow.prototype.initialize = function(x, y){
        Window_Message.prototype.initialize.call(this, x, y, 100, 100); // 100 = width, height
    }

})();
 
Last edited:

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,956
First Language
English
Primarily Uses
RMMV
I did a new map window to make a HUD for someone in another topic. Have a look at my code and see if it helps you figure out the process for yours.

Code:
//=============================================================================
// MapHUD.js
//=============================================================================

/*:
 * @plugindesc Simple HUD plugin for thalesgal.
 * @author John Clifford (Trihan)
 *
 * @param X
 * @desc The x coordinate of the window
 * @default 0
 *
 *
 * @param Y
 * @desc The y coordinate of the window
 * @default 0
 *
 * @help
 *
 * Just puts a HUD on the screen that shows the level/HP/MP of the party leader.
 *
 */

(function() {
    var parameters = PluginManager.parameters('MapHUD');
    
    function Window_HUD() {
        this.initialize.apply(this, arguments);
    }
    
    Window_HUD.prototype = Object.create(Window_Base.prototype);
    Window_HUD.prototype.constructor = Window_HUD;
    
    Window_HUD.prototype.initialize = function() {
        Window_Base.prototype.initialize.call(this, parameters['X'], parameters['Y'], 350, 150);
        this.opacity = 0;
    };
    
    Window_HUD.prototype.update = function() {
        this.contents.clear();
        this.drawLeaderHUD();
    };
    
    Window_HUD.prototype.drawLeaderLevel = function(leader, x, y) {
        this.changeTextColor(this.systemColor());
        this.drawText("Lv", 10, 0, 30);
        this.resetTextColor();
        this.drawText(leader.level, 30, 0, 30, 'right');
    };
    
    Window_HUD.prototype.drawLeaderHUD = function() {
        var leader = $gameParty.members()[0];
        this.drawLeaderLevel(leader, 10, 0);
        this.drawActorHp(leader, 10, this.lineHeight(), 250);
        this.drawActorMp(leader, 10, this.lineHeight() * 2, 250);       
    };
    
    _Scene_Map_createAllWindows = Scene_Map.prototype.createAllWindows;
    Scene_Map.prototype.createAllWindows = function() {
        _Scene_Map_createAllWindows.call(this);
        this._hudWindow = new Window_HUD();
        this.addChild(this._hudWindow);
    };
        
})();
 

Rink27

Veteran
Veteran
Joined
Jul 18, 2014
Messages
222
Reaction score
13
First Language
English
Primarily Uses
RMMV
I did a new map window to make a HUD for someone in another topic. Have a look at my code and see if it helps you figure out the process for yours.
Okay, so I need to call/update its appearance, which can be done via .update?
I understand that this.contents.clear(); clears the previous creation (to avoid stacking/overlapping), but I'm not even sure how to do the creation afterwards. I don't think I have to draw anything (yet)? At least for the item Window.

So if I was on the right track about createSubWindows... I need to use that to create what I want, but I'm not sure.
Would

Window_Message.prototype._itemWindow(); call it ultimately? I'm not sure what to do in the aliased createSubWindows part.

Code:
(function(){

    function My_RefineWindow(){
        this.initialize.apply(this, arguments);
    }

    My_RefineWindow.prototype = Object.create(Window_Message.prototype);
    My_RefineWindow.prototype.constructor = My_RefineWindow;

    My_RefineWindow.prototype.initialize = function(x, y){
        Window_Message.prototype.initialize.call(this, x, y, 100, 100); // 100 = width, height
    };

    My_RefineWindow.prototype.update = function(){
        this.contents.clear();
        //Window_Message.prototype._itemWindow();   // Need to "call" the itemWindow from the createSubWindows
    }


    var _Scene_Map_createMessageWindow = Scene_Map.prototype.createMessageWindow;
    Scene_Map.prototype.createMessageWindow = function() {
        _Scene_Map_createMessageWindow.call(this);

        this._myRefineWindow = new My_RefineWindow(30, 100);     //Create window by creating a private variable from scene map
        this.addWindow(this._myRefineWindow);                     //Adds window to scene map class
        this._myRefineWindow.subWindows().forEach(function(window) {
           this.addWindow(window);
        }, this);

        /*this._messageWindow = new Window_Message();
        this.addWindow(this._messageWindow);
        this._messageWindow.subWindows().forEach(function(window) {
            this.addWindow(window);
        }, this);*/

    };

    var _Window_Message_createSubWindows = Window_Message.prototype.createSubWindows;
    Window_Message.prototype.createSubWindows = function() {
        _Window_Message_createSubWindows.call(this);

        this._mySubRefineWindow = new My_RefineWindow(30, 100);
        //this._itemWindow = this._mySubRefineWindow;  // ???

        /*this._goldWindow = new Window_Gold(0, 0);
        this._goldWindow.x = Graphics.boxWidth - this._goldWindow.width;
        this._goldWindow.openness = 0;
        this._choiceWindow = new Window_ChoiceList(this);
        this._numberWindow = new Window_NumberInput(this);
        this._itemWindow = new Window_EventItem(this);*/
    };

})();
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,956
First Language
English
Primarily Uses
RMMV
Why are you creating an instance of My_RefineWindow in both createMessageWindow and createSubWindows? And why is it inheriting from Window_Message?
 

Rink27

Veteran
Veteran
Joined
Jul 18, 2014
Messages
222
Reaction score
13
First Language
English
Primarily Uses
RMMV
Why are you creating an instance of My_RefineWindow in both createMessageWindow and createSubWindows? And why is it inheriting from Window_Message?
Sorry. I don't fully grasp what I'm doing.
You said above "the instance of Window_EventItem is created in the createSubWindows function of Window_Message"

So I thought I'd use Window_Message. And oh it's creating an instance of it? I thought I was creating
this._mySubRefineWindow and this._myRefineWindow and setting My_RefineWindow as both.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,956
First Language
English
Primarily Uses
RMMV
You only want a single window added, right?
 

Rink27

Veteran
Veteran
Joined
Jul 18, 2014
Messages
222
Reaction score
13
First Language
English
Primarily Uses
RMMV
You only want a single window added, right?
Um a single window of the item selection event. Then after I figure that out, I need to add an accompanying (description) window whose info updates depending on the currently highlighted item (Like when you're navigating the item menu list and seeing different descriptions).

This is just to make it easier on the player to see what could happen when navigating an item to use.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,956
First Language
English
Primarily Uses
RMMV
So pretty much what you want is a help window for item selection?
 

Rink27

Veteran
Veteran
Joined
Jul 18, 2014
Messages
222
Reaction score
13
First Language
English
Primarily Uses
RMMV
So pretty much what you want is a help window for item selection?
Well, yea. But not all item selection events. I'm trying to create a reverse-crafting system, where you can deconstruct an item to get some of the resources that were used to create it.

I've already created such a system on my own, but when the player has to select an item, I'd like if they had more info at that step than after selecting the item.

Edit: A help window added on, yea, but I don't want it to use the description defined in the database.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,956
First Language
English
Primarily Uses
RMMV
Okay, give me a bit.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,956
First Language
English
Primarily Uses
RMMV
Here you go, all you need to add is the help text.

Code:
//=============================================================================
// RefineWindow.js
//=============================================================================

/*:
 * @plugindesc Refinement window for Rink27
 * @author John Clifford (Trihan)
 *
 * @help
 *
 * Use the plugin command RefineWindow open variableId itemtypeId
 *
 */

(function() {
    var parameters = PluginManager.parameters('RefineWindow');
    
    _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    Game_Interpreter.prototype.pluginCommand = function(command, args) {
        _Game_Interpreter_pluginCommand.call(this, command, args);
        if (command === 'RefineWindow') {
            switch(args[0]) {
                case 'open':
                if (!$gameMessage.isBusy()) {
                    $gameMessage.setRefineChoice(Number(args[1]), Number(args[2]));
                    this.setWaitMode('message');
                }
                break;
            }
        }
    };
    
    function Window_Refine() {
        this.initialize.apply(this, arguments);
    }
    
    Window_Refine.prototype = Object.create(Window_EventItem.prototype);
    Window_Refine.prototype.constructor = Window_Refine;
    
    Window_Refine.prototype.initialize = function(messageWindow) {
        Window_EventItem.prototype.initialize.call(this, messageWindow);
    };
    
    Window_Refine.prototype.updatePlacement = function() {
        this.y = this.fittingHeight(1);
    };
    
    Window_Refine.prototype.includes = function(item) {
        return true;
        var itypeId = $gameMessage.refineChoiceItypeId();
        return DataManager.isItem(item) && item.itypeId === itypeId;
    };
    
    Window_Refine.prototype.onOk = function() {
        var item = this.item();
        var itemId = item ? item.id : 0;
        $gameVariables.setValue($gameMessage.refineChoiceVariableId(), itemId);
        this._messageWindow.terminateMessage();
        this._helpWindow.hide();
        this.close();
    };
    
    Window_Refine.prototype.onCancel = function() {
        $gameVariables.setValue($gameMessage.refineChoiceVariableId(), 0);
        this._messageWindow.terminateMessage();
        this._helpWindow.hide();
        this.close();
    };
    
    _Window_Message_subWindows = Window_Message.prototype.subWindows;
    Window_Message.prototype.subWindows = function() {
        var subWindows = _Window_Message_subWindows.call(this);
        subWindows.push(this._refineWindow);
        subWindows.push(this._refineHelpWindow);
        return subWindows;
    };
    
    _Window_Message_createSubWindows = Window_Message.prototype.createSubWindows;
    Window_Message.prototype.createSubWindows = function() {
        _Window_Message_createSubWindows.call(this);
        this._refineWindow = new Window_Refine(this);
        this._refineHelpWindow = new Window_Help(1);
        this._refineWindow.setHelpWindow(this._refineHelpWindow);
        this._refineHelpWindow.hide();
    };
    
    _Window_Message_isAnySubWindowActive = Window_Message.prototype.isAnySubWindowActive;
    Window_Message.prototype.isAnySubWindowActive = function() {
        return (this._refineWindow.active || _Window_Message_isAnySubWindowActive.call(this));
    };
    
    _Window_Message_startInput = Window_Message.prototype.startInput;
    Window_Message.prototype.startInput = function() {
        if ($gameMessage.isRefine()) {
            this._refineWindow.start();
            this._refineHelpWindow.show();
            return true;
        } else {
            _Window_Message_startInput.call(this);
        }
    };
    
    _Game_Message_clear = Game_Message.prototype.clear;
    Game_Message.prototype.clear = function() {
        _Game_Message_clear.call(this);
        this._refineChoiceVariableId = 0;
    };
    
    Game_Message.prototype.refineChoiceVariableId = function() {
        return this._refineChoiceVariableId;
    };
    
    Game_Message.prototype.refineChoiceItypeId = function() {
        return this._itemChoiceItypeId;
    };
    
    Game_Message.prototype.setRefineChoice = function(variableId, itemType) {
        this._refineChoiceVariableId = variableId;
        this._refineChoiceTypeId = itemType;
    };
    
    Game_Message.prototype.isRefine = function() {
        return this._refineChoiceVariableId > 0;
    };
    
    _Game_Message_isBusy = Game_Message.prototype.isBusy;
    Game_Message.prototype.isBusy = function() {
        return this.isRefine() || _Game_Message_isBusy.call(this);
    };
})();
 

Rink27

Veteran
Veteran
Joined
Jul 18, 2014
Messages
222
Reaction score
13
First Language
English
Primarily Uses
RMMV
Here you go, all you need to add is the help text.

Thanks very much. I'm getting it to work.


I don't think I'd have figured out some of these stuff for a long while.
Anyways, I eventually figured out how to edit the help text. I added the Window_Help function and it's relevant parts thereafter. Then I renamed accordingly:

Code:
    function Window_RefHelp() {
    this.initialize.apply(this, arguments);
    }

    Window_RefHelp.prototype = Object.create(Window_Base.prototype);
    Window_RefHelp.prototype.constructor = Window_Help;

    Window_RefHelp.prototype.initialize = function(numLines) {
        var width = Graphics.boxWidth;
        var height = this.fittingHeight(numLines || 2);
        Window_Base.prototype.initialize.call(this, 0, 0, width, height);
        this._text = '';
    };

    Window_RefHelp.prototype.setText = function(text) {
        if (this._text !== text) {
            this._text = text;
            this.refresh();
        }
    };

    Window_RefHelp.prototype.clear = function() {
        this.setText('');
    };

    Window_RefHelp.prototype.setItem = function(item) {
        this.setText(item ? $item.description : '');
    };

    Window_RefHelp.prototype.refresh = function() {
        this.contents.clear();
        this.drawTextEx(this._text, this.textPadding(), 0);
    };

I played around with the second to last section:
this.setText(item ? item.description : '');

I think utilising item.note would be best for me since I wanted to utilise notetags before.
However, it only displays the first line from the note box (Edit: could get it to display more lines) - which I *can* work with, but I have two questions:

1)
The following line:
var height = this.fittingHeight(numLines || 2);

causes the help window to be the length of 1 line. I'm not sure why it's not greater than 1.
I could just remove numLines || and get it to 2 lines if I want, but was curious.

2)
So how I was pulling info from the note tags involved:

$gameVariables.setValue(244, $dataItems[$gameVariables.value(242)].meta.refined_Resource);
$gameVariables.setValue(245, $dataItems[$gameVariables.value(242)].meta.refined_Amount);

However,
this.setText(item ? item.meta.refined_Resource : '');
this.setText(item ? item.note.meta.refined_Resource : '');
this.setText(item ? $dataItems[item.meta.refined_Resource] : '');

etc failed. I could achieve what I want without doing it this method, but curious if it's possible to use the meta coding.

Thanks very much for the help again though.
 

Rink27

Veteran
Veteran
Joined
Jul 18, 2014
Messages
222
Reaction score
13
First Language
English
Primarily Uses
RMMV
Oh, found a bug. It is retrieving all the items. I specified normal items, but it's also retrieving key items from my inventory.

Also, cancelling gives a "cannot read property 'meta' of null".
I think it closes the help window first and then runs into problems.
 
Last edited:

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,956
First Language
English
Primarily Uses
RMMV
Oh sorry, it allowing all items is a holdover from a debugging edit I made that automatically includes everything. I'll fix that.

I don't think that's how the meta property works, as far as I'm aware only $gameMap uses it. You'd have to add the properties to Game_Item; I'll take a look and add a notetag for you to use for help text.

Also, I coded it at 1 line because I wasn't sure how many you needed. If you'd prefer 2 that's fine.

Edit: Here, this should work a bit better. I fixed the item type bug and put in a bit to show you how you can show meta data in your help window without having to create an entirely new help window class.

Code:
//=============================================================================
// RefineWindow.js
//=============================================================================

/*:
 * @plugindesc Refinement window for Rink27
 * @author John Clifford (Trihan)
 *
 * @help
 *
 * Use the plugin command RefineWindow open variableId itemtypeId
 *
 */

(function() {
    var parameters = PluginManager.parameters('RefineWindow');
    
    _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    Game_Interpreter.prototype.pluginCommand = function(command, args) {
        _Game_Interpreter_pluginCommand.call(this, command, args);
        if (command === 'RefineWindow') {
            switch(args[0]) {
                case 'open':
                if (!$gameMessage.isBusy()) {
                    $gameMessage.setRefineChoice(Number(args[1]), Number(args[2]));
                    this.setWaitMode('message');
                }
                break;
            }
        }
    };
    
    function Window_Refine() {
        this.initialize.apply(this, arguments);
    }
    
    Window_Refine.prototype = Object.create(Window_EventItem.prototype);
    Window_Refine.prototype.constructor = Window_Refine;
    
    Window_Refine.prototype.initialize = function(messageWindow) {
        Window_EventItem.prototype.initialize.call(this, messageWindow);
    };
    
    Window_Refine.prototype.updatePlacement = function() {
        this.y = this.fittingHeight(2);
    };
    
    Window_Refine.prototype.updateHelp = function() {
        this._helpWindow.setText(this.item() ? this.item().meta.refined_resource : '');
    };
    
    Window_Refine.prototype.includes = function(item) {
        var itypeId = $gameMessage.refineChoiceItypeId();
        return DataManager.isItem(item) && item.itypeId === itypeId;
    };
    
    Window_Refine.prototype.onOk = function() {
        var item = this.item();
        var itemId = item ? item.id : 0;
        $gameVariables.setValue($gameMessage.refineChoiceVariableId(), itemId);
        this._messageWindow.terminateMessage();
        this._helpWindow.hide();
        this.close();
    };
    
    Window_Refine.prototype.onCancel = function() {
        $gameVariables.setValue($gameMessage.refineChoiceVariableId(), 0);
        this._messageWindow.terminateMessage();
        this._helpWindow.hide();
        this.close();
    };
    
    _Window_Message_subWindows = Window_Message.prototype.subWindows;
    Window_Message.prototype.subWindows = function() {
        var subWindows = _Window_Message_subWindows.call(this);
        subWindows.push(this._refineWindow);
        subWindows.push(this._refineHelpWindow);
        return subWindows;
    };
    
    _Window_Message_createSubWindows = Window_Message.prototype.createSubWindows;
    Window_Message.prototype.createSubWindows = function() {
        _Window_Message_createSubWindows.call(this);
        this._refineWindow = new Window_Refine(this);
        this._refineHelpWindow = new Window_Help(2);
        this._refineWindow.setHelpWindow(this._refineHelpWindow);
        this._refineHelpWindow.hide();
    };
    
    _Window_Message_isAnySubWindowActive = Window_Message.prototype.isAnySubWindowActive;
    Window_Message.prototype.isAnySubWindowActive = function() {
        return (this._refineWindow.active || _Window_Message_isAnySubWindowActive.call(this));
    };
    
    _Window_Message_startInput = Window_Message.prototype.startInput;
    Window_Message.prototype.startInput = function() {
        if ($gameMessage.isRefine()) {
            this._refineWindow.start();
            this._refineHelpWindow.show();
            return true;
        } else {
            _Window_Message_startInput.call(this);
        }
    };
    
    _Game_Message_clear = Game_Message.prototype.clear;
    Game_Message.prototype.clear = function() {
        _Game_Message_clear.call(this);
        this._refineChoiceVariableId = 0;
    };
    
    Game_Message.prototype.refineChoiceVariableId = function() {
        return this._refineChoiceVariableId;
    };
    
    Game_Message.prototype.refineChoiceItypeId = function() {
        return this._refineChoiceItypeId;
    };
    
    Game_Message.prototype.setRefineChoice = function(variableId, itemType) {
        this._refineChoiceVariableId = variableId;
        this._refineChoiceItypeId = itemType;
    };
    
    Game_Message.prototype.isRefine = function() {
        return this._refineChoiceVariableId > 0;
    };
    
    _Game_Message_isBusy = Game_Message.prototype.isBusy;
    Game_Message.prototype.isBusy = function() {
        return this.isRefine() || _Game_Message_isBusy.call(this);
    };
})();
 
Last edited:

Rink27

Veteran
Veteran
Joined
Jul 18, 2014
Messages
222
Reaction score
13
First Language
English
Primarily Uses
RMMV
Oh sorry, it allowing all items is a holdover from a debugging edit I made that automatically includes everything. I'll fix that.

I don't think that's how the meta property works, as far as I'm aware only $gameMap uses it. You'd have to add the properties to Game_Item; I'll take a look and add a notetag for you to use for help text.

Also, I coded it at 1 line because I wasn't sure how many you needed. If you'd prefer 2 that's fine.

Edit: Here, this should work a bit better. I fixed the item type bug and put in a bit to show you how you can show meta data in your help window without having to create an entirely new help window class.
It's no problem. Your assistance has been greatly appreciated so I don't mind the problems. And alright, I see the changes. Also, I figured out my cannot read property 'meta' of null error. My eventing was running into problems because the refineChoiceVariableId is set to 0 in the plugin upon being cancelled so I just included a conditional check for that.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,956
First Language
English
Primarily Uses
RMMV
So is that it doing everything you need now or do you need further assistance?
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Why is there so much month left at the end of money? D=
Hello humans! How goes your day in this journey of living? I hope it is good, for I am human like you, and I am feeling great! Worship the altar.
Sand is basically small rocks

Forum statistics

Threads
105,624
Messages
1,015,036
Members
137,285
Latest member
AndrewRobertson
Top