$gameScreen.fadeOut(), interpreter.wait(), and others not working.

ndcomix

Villager
Member
Joined
May 4, 2016
Messages
6
Reaction score
1
Primarily Uses
N/A
Hi there. I am experiencing issues with certain plugin commands executing in javascript. To isolate external factors, I created a brand new game with no plugins and wrote this simple code:

Code:
Game_Interpreter.prototype.pluginCommand = function(command, args) {
    if (command === "testFadeOut") {
        console.log('start test');
        $gameScreen.startFadeOut(30);
        this.wait(30);
        $gameScreen.startFadeIn(30);
        console.log('finish test');
    }
};
When I execute the plugin command, all that happens is the console logs each call immediately without delay and no screens are faded in or out. I have tried executing a variety of code with the interpreter's wait() function but it just does not work from within the javascript. What am I missing here? Is there some other approach that will allow these types of commands to work? And just in case you're wondering: yes, this code must execute from within javascript files and not the RMMV editor, event editor, etc.

Thank you for your insight!
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
965
Reaction score
708
First Language
English
Primarily Uses
RMMV
@ndcomix Actually, the screen fade and the wait functions do work, but perhaps not in the way that you might be expecting. The plugin command is executed all at once and does not stop when the 'wait' function is called. If you only call 'startFadeOut' and 'wait', the screen will fade out as normal. Technically you could have a function updating every millisecond and trigger when the 'waitCount' variable reaches zero :

Code:
if (command === "testFadeOut") {
    console.log('start test');
    $gameScreen.startFadeOut(30);
    this.wait(30);

    var interval = setInterval(() => {
      if (this._waitCount === 0) {
        console.log('finish test');
        $gameScreen.startFadeIn(30);
        this.wait(30);
        clearInterval(interval);
      }
    }, 1);
}
Not sure I would want to rely on that, though. Or you could have a 'while' loop that updates the game as wait timer counts down, I suppose. Does the fade in process have to happen in the same command?
 

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
14,159
Reaction score
7,807
First Language
English
Primarily Uses
RMMV

I've moved this thread to Learning Javascript. Please be sure to post your threads in the correct forum next time. Thank you.

 

ndcomix

Villager
Member
Joined
May 4, 2016
Messages
6
Reaction score
1
Primarily Uses
N/A
Thanks for your input Ossra, I appreciate your time & suggestions. Unfortunately, there is a multitude of complex movements, animations, and screen effects that need to coordinate with the frames. Using a time interval was not effective in my tests, particularly with the quantity of effects. I suppose there may be a way to build out a large event page programmatically then assign it to my event and execute... was really hoping to avoid that route though. If you or anyone else has any other suggestions I'd love to hear them. Thanks again!
 
Last edited:

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
965
Reaction score
708
First Language
English
Primarily Uses
RMMV
@ndcomix Do you have an example? A list of event commands that you want to occur in a certain way? There are methods to more or less force event commands to wait for one another.
 

ndcomix

Villager
Member
Joined
May 4, 2016
Messages
6
Reaction score
1
Primarily Uses
N/A
Here's a little context: I've built a puzzle game where the player can arrange all sorts of components and characters to "set" a level however they'd like. Afterwords, they hit "go" and the program runs through the level, causing certain interactions and reactions based on the player's setup. Most of these interactions/combinations should be tied to specific animations. Given the multitude of components (particularly as the game progresses) the potential animation combinations number in the hundreds or maybe even thousands. That's why it has to be assimilated programmatically.

One short example could be:

Code:
1. Party Leader moves backwards one step.
2. Party Leader "attack animation" (Set Movement Route, "Wait")
2.1 Change Party Leader Image
2.2 Wait 3 frames
2.3 Change Party Leader Image
2.4 Wait 3 frames
2.5 Change Party Leader Image
2.6 Wait 3 frames
2.7 Change Party Leader Image
2.8 Wait 3 frames
2.9 Change Party Leader Image
2.10 Wait 3 frames
2.11 Change Party Leader Image
2.12 Wait 3 frames
2.13 Change Party Leader Image
2.14 Wait 3 frames
2.15 Change Party Leader Image
2.16 Wait 3 frames
3. Party Leader "attack animation" (Set Movement Route)
3.1 Change Party Leader Image
3.2 Wait 3 frames
3.3 Change Party Leader Image
3.4 Wait 3 frames
3.5 Change Party Leader Image
3.6 Wait 3 frames
3.7 Change Party Leader Image
3.8 Wait 3 frames
3.9 Change Party Leader Image
3.10 Wait 3 frames
3.11 Change Party Leader Image
3.12 Wait 3 frames
4. Show Animation "This Event" Hit, Thunder
5. Flash Screen 255,255,255,170 10 frames "Wait"
6. Flash Screen 255,255,255,170 10 frames "Wait"
7. Flash Screen 255,255,255,170 10 frames
8. Event A "attack animation" (Set Movement Route, "Wait")
... etc, etc, etc ..
 

ndcomix

Villager
Member
Joined
May 4, 2016
Messages
6
Reaction score
1
Primarily Uses
N/A
Oops, double posted. Plz disregard this comment. :) Or mods plz delete it!
 
Last edited:

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
965
Reaction score
708
First Language
English
Primarily Uses
RMMV
@ndcomix Hmm, well, whenever I want to create a hard wait in order for a specific event command to complete before moving on to the next command, I use a loop and a conditional branch :

Code:
◆Script:$gameScreen.startFadeIn(30);
◆Loop
  ◆If:Script:$gameScreen._brightness >= 255;
    ◆Break Loop
    ◆
  :End
  ◆Wait:1 frame
  ◆
:Repeat Above
The 'startFadeIn' function gradually raises the '_brightness' variable in '$gameScreen' up to a value of '255', so the loop will continue to hold the event until it reaches that amount. You can even have certain commands execute at a certain point within that loop, as well :

Code:
◆Loop
  ◆If:Script:$gameScreen._brightness >= 120 && $gameScreen._brightness < 125;
    ◆Play SE:Attack3 (90, 100, 0)
    ◆Set Movement Route:Player (Wait)
    :                  :◇1 Step Backward
    :                  :◇1 Step Backward
    ◆
  :End
  ◆If:Script:$gameScreen._brightness === 0;
    ◆Break Loop
    ◆
  :End
  ◆Wait:1 frame
  ◆
:Repeat Above
If you are within a Movement Route command, you can use an 'if' in a Script Command to do something similar :

Code:
if ($gameMessage.isBusy()) { this._moveRouteIndex--; this._waitCount = 1; };
When the above is encountered in a Movement Route, the event will wait until there is not a Show Text message on the screen.

I am not sure if this is useful to you as I am not quite sure what the provided example is really doing, but I thought I would offer some options.
 

ndcomix

Villager
Member
Joined
May 4, 2016
Messages
6
Reaction score
1
Primarily Uses
N/A
I Ossra, I appreciate your input. Unfortunately, that's not going to be feasible approach for reasons that would take me a long time to explain but could probably be summarized as: 1) Too resource intensive and 2) Conflicting variables & validators between multiple simultaneous loops.

I will continue to explore programmatically building an event page then executing it, though if there are any other suggestions out there I'd appreciate hearing them. Thank you!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Out of sudden, snow. Everywhere.
People in Italy panicking for this stupid coronavirus, it's nothing more than a flu and they are all acting like it's the black plague...
Blech. I hate coming up with stories. Making gameplay is fun but coming up with lore and reasons for these areas/mechanics just makes me sleepy.
40 card deck size, the plugin seems more sluggish.

Forum statistics

Threads
94,568
Messages
921,951
Members
124,432
Latest member
slimshada
Top