RMMZ About Scenes and Windows update function...

PMantis13

Caipirinha lover.
Veteran
Joined
Aug 29, 2020
Messages
31
Reaction score
18
First Language
PT-BR
Primarily Uses
RMMZ
I made a Window for a Scene I created, with an update function like this:
JavaScript:
QuestDetailWindow.prototype.update = function () {
    Window_Base.prototype.update.call(this);
    this.drawAllItems();
}

QuestDetailWindow.prototype.drawAllItems = function () {
    this.drawText('Hello world', 0, 0);
}
Everything works just fine, Hello World displays at the top of my window. Now I've put another update function, but for my Scene:
JavaScript:
QuestScene.prototype.update = function () {
    if (Input.isTriggered('cancel')) {
        SceneManager.pop();
    }
}
The problem is that the update function from the QuestDetailWindow is not being called anymore, so the message Hello World is not being displayed. Is this a common behavior? Can't I have a Scene AND it's Windows updating at the same time?

My workaround for this: calling the update function for the Window inside the Scene update function.
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,625
Reaction score
991
First Language
Portuguese - Br
Primarily Uses
RMMV
Hi!
I think it should work., I mean, with the code you have shown.
JavaScript:
QuestScene.prototype.update = function () {
    // Maybe this had to have a Scene_something.prototype.update()
    if (Input.isTriggered('cancel')) {
        SceneManager.pop();
    }
}
If your scene is inherited from somewhere, I think that is what is being missed.


Can't I have a Scene AND it's Windows updates at the same time?
Yes, you can.

Where you are adding your window? To the QuestScene or SceneMap ?
 

PMantis13

Caipirinha lover.
Veteran
Joined
Aug 29, 2020
Messages
31
Reaction score
18
First Language
PT-BR
Primarily Uses
RMMZ
Hi!
I think it should work., I mean, with the code you have shown.
JavaScript:
QuestScene.prototype.update = function () {
    // Maybe this had to have a Scene_something.prototype.update()
    if (Input.isTriggered('cancel')) {
        SceneManager.pop();
    }
}
If your scene is inherited from somewhere, I think that is what is being missed.



Yes, you can.

Where you are adding your window? To the QuestScene or SceneMap ?
I'm adding the windows to the QuestScene, and then I push it with the SceneManager. If I add what your comment suggested on QuestScene update function, I get an error :(

Well, I solved it by calling the update function for the Window inside the Scene update function. Don't know if that's the best practice for RM, but works good! Thank you, @Eliaquim
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,948
First Language
English
Primarily Uses
RMMV
This is because you've overwritten the default update function of your scene but aren't calling the super in it, so all update is doing is whatever you've written. You need to preface your if statement with a call to the base class update function, same as you did with the window.

It's bad form to resolve this with what you've done, because there will still be other base update stuff that's not being done.
 

PMantis13

Caipirinha lover.
Veteran
Joined
Aug 29, 2020
Messages
31
Reaction score
18
First Language
PT-BR
Primarily Uses
RMMZ
Maybe I did something wrong. I'll post my Scene and Windows in the current state:

JavaScript:
/** -----------------------------------------------------------
* Quest Scene
*/
function QuestScene() {
    this.initialize(...arguments);
}
QuestScene.prototype = Object.create(Scene_MenuBase.prototype);
QuestScene.prototype.constructor = QuestScene;
QuestScene.prototype.initialize = function () {
    Scene_MenuBase.prototype.initialize.call(this);
};
QuestScene.prototype.create = function (quest) {
    this.selectedQuest = quest;
    Scene_MenuBase.prototype.create.call(this);
  
    this.questListWindow = new QuestListWindow(
        new Rectangle(0, this.buttonAreaHeight(), Graphics.boxWidth / 3, Graphics.boxHeight - this.buttonAreaHeight()));
    this.questDetailsWindow = new QuestDetailWindow(
        new Rectangle(Graphics.boxWidth / 3, this.buttonAreaHeight(), (Graphics.boxWidth / 3) * 2, Graphics.boxHeight - this.buttonAreaHeight()));
    this.addWindow(this.questListWindow);
    this.addWindow(this.questDetailsWindow);
}
QuestScene.prototype.update = function () {
    if (Input.isTriggered('cancel')) {
        SceneManager.pop();
    }
    this.questListWindow.update(); // this is my workaround
    this.questDetailsWindow.update(this.selectedQuest); // this is my workaround
}
/** -----------------------------------------------------------
* Quest List Window
*/
function QuestListWindow() {
    this.initialize(...arguments);
}
QuestListWindow.prototype = Object.create(Window_Command.prototype);
QuestListWindow.prototype.constructor = QuestListWindow;
QuestListWindow.prototype.initialize = function (rect) {
    Window_Command.prototype.initialize.call(this, rect);
}
QuestListWindow.prototype.update = function () {
    Window_Command.prototype.update.call(this);
}
QuestListWindow.prototype.makeCommandList = function () {
    for(var i = 0; i <=20 ; i++) {
        this.addCommand("Yes", '');
    }
};

/** -----------------------------------------------------------
* Quest Detail Window
*/
function QuestDetailWindow() {
    this.initialize(...arguments);
}
QuestDetailWindow.prototype = Object.create(Window_Base.prototype);
QuestDetailWindow.prototype.constructor = QuestDetailWindow;
QuestDetailWindow.prototype.initialize = function (rect) {
    Window_Base.prototype.initialize.call(this, rect);
}
QuestDetailWindow.prototype.update = function (quest) {
    Window_Base.prototype.update.call(this);
    this.drawAllItems(quest);
}
QuestDetailWindow.prototype.drawAllItems = function () {
    this.drawText('Hello world', 0, 0);
}
As I said, it only happens when I override the update function on the Scene. If I delete that snippet, Windows get to update normally again.
 
Last edited:

PMantis13

Caipirinha lover.
Veteran
Joined
Aug 29, 2020
Messages
31
Reaction score
18
First Language
PT-BR
Primarily Uses
RMMZ
This is because you've overwritten the default update function of your scene but aren't calling the super in it, so all update is doing is whatever you've written. You need to preface your if statement with a call to the base class update function, same as you did with the window.

It's bad form to resolve this with what you've done, because there will still be other base update stuff that's not being done.
You guys are awesome! I was calling Scene_MenuBase.prototype.update() instead of Scene_MenuBase.prototype.update.call(this). It worked like a charm! Thank you @Trihan and @Eliaquim !
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Here's the title-screen for the game I'm working on: :LZSgrin:
Oh man I've been struggling with event spawners and Qmovement compatibility for quite a while- went as far as to use a tool just to pick crops :kaocry: but Ritter got their spawner to work with Qmove and I'm screeing! It's still in testing period but just- the feeling of getting over a large gameplay hurdle is a HUGE relief, I'm so thankful to Ritter! It's a cheap paid plugin but totally worth it!
Welp, I just finished my favorite part of RPG making which is creating skills, now onto the tasks I like less so the motivation is lower. At least I'll get to create new ones while designing enemies!
New to MV... Awesome forum, cheers everyone.

Forum statistics

Threads
104,653
Messages
1,007,877
Members
136,143
Latest member
idotine
Top