Clicking on an item should open a small command window

Candacis

Pixel Pusher
Restaff
Joined
May 2, 2012
Messages
1,446
Reaction score
1,936
First Language
German
Primarily Uses
So, I'm trying to incorporate something into the item menu, but I don't know where to start. Could someone help me out?
I want, if you click an item (or press enter), that a small command window opens, like right next to the item. I want to incorporate maybe 4 commands in a vertical list, but right now I'm struggling to even get that window to show up. If that command window is up, you can select one of the commands (like use, equip or something like that) or with the Cancel function, close the command window again.
How would I do that?
 

JGreene

Veteran
Veteran
Joined
Oct 24, 2015
Messages
375
Reaction score
289
First Language
English
Primarily Uses
RMMV
You could possibly start by looking at the code for SRD's Skill Extender. That's the only plugin I know of that does something similar (even though it's meant for skills).
 

Joy Diamond

Talkative
Veteran
Joined
Nov 12, 2017
Messages
135
Reaction score
173
First Language
English
Primarily Uses
RMMV
So, I'm trying to incorporate something into the item menu, but I don't know where to start. Could someone help me out?
It would really help if you could give a few sentences describing your skills.

For example:
  • How well do you know JavaScript?
    • Can you read it?
    • Can you write it?
  • Do you know how to use plugins?
    • Can you follow the advice above from @JGreene to "looking at the code for SRD's Skill Extender"?
Hopefully that gives you an idea what I am asking.

We need to understand your skills, in order to give an answer that is useful to you.
 

luizcubas

Veteran
Veteran
Joined
Oct 7, 2015
Messages
30
Reaction score
58
First Language
Pt-BR
Primarily Uses
RMMV
Understanding the code of the Windows in MV was very hard, at least for me.

First you need to create your new window with your new features, for illustration, I'm creating a Confirm window, with options Confirm and Cancel:

Using the Window_Command as parent Class, I create the Window_GameConfirm:
Code:
//##Creating the class
function Window_GameConfirm() {
  this.initialize.apply(this, arguments);
}

//##Setting the inheritance of the Window_Command class
Window_GameConfirm.prototype = Object.create(Window_Command.prototype);
Window_GameConfirm.prototype.constructor = Window_Command;

//Rewriting this function for setting my desired width of the Window
Window_GameConfirm.prototype.windowWidth = function() {
  return 450;
};

//Rewriting this function to adjust the height of my Window, using 3 rows
Window_GameConfirm.prototype.windowHeight = function() {
  return this.fittingHeight(3);
};

//Rewriting this function to set the commands of my window
Window_GameConfirm.prototype.makeCommandList = function() {
  this.addCommand("Confirm", 'confirm');
  this.addCommand("Cancel", 'cancel');
};

Note: You can check all the base functions for the parent class I'm using searching for "function Window_Command()" on rpg_windows.js.

Your new windows is ready, but now you need to make it shine, the system that tells the game to open, close or active your window is the Scene of the game, the MV has various Scenes (Scene_Title, Scene_Map, Scene_Item).

In your case, as you say that this will be in Item Window Menu, I think you should use Scene_Item

So, you will need to add some new stuff on Scene_Item:
Code:
var parent_Scene_Item_createItemWindow = Scene_Item.prototype.createItemWindow;
Scene_Item.prototype.createItemWindow = function() {
  //Here will create all already existing windows
  parent_Scene_Item_createItemWindow.call(this);
 
  //And here you gonna create your new custom Window(x and y must be set for your coord on the screen)
  this._myCustomWindow = new Window_GameConfirm(x, y);
   
  //Here you gonna bind the functions that will handle each option in your menu
  this._myCustomWindow.setHandler('confirm',     this.onMyCustomOk.bind(this));
  this._myCustomWindow.setHandler('cancel', this.onMyCustomCancel.bind(this));

  //Here you actually tells the Scene_Item to add your new Window in the drawing process of the scene
  this.addWindow(this._myCustomWindow);
};

You can't forget to add the code of what happens when any of the conditions are selected:
Code:
//Function 
Scene_Item.prototype.onMyCustomOk= function() {
  var item = this.item();
  //Do whaterever you want with the selected Item
}

//Function for closing the Custom Window
Scene_Item.prototype.onMyCustomCancel= function() {
  this._myCustomWindow.deactivate();
  this._myCustomWindow.deselect();
  this._myCustomWindow.hide();
  
  //You need to remember to activete the old Window or 
  // the game will looks likes is frozen
  this._itemWindow.activate();
};

Ok, you new Windows is ready and the Scene should create it when you pop up the Item List Menu, but will not show yet, for this happen, you need to rewrite the exactly code you want to call your new Window.

Assuming you want to pop your new window when you use a Item, you can rewrite this function:

Code:
var parent_Scene_Item_onActionUse = Scene_Item.prototype.onActionUse;
Scene_Item.prototype.onActionUse = function() {

//Here, instead of "== true", you add any condition to show your
//new Window only when it's some special item for instance
if(this.item() == true){
  this._myCustomWindow.show();
  this._myCustomWindow.activate();
  this._myCustomWindow.selectLast();
}else{
  parent_Scene_Item_onActionUse.call(this)
}

Well, that's a lot of things. I really expend a lot of time to understand a bit of how it works, this code is just for illustration, there are probably some errors but I think it will help you a little bit to understand the idea of how MV handles the Window. Cheers!
 

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

Latest Threads

Latest Posts

Latest Profile Posts


The main character of the book)
Things you can say about your rpg maker project but not your bf/gf: I'm not super committed but it's fun to play around with it.
putting a puzzle in my game that BSODs the player's computer if they complete it
I finally got a book out the door after seven years of nothing \^-^/ Now if I can get a game out the door too, that'd be great...

Forum statistics

Threads
94,365
Messages
920,291
Members
124,130
Latest member
jarja2541
Top