$gameInterpreter.wait() doesn't work?

I've been referencing the 'script equivalent of command calls' list a lot lately ( link ) but the listing for the Wait command doesn't work.


I can't locate $gameInterpreter in my console, firstly.  I was able to find it being created (or at least where I think it's created, I'm an amateur with JS) in rpg_objects.js and, in fact, that Game_Interpreter function does have a wait method which takes a duration as its parameter.  However, even so, calling it returns that $gameInterpreter is undefined.  If I call Game_Interpreter instead it (of course) returns that it doesn't have a Wait method.


So what is the proper way to call for a Wait inside a script execution event?  This is what my event looks like at the moment:


Capture4.PNG


What I'm trying to achieve is a sweep of audio from the left-most pan to the right-most pan with a short delay between each played sound so it doesn't create overlapping tones and takes a little bit to go from left to right.
because this not how it's work.


your method is strongly wrong you can't declare variable like this.


honestly what you are trying to do is a "gradual" song increasing.


and I do think this would require a plugin who edit how work HTML audio.


and pan is setup to a value of 0 to 1 
Use this instead:


this.wait(60);


Then you have your code after. No need using a for loop. 🙂
No need using a for loop

Pan goes from -100 to 100 in RMMV's event editor, I want it to play a sound once for every increment of 5 between -100 and 100, to create a sweep.  Playing it once won't be enough and I don't want to put down 80 'play sound' and 'wait' commands.

honestly what you are trying to do is a "gradual" song increasing.

Hm?  But that's not at all what I'm trying to do.  It's similar in execution - but I'm not changing its volume from 0 to 100, I'm changing its pan from the left-most to the right-most speaker.

and pan is setup to a value of 0 to 1 

Interesting.  I'll check that but at first blush my event did seem to work properly with the -100 to 100 cycle.

this.wait(60);

Aha.  That would make sense.  I didn't consider that possibility.  Let me check into that real quick.

and I do think this would require a plugin who edit how work HTML audio.

Definitely not true.  Without the wait command it functions perfectly.  Replicating the facisimile of a forloop in the database made it work fine - but it doesn't solve my query over why the listed command ($gameInterpreter.wait(x)) isn't working.  


This works, although it's more annoying to set up than a for loop in the scripted event execution command.


Capture6.PNG
@Firgof


// Wait
Game_Interpreter.prototype.command230 = function() {
    this.wait(this._params[0]);
    return true;
};


This is the definition, so you should be able to just use


this.wait(4)

but it doesn't solve my query over why the listed command ($gameInterpreter.wait(x)) isn't working.  



Perhaps they mean you need to replace $gameinterpreter with an actual reference to a Game_Interpreter object. For example if you're calling from a script call, `this` would work just fine.


I don't know, different programmers have different ways of representing things I guess.
this.wait(frames) does in fact work.  I've made a note of it in the official spreadsheet for the script call.


Note to others who might stumble on this topic also looking to pan a sound:  I'm using very short sounds which I've modified to the exact length in frames * 60 seconds I expect each step to take.  Obviously this can result in stutters, gaps, and lots of clashing noise if not handled delicately.  I have the benefit of working in a game project where the player character is exploring a glitchy computer-generated environment so that sort of audio processing error is actually just fine in my use-case.  Beware if you can't guarantee that framerate or don't have a sound short enough to fit in those small increments of time.

Original thread: https://forums.rpgmakerweb.com/threads/gameinterpreter-wait-doesnt-work.59049/