MV Help with displaying one line at a time in battle log

Hello everyone. My goal is to display battle log text, one line at a time, in a visible window. Here's what I have so far.

JavaScript:
    Window_BattleLog.prototype.initialize = function() {
        var width = this.windowWidth();
        var height = this.windowHeight();
        Window_Selectable.prototype.initialize.call(this, 0, 0, width, height);
        this.opacity = 0;
        this._lines = [];
        this._methods = [];
        this._waitCount = 0;
        this._waitMode = '';
        this._baseLineStack = [];
        this._spriteset = null;
        this.createBackBitmap();
        this.createBackSprite();
        this.refresh();
    };

    Window_BattleLog.prototype.maxLines = function() {
        return 1;
    };

    Window_BattleLog.prototype.refresh = function() {
        this.drawBackground();
        this.contents.clear();
        this.hide();
        for (var i = 0; i < this._lines.length; i++) {
            this.drawLineText(i);
            this.opacity = 255;
            this.show();
        }
    };

The problem is, "Window_BattleLog.prototype.maxLines" only determines the window size, so if there is more than one line of battle text, it trails off the window. For example:

Slime B attacks!
Harold takes 15 damage!


Using my code above in a plug-in causes the "Harold takes 15 damage" to not be visible since it is no longer in the window. I want only one line to appear at a time, so ideally, "Slime B attacks" should be overwritten with "Harold takes 15 damage". In the screenshot below, you can see that the second line is cut off, rather than replacing "Slime B attacks".

1652217683656.png


I think the lines drawn have something to do with "_baseLineStack", but I cannot figure it out. Any assistance is very much appreciated.
@jcruise Try this:

JavaScript:
const jcruise_Window_BattleLog_initalize = Window_BattleLog.prototype.initialize;
Window_BattleLog.prototype.initialize = function() {
    jcruise_Window_BattleLog_initalize.apply(this);
    this.opacity = 255;
    this.height = this.fittingHeight(1);
}
const jcruise_Window_BattleLog_update = Window_BattleLog.prototype.update;
Window_BattleLog.prototype.update = function() {
    jcruise_Window_BattleLog_update.apply(this);
    if (this.visible && !this._lines.length) this.hide();
    if (!this.visble && this._lines.length) this.show();
}
Window_BattleLog.prototype.numLines = function() {
    return 1;
};
Window_BattleLog.prototype.createBackSprite = function() { };
Window_BattleLog.prototype.drawLineText = function(index) {
    var rect = this.itemRectForText(index);
    this.contents.clear();
    this.drawTextEx(this._lines[index], rect.x, 0, rect.width);
};

jcruise-request.gif
@Kenen , I can't thank you enough. It works brilliantly.
@jcruise No problem!

Original thread: https://forums.rpgmakerweb.com/threads/help-with-displaying-one-line-at-a-time-in-battle-log.147476/