RMMZ SOLVED! Help with Window_selectable on scroll making items of undefined.

rexie09

Villager
Member
Joined
Apr 4, 2021
Messages
26
Reaction score
10
First Language
English
Primarily Uses
RMMZ
I am learning how rpg maker makes windows and upon trying to make a selectable window that scrolls once the window starts scrolling and you press the up or down arrow the game proceeds to make a bunch of items with the text undefined.
I was wondering how to stop this and get the window to continue scrolling to the bottom of the choices then return to the top.
Here is the plugin code
JavaScript:
/**
* * @target MZ
*/

"use strict"

var Rexie09 = Rexie09 || {};
var Imported = Imported || {};
Rexie09.Window_Test = Rexie09.Window_Test || {};

var windowWidth = Graphics.width


class Rexie09_DescriptWindow extends Window_Base {
    constructor() {
        super(new Rectangle(240, 0, Graphics.boxWidth - 240, Graphics.boxHeight));
    }

}class Rexie09_CommandWindow extends Window_Selectable {
    constructor() {
        super(new Rectangle(0, 0, 240, Graphics.boxHeight));
        this._index = 0;
        this.totalItems = 0;
        this.mainClick = false;
        this.setHandler("ok", this.onActorOk.bind(this));
        this.setHandler("cancel", this.onActorCancel.bind(this));
    }

    maxItems() {
        return this.totalItems;
    }
   
   maxPageRows() {
        return 1;
    }
   
    maxPageItems() {
        return this.maxPageRows() * this.maxCols();
    }
   
    drawItem(index, text) {
        console.log("Item being drawn");
        var itemRect = this.itemRect(index);
        this.drawText(text, itemRect.x + 5, itemRect.y + 3, 200, 'center');
        this.totalItems ++;
    }

    clickedMain() {
        this.mainClick = true;
        this.drawItem(this._index + 1, "test 1");
        this.drawItem(this._index + 2, "test 2");
        this.drawItem(this._index + 3, "test 3");
        this.drawItem(this._index + 4, "test 1");
        this.drawItem(this._index + 5, "test 2");
        this.drawItem(this._index + 6, "test 3");
        this.drawItem(this._index + 7, "test 1");
        this.drawItem(this._index + 8, "test 2");
        this.drawItem(this._index + 9, "test 3");
        this.drawItem(this._index + 10, "test 1");
        this.drawItem(this._index + 11, "test 2");
        this.drawItem(this._index + 12, "test 3");
        this.drawItem(this._index + 13, "test 1");
        this.drawItem(this._index + 14, "test 2");
        this.drawItem(this._index + 15, "test 3");
        this.drawItem(this._index + 16, "test 1");
        this.drawItem(this._index + 17, "test 2");
        this.drawItem(this._index + 18, "test 3");
        console.log(this);
    }

    select(index) {
        super.select(index);
       
    }

    processOk() {
        if (this.isCurrentItemEnabled()) {
          console.log("Hello")
          this.playOkSound();
          this.updateInputData();
          this.callOkHandler();
        } else {
          this.playBuzzerSound();
        }
      }

    onActorOk() {
    if (this._index == 0 && this.mainClick == false) {
        this.clickedMain();
    } else {
        SoundManager.playBuzzer();
        }
    }
   
    onActorCancel() {
        this.deactivate
    }
}


//test function for the windows
function make_ShowWindow () {
    if(SceneManager._scene instanceof Scene_Title){
        console.log("WOW man it works");
    }
    let apples = new Rexie09_DescriptWindow();
    let apes = new Rexie09_CommandWindow();
    console.log(apples);
    console.log(apes);
    apes.activate();
    apes.drawItem(0, "Get the apples for the hunter");

    SceneManager._scene.addWindow(apples);
    SceneManager._scene.addWindow(apes);

}

and here is a gif of what is happening
ezgif.com-gif-maker.gif
 

Jragyn

JABS codemonkey
Veteran
Joined
Aug 14, 2012
Messages
230
Reaction score
186
First Language
English
Primarily Uses
RMMZ
I've found that in most cases, if I'm trying to make a list of windows, I extend Window_Command instead of Window_Selectable.

If I had to guess, it is probably it is related to your explicit management of the different items being rendered into the list. If you extend Window_Command (maybe Window_Selectable has it too?) you can leverage it's built in command management and just use Window_Command.prototype.addCommand (name, symbol, enabled, ext) to add commands pretty easily.

If you spin up a custom scene to handle the management of your windows, you'll also be able to add proper handling for your windows through the patterns that RMMZ already uses (like choosing a command or window navigation). I'd recommend against trying to build a Scene within Scene_Map, it gets kinda messy pretty fast.
 

rexie09

Villager
Member
Joined
Apr 4, 2021
Messages
26
Reaction score
10
First Language
English
Primarily Uses
RMMZ
I've found that in most cases, if I'm trying to make a list of windows, I extend Window_Command instead of Window_Selectable.

If I had to guess, it is probably it is related to your explicit management of the different items being rendered into the list. If you extend Window_Command (maybe Window_Selectable has it too?) you can leverage it's built in command management and just use Window_Command.prototype.addCommand (name, symbol, enabled, ext) to add commands pretty easily.

If you spin up a custom scene to handle the management of your windows, you'll also be able to add proper handling for your windows through the patterns that RMMZ already uses (like choosing a command or window navigation). I'd recommend against trying to build a Scene within Scene_Map, it gets kinda messy pretty fast.
Thank you extending Window_command works well and has no issue with scrolling and as for making a new scene i will now since i got the window i wanted to figure out first working.
 

Latest Threads

Latest Profile Posts

I decided to reinstall one of my most favourite game of all times, Gothic 2. Time to get back to Khorinis!
So much game make... I needs to rest. The foods call.
-Casino with bunnysuit green check.png
1638563168795.png
Monday December 6th 2021 at 7PM Hawkzombie will stream A Thief's Voyage on his Twitch.

Hawkzombie Twitch

Check it out.​
Ladies and gentlepeeps, I'm working on a Chuck E Cheese horror game! Did you know that in the 80's, in the Pizza Time Theater, Helen Henny was a separate character who performed in a separate room called the Cabaret? She was one of the possible guest stars there, and she was a Hollywood star at the time. But this particular unit seems to have a dark secret...

Forum statistics

Threads
117,161
Messages
1,105,052
Members
153,244
Latest member
MLC
Top