RMMZ Cannot get my Window_Selectable to work

florodude

Crucible Gaming
Member
Joined
Jul 7, 2014
Messages
15
Reaction score
18
First Language
English
Primarily Uses
RMMZ
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');
};
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,936
Reaction score
1,386
First Language
EN
Primarily Uses
RMMZ
There might be other errors, but it looks like you've forgotten to include this line in your scene's update method:
JavaScript:
Scene_MenuBase.prototype.update.call(this);
 

Galv

Veteran
Veteran
Joined
Oct 1, 2012
Messages
1,273
Reaction score
1,525
First Language
English
Primarily Uses
RMMZ
Code:
Scene_CustomMenu.prototype.update = function() {
    if(Input.isTriggered("cancel")) SceneManager.pop();
}
This is overwriting the Scene_MenuBase.prototype.update function, which controls the functionality you are missing.

You could add that in like:
Code:
Scene_CustomMenu.prototype.update = function() {
    Scene_MenuBase.prototype.update.call(this); // Run those updates
    if(Input.isTriggered("cancel")) SceneManager.pop();
}
 

florodude

Crucible Gaming
Member
Joined
Jul 7, 2014
Messages
15
Reaction score
18
First Language
English
Primarily Uses
RMMZ
This is it! Thank you both, can't believe I forgot that! I thought for sure it had to be somewhere in the Window_Selectable code...
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Officially not a mod anymore. Thanks for the many years!
Thinking if i should post on the classifieds section...
Made another plugin showcase video! :kaojoy:
(Plugins and details inside the description of the YouTube video.) :LZScheeze:
Ami
Castle is my Biggest Fear :kaodes:. I just Managed make Part by Part (like the Entrance only),not the Entire Castle like in the RM Sample...
This video really speaks to me...

Forum statistics

Threads
104,371
Messages
1,005,900
Members
135,892
Latest member
Duskpyx
Top