public

Rpg Maker Developers Group

Simple enough for a child, powerful enough for a developer

2 Followers

Strange thing happened when Custom Window_Command

BMM Archive · July 15, 2026

Preserved forum archive. This topic stores the original first post and locally mirrored RPG Maker Web attachments when available. It is posted by the BMMPlay archive account, not by the original creator.

Original Source

  • Original title: Strange thing happened when Custom Window_Command
  • Original author: SoraShiro
  • Original date: December 2, 2017
  • Source thread: https://forums.rpgmakerweb.com/threads/strange-thing-happened-when-custom-window_command.87994/
  • Source forum path: Game Development Engines > RPG Maker Javascript Plugins > Javascript/Plugin Support

Summary

Hello everyone, I'm a beginner of RMMV v1.5.1. Recently I want to custom a Command Menu, so I inherit the Window_Command class.[^1] The menu named Window_SlotCommand , it has a dynamic height, which is controlled by a variable named _IModuleSlot . If _IModuleSlot isn't null, the command list's length should be 2, or it should be 1. So here is the code, or you can see in here, ← DropBox:

Archived First Post

Hello everyone, I'm a beginner of RMMV v1.5.1.
Recently I want to custom a Command Menu, so I inherit the Window_Command class.[^1]

The menu named Window_SlotCommand , it has a dynamic height, which is controlled by a variable named _IModuleSlot . If _IModuleSlot isn't null, the command list's length should be 2, or it should be 1.
So here is the code, or you can see in here, ← DropBox:

//=============================================================================
// Command Issue
// SoraShiro_CommandIssue.js
//=============================================================================

var Sora = Sora || {};
Sora.CommandIssue = Sora.CommandIssue || {};
Sora.CommandIssue.version = 1.00;


//=============================================================================
// Scene_Menu
//=============================================================================

Sora.CommandIssue.Scene_Menu_create = Scene_Menu.prototype.create;
Scene_Menu.prototype.create = function () {
Sora.CommandIssue.Scene_Menu_create.call(this);
this.createSlotCommandWindow();​
};

Sora.CommandIssue.Scene_Menu_createCommandWindow = Scene_Menu.prototype.createCommandWindow;
Scene_Menu.prototype.createCommandWindow = function () {
this._commandWindow = new Window_MenuCommand(0, 0);
this._commandWindow.setHandler('strange', this.onSlotSelect.bind(this));
this._commandWindow.setHandler('item', this.commandItem.bind(this));
this._commandWindow.setHandler('skill', this.commandPersonal.bind(this));
this._commandWindow.setHandler('equip', this.commandPersonal.bind(this));
this._commandWindow.setHandler('status', this.commandPersonal.bind(this));
this._commandWindow.setHandler('formation', this.commandFormation.bind(this));
this._commandWindow.setHandler('options', this.commandOptions.bind(this));
this._commandWindow.setHandler('save', this.commandSave.bind(this));
this._commandWindow.setHandler('gameEnd', this.commandGameEnd.bind(this));
this._commandWindow.setHandler('cancel', this.popScene.bind(this));
this.addWindow(this._commandWindow);​
};

var $increase = 1;

Scene_Menu.prototype.onSlotSelect = function () {
$increase++;
if($increase % 2 === 0) {
var s = {};
this._slotCommandWindow.setIModuleSlot(s);​
} else {
this._slotCommandWindow.setIModuleSlot(null);​
}
// Move Window
this._slotCommandWindow.move(0, 0,
this._slotCommandWindow.windowWidth(),
this._slotCommandWindow.windowHeight());
this._slotCommandWindow.select(0);
this._slotCommandWindow.activate();
this._slotCommandWindow.show();​
}

Scene_Menu.prototype.createSlotCommandWindow = function () {
this._slotCommandWindow = new Window_SlotCommand();
this._slotCommandWindow.setHandler('cancel', this.onSlotCommandCancel.bind(this));
this._slotCommandWindow.hide();

this.addWindow(this._slotCommandWindow);​
}

Scene_Menu.prototype.onSlotCommandCancel = function () {
this._slotCommandWindow.deactivate();
this._slotCommandWindow.hide();
this._commandWindow.activate();​
}

//=============================================================================
// Window_MenuCommand
//=============================================================================

Sora.CommandIssue.Window_MenuCommand_addOriginalCommands = Window_MenuCommand.prototype.addOriginalCommands;
Window_MenuCommand.prototype.addOriginalCommands = function () {
Sora.CommandIssue.Window_MenuCommand_addOriginalCommands.call(this);
this.addCommand('Strange Thing', 'strange', true);​
}

//=============================================================================
// Slot Command Window
//=============================================================================

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

Window_SlotCommand.prototype = Object.create(Window_Command.prototype);
Window_SlotCommand.prototype.constructor = Window_SlotCommand;

Window_SlotCommand.prototype.initialize = function() {
Window_Command.prototype.initialize.call(this, 0, 0);
this._IModuleSlot = null;​
};

Window_SlotCommand.prototype.windowHeight = function () {
var result = this.fittingHeight(this.numVisibleRows());
console.log(result);
return result;
// return 72;
// return 108;
}

Window_SlotCommand.prototype.maxCols = function() {
return 1;​
};

Window_SlotCommand.prototype.setIModuleSlot = function(slot) {
this._IModuleSlot = slot;
this.refresh();​
}

Window_SlotCommand.prototype.makeCommandList = function() {
if(this._IModuleSlot) {
this.addCommand('Change', 'change', true);
this.addCommand('Remove', 'remove', true);​
} else {
this.addCommand('Add', 'add', true);​
}​
}

Window_SlotCommand.prototype.refresh = function() {
this.clearCommandList();
this.makeCommandList();
this.contents.clear();
this.drawAllItems();​
}

Window_SlotCommand.prototype.update = function () {
Window_Command.prototype.update.call(this);​
}

As you can see, setIModuleSlot() function is used to control the _IModuleSlot, and every time we show _slotCommandWindow, it will display two kinds of command list alternately.

But strange thing then happened. When I run this code in the new game project, it appeared like this:
photo_left_1 photo_right_1
The left condition is displaying incompletely!
But if I change Window_SlotCommand.prototype.windowHeight return constant value, like 108 or 72, which is the fittingHeight() function had calculated actually and also is logged by console.log() function, displaying is different!
photo_left_2 photo_right_2
This time both condition is displaying completely!

I tried other dynamic height such as 2&3, 3&2(which can exclude the order factor at the window first created), it showed the same phenomenon that the long condition will displaying incompletely if I use calculated value.

SO WHY? It makes no sense that constant value and calculated value results to different display phenomenon! I thought JavaScript maybe do some wrong stuff, but now I think maybe the RGSS Engine doesn't work well with JavaScript, if RGSS Engine is not writen by JavaScript in its foundation.

Any suggestions will be grateful, thanks.

- - -

[^1]: Although Js didn't have a Class concept, I prefer to use Class to describe my question

Downloads / Referenced Files

Log in to download

Log in, then follow the RPG Maker Developers Group to see these download links.

Log in to download
Creator Claims / Removal

If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.

#039#rpg-maker-archive#js-support

Replies (0)

No replies yet.

0 replies 1 view

Log in to reply.

User Avatar