[RMMV] "Typewriter" Effect; Need Assistance Centering Text

I asked about a typewriter-effect plugin earlier (https://forums.rpgmakerweb.com/index.php?threads/typewriter-text-effect.102482/) but managed to muddle through and draft one of my own which I'm getting pretty happy with.

I have two issues right now, I'll list both but I'm most interested in solving the centering of the text vertically:
- Text Centering; improving the horizontal center and making the vertical center make any sense what so ever
- Events reacting appropriately, IE not moving

Some background:
I copied the Window_Message code and base the "Window_Typewriter" on that.
I modify the parts as appropriate to accomplish what I needed to do, and bring in a few other elements to adjust as appropriate.
The plugin is called, right now, via a script call in an event.
I have three scripts that can be called from there, one which displays as a normal message, one which displays at the bottom of the screen without a frame, and the GOAL is the third will display full screen, with the text vertically and horizontally centered. So far it displays full screen, displays horizontally centered for the most part (I think its a little off, too far to the right at the moment), but I CANNOT get the vertical to work appropriately.
Attached is one of the most simple: box height divided by two. The line of text is CLEARLY not near the center of the screen, but more like center of the top half?
center_test.png
Notes:
- The parameters have no effect right now. They're placeholders for the moment.
- The font "SecretTypewriter" is in my game; comment that line out and use the GameFont
- If this code does prove useful to someone, please just toss a note in the credits for me, "Typewriter Effect, Nate Petersen (daMoose52)"
Well, first of all, while I commend the fact that you tried to construct it yourself, please allow me some honest criticism.

You have created a new window, Window_TypewriterMessage. However, you copied a ton of functions, if not all of them, from Window_Message. Instead of making it Window_Base prototype you should have therefore made it a Window_Message prototype, this way it'd inherit all Window_Message methods and you wouldn't need to copy them over and only redefine the methods you need to redefine, thus making your changes more visible.

The code is also quite dirty. A lot of the things can be simplified and you're using several pointless lines of code as well as typos in the code. Nevertheless, I'll talk only about the relevant ones.

Code:
Window_Typewriter.prototype.newLineX = function() {
    if($typewriterMessage.hAlign = "center") {
      return (this.x + (this.width/2)) - (this.textWidth(this._textState.text) / 2);
    } else {
      return $typewriterMessage.faceName() === '' ? 0 : 168;
    }
};

//equal sign is ==, not =

Code:
    var _window_typewriter_updatePlacement = Window_Typewriter.prototype.updatePlacement;
    Window_Typewriter.prototype.updatePlacement = function() {
      this.width = this.windowWidth();
      this.height = this.windowHeight();
      this.x = (this.windowWidth() - this.width) / 2;
      this.y = 2 * (this.windowHeight() - this.height) / 2;
    };

// it's pointless to multiply the y by 2 when you have division by 2 afterwards.

As for the actual problem, I'd recommend you to open the dev console, then as you are having this message on screen, go back to the console and console.log the message's x and y dimensions as well as the window's x and y dimensions to see if they are what they're supposed to be or not.
I'm learning my way through the MV code; I do more proper web development on a daily basis and have been beating on MV for about a week now? I fully expect it to be fairly messy 🙂

I actually had a lot of issues with using the Message window as the parent; for some reason it was complaining about some of those Message window functions not existing, hence copying over all of the Message functions. I've been pruning elements as I have confirmed needed and unneeded elements.

I'd turned up the single "=" a little bit after posting, and the multiple by 2/divide by 2 was a holdover from some of the duplicated code.

Original thread: https://forums.rpgmakerweb.com/threads/rmmv-typewriter-effect-need-assistance-centering-text.102563/