Force message box dialogue along (JavaScript)

Hi all!

I want to force message box dialogue irrespective of user input. For example, a message box appears open for x amount of time then closes or continues to the next bit of dialogue.

I've found success using the special characters |\ |\ |\ ^ (This waits 3 seconds then continues to the next bit of dialogue).

The problem with this is that I am using JavaScript to create my messages $gameMessage.add("Foo") and special characters are not interpreted at any point past the add method.

I've failed at 2 solutions so far:

1. Find the code in which special characters are interpreted to pause text and try to implement it at the $gameMessage level. I could not find this anywhere in the code base.

2. Simulate a key press in the browser after the dialogue has finished. This is the code I have implemented so far.

Code:
Game_System.prototype.sayAuto = function (msg, sprite, spritePos, bg, pos, waitTime) {
   $gameMessage.setFaceImage(sprite || 'blank', spritePos);
   $gameMessage.setBackground(bg || 0);
   $gameMessage.setPositionType(pos || 2);
   $gameMessage.add(msg);
   $gameMap._interpreter.setWaitMode('message');
  
   setTimeout(function () {     
     var keyboardEvent = document.createEvent("KeyboardEvent");
     var initMethod = typeof keyboardEvent.initKeyboardEvent !== 'undefined' ? "initKeyboardEvent" : "initKeyEvent";
     keyboardEvent[initMethod](
                  "keydown", // event type : keydown, keyup, keypress
                   true, // bubbles
                   true, // cancelable
                   window, // viewArg: should be window
                   false, // ctrlKeyArg
                   false, // altKeyArg
                   false, // shiftKeyArg
                   false, // metaKeyArg
                   13, // keyCodeArg : unsigned long the virtual key code, else 0
                   0 // charCodeArgs : unsigned long the Unicode character associated with the depressed key, else 0
      );
     document.dispatchEvent(keyboardEvent);
  }, waitTime);
};

// It would be used like so if I wanted the box to appear open for just 3 seconds.

$gameSystem.sayAuto("Hello", "custom2", 0, null, 3000);

It works but the game acts as if the key is held down leading to a bunch of dialogue being skipped.


Both these methods seem hackish and not very clean.


Does any body have any idea how this can be achieved whilst still retaining use of $gameMessage.add().

I've moved this thread to Plugin Support. Thank you.

I know this is old, but I had the same problem, and after some time looking at the code I found how to simulate by code an 'ok' press.

Call this code from Window_Message

JavaScript:
this.pause = false;
this.terminateMessage();

Original thread: https://forums.rpgmakerweb.com/threads/force-message-box-dialogue-along-javascript.81487/