MZ Put a Wait between Windows / Scenes

Hello! Good evening, you see, I'm trying to make a Delay in the appearance of Scenes (Or in the Change between them) but I can't get the Loop to work, the game crashes as soon as the count starts I think, but if I remove it, the Appearance is almost instantaneous, I would like to have a spacing of at least two seconds.
The code that I attached in Spoiler is the step prior to the Appearance of said Scene (Which is Name Input, but I renamed it so as not to interfere with the Original).
Spoiler: CODE
JavaScript:
Game_Party.prototype.callRenameScene = function(actor){
for (wait = 0; wait < 60;) {
   if (wait == 60) {
    const scene = Scene_Rename;
    const max_name_chars = Kaltias.MaxNameChars;
    const scenesToBoot = [{scene,prep:[actor, max_name_chars]}];
    $gameTemp.bootRequiredScenes(scenesToBoot);
   } else {
   wait = + 1
  }
 }
}
(Yes, I know my code sucks, but I'm still trying u.u)

I attach a video in which you can see how quickly the Window appears.


I hope you can help me, I thank you in advance.
your problem is that a correct wait doesn't work as you assumed it would.

There is a main game loop that activates once per frame or sixty times per second in the normal case.
your code for wait is an absolute code, which stops everything else from updating while it is waiting - and that is bad because the other updates in the main loop are neccessary.

What you need to do is the same as the event command wait, which simply tells the engine to skip processing this event for x iterations of the main loop.
That will require an entirely different approach to coding.
JavaScript:
Game_Party.prototype.callRenameScene = function(actor){
for (wait = 0; wait < 60;) {
   if (wait == 60) {
    ...
   } else {
   wait = + 1
  }

This is an infinite loop.

You mean to say wait += 1 which is a single operator with no space in between the two symbols.

By putting them in the wrong order and putting a space between, what's happening is every time through the loop it's setting wait equal to 1.

Aside from that, as Andar said, that code wouldn't do what you want - your CPU can iterate a loop from 0 to 60 in an imperceptible fraction of a second.

I think your best bet would be to add a wait command to the current game interpreter.
Hello Andar! I just started reading and I have been analyzing this part of your text:
What you need to do is the same as the event command wait, which simply tells the engine to skip processing this event for x iterations of the main loop.
That will require an entirely different approach to coding.

I thought that replicating in a way similar to the Command would work, well, correcting what Duran mentioned (How stupid, I didn't see that the sum in the Wait Variable was written wrong), I'll see how I can get closer to what you mention.

This is an infinite loop.

You mean to say wait += 1 which is a single operator with no space in between the two symbols.

By putting them in the wrong order and putting a space between, what's happening is every time through the loop it's setting wait equal to 1.

Aside from that, as Andar said, that code wouldn't do what you want - your CPU can iterate a loop from 0 to 60 in an imperceptible fraction of a second.

I think your best bet would be to add a wait command to the current game interpreter.
Yes, sorry, I was looking all afternoon for a similar way, but I didn't find a method to script the Wait command, by the way, I didn't think the CPU processing would be that fast, I thought it would still be static seconds like the Wait Command in Events.
I found this topic (It's from 2015) and quoting the User "??????" Defined Function:
JavaScript:
Game_Interpreter.prototype.wait = function(duration) { 
    this._waitCount = duration;
};

I can't get "this.wait();" works as expected, am I quoting it wrong?
JavaScript:
Game_Interpreter.prototype.wait = function(duration) { 
    this._waitCount = duration;
};

Game_Party.prototype.callRenameScene = function(actor){
    this.wait(60);
    const scene = Scene_Rename;
    const max_name_chars = Kaltias.MaxNameChars;
    const scenesToBoot = [{scene,prep:[actor, max_name_chars]}];
    $gameTemp.bootRequiredScenes(scenesToBoot);
}

Sorry if I'm being too redundant or pushy, but I thought the MZ's scene handling would have a similar delay to the MV's, so trying to script this is a mess. Thank you and have a nice day!
I can't get "this.wait();" works as expected, am I quoting it wrong?
Yes.

In JavaScript, this refers to the object calling the function.


Putting this inside of a Game_Party method, therefore, will always refer to a Game_Party data object.

But that doesn't have any wait() method - as I mentioned in my first reply, and you quoted from another thread just now, wait() is a method of the interpreter.
Yes.

In JavaScript, this refers to the object calling the function.


Putting this inside of a Game_Party method, therefore, will always refer to a Game_Party data object.

But that doesn't have any wait() method - as I mentioned in my first reply, and you quoted from another thread just now, wait() is a method of the interpreter.
Oh, sorry, I'm quite slow to understand properly, I'll try to take a look at it in depth, thanks for the patience!

Original thread: https://forums.rpgmakerweb.com/threads/put-a-wait-between-windows-scenes.163666/