[js] Message from Plugin Scene not showing correctly?

Hello everyone,

I'm currently writing a plugin for a friend of mine, but I've run into problems.

I have a pretty straightforward scene (which inherits from Scene_MenuBase) with a few windows in it.

Now I wanted to show a message (I'm trying to tell the player why he can't choose the option he just tried to choose, in this case, but I'm sure I will need this function for other stuff in the future too.) inside of that scene.

I tried the following code:

$gameMessage.clear();$gameMessage.setBackground(1);$gameMessage.setPositionType(1);$gameMessage.add("Message to the player here...");The code gets executed almost correctly. The problem is, that the message is only shown after I pop my scene!

I figured that the Scene_Map does something that my scene does not, hence it showing the message-box only when I return to that scene, so I looked and realised that Scene_Map and Scene_Battle both have Window_Message windows.

So I go and create a function that creates this for my scene exactly like the ones Scene_Map and Scene_Battle have and call it in the create function of my scene... but STILL my message-box only opens after I pop my own scene and return to Scene_Map.

I can't find any clue why it's not showing on my scene...

Anyone knows what I am doing wrong?

I didn't post any of my code, because I know all the functions I wrote are beeing executed (tested it by throwing local variables of these functions in "console.log()", and they always were as expected. I even compared the Window_Message from my scene with the one from Scene_Map and I couldn't find any difference except the variables "_animationCount" and "stage")

Kinda going crazy here, because I can't see why it is working on Scene_Map and Scene_Battle but not in my custom scene...

I'm thankful for anyone trying to help.
I've moved this thread to Learning Javascript. Please be sure to post your threads in the correct forum next time. Thank you.
Yeah sorry, I realised I was in the wrong forum after posting. Thanks for moving.
Scene.prototype.create = function() { Scene_MenuBase.prototype.create.call(this); this.createAllWindows(); }; Scene.prototype.createAllWindows = function() { this.createMessageWindow(); }; Scene.prototype.createMessageWindow = function() { this._messageWindow = new Window_Message(); this.addWindow(this._messageWindow); this._messageWindow.subWindows().forEach(function(window) { this.addWindow(window); }, this); };Should be all you need. Then of course $gameMessage.add("text")
Yeah that's what I did. And I just found the mistake.

I added the Window_Message before adding my own windows. I had to add it after them...

I know got another problem though.

When I want to dismiss the message my own window still has the focus, so I'm cancelling it instead of the message-box.

Is there a way to set focus to that Window_Message, to prevent my own window (and therefore my scene) to cancel?
Hmmm, from the top of my head you could deactivate the current window just before the add the $gameMessage then in your update you can check if the $gameMessage is busy or not, once it is not busy(closed) you could then reactivate the window.
My first guess also was to deactivate the current window. But for some reason the window (inherits from "Window_Selectable") doesn't react to deactivate(). It's property active doesn't get changed to false, it keeps beeing true.

Edit: Oh wait, I think I found the error, let me check.

Edit2: Okay, I activated it again a few lines later, that was the problem... But deactivated windows don't run update, right? so where do I check $gameMessage.isBusy now?
myScene.prototype.update = function() { Scene_Base.prototype.update.call(this); if(!this.isBusy() && !this.myWindow.active){ this.myWindow.activate(); };}; myScene.prototype.isBusy = function(){ return $gameMessage.isBusy();};With out seeing the code or purpose of the scene it is difficult to give advice. The above code will activate the window if the game message is not playing and the window was inactive.
Well, I should've known that Scene_Base also has an update function...

Anyway, that works perfectly, big thanks to you!

Original thread: https://forums.rpgmakerweb.com/threads/js-message-from-plugin-scene-not-showing-correctly.53474/