I'm creating a very simple plugin as a way to learn javascript applied to RMMV, and I've run into a few issues.
My purpose is to show a small "Yes or No" command window during battle after every actor has selected an action, as a way to ask the player for a final confirmation before the skills they selected are executed. I plan on showing them additional info with this window, but for now I just made the commands and nothing else.
I managed to write code that creates and shows the window at the appropiate time, but the problem now is that I don't know how to make the game stop and wait for player input. Right now the window appears but the battle flow continues as usual, and I can select commands in the window but it doesn't accept any input until the actions are over and the input phase begins again.
TL;DR What do I need to do so the game waits for input while a window is on screen?
Here's my current code:
My purpose is to show a small "Yes or No" command window during battle after every actor has selected an action, as a way to ask the player for a final confirmation before the skills they selected are executed. I plan on showing them additional info with this window, but for now I just made the commands and nothing else.
I managed to write code that creates and shows the window at the appropiate time, but the problem now is that I don't know how to make the game stop and wait for player input. Right now the window appears but the battle flow continues as usual, and I can select commands in the window but it doesn't accept any input until the actions are over and the input phase begins again.
TL;DR What do I need to do so the game waits for input while a window is on screen?
Here's my current code:
JavaScript:
// New Window · Window_Confirm
function Window_Confirm() {
this.initialize.apply(this, arguments);
}
Window_Confirm.prototype = Object.create(Window_Command.prototype);
Window_Confirm.prototype.constructor = Window_Confirm;
Window_Confirm.prototype.initialize = function() {
Window_Command.prototype.initialize.call(this, 0, 0);
this.x = (Graphics.boxWidth - this.width) / 2;
this.y = (Graphics.boxHeight - this.height) / 2;
this.close();
};
Window_Confirm.prototype.makeCommandList = function() {
this.addCommand("Yes", 'confirmYes');
this.addCommand("No", 'confirmNo');
};
// Scene_Battle Aliases
var _dawnAliasBattleCreateAllWindows = Scene_Battle.prototype.createAllWindows;
Scene_Battle.prototype.createAllWindows = function() {
_dawnAliasBattleCreateAllWindows.call(this);
this.createConfirmWindow();
};
Scene_Battle.prototype.createConfirmWindow = function() {
this._confirmWindow = new Window_Confirm();
this._confirmWindow.setHandler('confirmYes', this.commandConfirmYes.bind(this));
this._confirmWindow.setHandler('confirmNo', this.commandConfirmNo.bind(this));
this._confirmWindow.deselect();
this._confirmWindow.deactivate();
this.addWindow(this._confirmWindow);
}
var _dawnAliasBattleEndCommandSelection = Scene_Battle.prototype.endCommandSelection;
Scene_Battle.prototype.endCommandSelection = function() {
_dawnAliasBattleEndCommandSelection.call(this);
this._confirmWindow.activate();
this._confirmWindow.open();
};
// Scene Battle · New Methods
Scene_Battle.prototype.commandConfirmYes = function () {
this._confirmWindow.deactivate();
this._confirmWindow.close();
}
Scene_Battle.prototype.commandConfirmNo = function () {
this._confirmWindow.deactivate();
this._confirmWindow.close();
}