Hey, I am trying to create a Window_Selectable on RPG Maker MZ, and cannot for the life of me get it to work. The items show up, and the first item is selected, then I can't move the keys to get them to change selection...Here's the code. This is from this "tutorial":
JavaScript:
var params = PluginManager.parameters("CustomMenu");
Input.keyMapper["80"] = "customMenu";
_alias_scene_map_update = Scene_Map.prototype.update;
Scene_Map.prototype.update = function() {
_alias_scene_map_update.call(this);
if(Input.isTriggered("customMenu")) SceneManager.push(Scene_CustomMenu);
};
function Scene_CustomMenu() {
this.initialize.apply(this, arguments);
}
Scene_CustomMenu.prototype = Object.create(Scene_MenuBase.prototype);
Scene_CustomMenu.prototype.constructor = Scene_CustomMenu;
Scene_CustomMenu.prototype.initialize = function() {
ImageManager.loadFace("Actor3");
ImageManager.loadCharacter("People1")
Scene_Base.prototype.initialize.call(this);
};
Scene_CustomMenu.prototype.create = function() {
//Scene for Data display
Scene_MenuBase.prototype.create.call(this);
this._customWindow = new Window_Custom(Graphics.boxWidth/3, Graphics.boxHeight/10,(Graphics.boxWidth / 3)*2,(Graphics.boxHeight/10)*9)
this.addWindow(this._customWindow);
this._collectiblesTitle = new Window_CollectiblesTitle(0, 0,Graphics.boxWidth,Graphics.boxHeight/10)
this.addWindow(this._collectiblesTitle);
//Scene for choosing a collectible
this._customSelectableWindow = new Window_CustomSelectable(0,Graphics.boxHeight/10,Graphics.boxWidth/3,(Graphics.boxHeight/10)*9)
this._customSelectableWindow.select(0);
this._customSelectableWindow.activate();
//this._customSelectableWindow.setHandler("ok", this.command1.bind(this));
this._customSelectableWindow.setHandler("cancel",this.popScene.bind(this));
this.addWindow (this._customSelectableWindow);
}
Scene_CustomMenu.prototype.command1 = function () {
this._customSelectableWindow.activate();
$gameVariables.setValue(1, $gameVariables.value(1) + 1);
}
Scene_CustomMenu.prototype.start = function() {
Scene_MenuBase.prototype.start.call(this);
this._customWindow.drawAllItems();
this._customSelectableWindow.refresh();
}
Scene_CustomMenu.prototype.update = function() {
if(Input.isTriggered("cancel")) SceneManager.pop();
}
//Window Custom
function Window_Custom() {
this.initialize.apply(this, arguments);
}
Window_Custom.prototype = Object.create(Window_Base.prototype);
Window_Custom.prototype.constructor = Window_Custom;
Window_Custom.prototype.initialize = function(x, y, width, height) {
Window_Base.prototype.initialize.call(this, new Rectangle(x,y,width,height));
this.drawAllItems();
}
Window_Custom.prototype.drawAllItems = function() {
this.drawText($gameVariables.value(2), 0, 0, this.width - this.padding * 2, "center");
this.drawIcon(45, 48, 48);
this.drawFace("Actor3", 5, 96, 42, 148, 148);
this.drawCharacter("People1", 0, this.padding, this.padding + 96);
//this.drawGauge(0,0,100,1,"#ff0000", "#00ff00")
}
//Window Collectibles Title
function Window_CollectiblesTitle() {
this.initialize.apply(this,arguments)
}
Window_CollectiblesTitle.prototype = Object.create(Window_Base.prototype);
Window_CollectiblesTitle.prototype.constructor = Window_Custom;
Window_CollectiblesTitle.prototype.initialize = function(x, y, width, height) {
Window_Base.prototype.initialize.call(this, new Rectangle(x,y,width,height));
this.drawAllItems();
}
Window_CollectiblesTitle.prototype.drawAllItems = function() {
this.drawText(params["Collectible Title"], 0, 0, this.width - this.padding * 2, "center");
}
//Window Custom Selectable
function Window_CustomSelectable () {
this.initialize.apply (this, arguments);
}
Window_CustomSelectable.prototype = Object.create (Window_Selectable.prototype);
Window_CustomSelectable.prototype.constructor = Window_Selectable;
Window_CustomSelectable.prototype.initialize = function (x, y, width, height) {
Window_Selectable.prototype.initialize.call(this,new Rectangle(x, y, width, height));
this.refresh();
//this.hide();
}
Window_CustomSelectable.prototype.maxItems = function () {
return 3;
}
Window_CustomSelectable.prototype.maxPageRows = function () {
return 2;
}
Window_CustomSelectable.prototype.maxPageItems = function () {
return this.maxPageRows() * this.maxCols();
}
Window_CustomSelectable.prototype.drawItem = function(index) {
console.log("Item being drawn");
var itemRect = this.itemRect(index);
this.drawText("text " + index, itemRect.x, itemRect.y, itemRect.width / 2, itemRect.height / 2, 'center');
};