The first thing you need to do is to create the contents of the window in a size that can be scrolled.
You can do that by the fittingHeight or calcHeight method. Or with the textHeight(Which was the one that I used).
Spoiler: references
JavaScript:
Window_Base.prototype.fittingHeight = function(numLines) {
return numLines * this.itemHeight() + $gameSystem.windowPadding() * 2;
};
Window_Base.prototype.calcTextHeight = function(textState) {
const lineSpacing = this.lineHeight() - $gameSystem.mainFontSize();
const lastFontSize = this.contents.fontSize;
const lines = textState.text.slice(textState.index).split("\n");
const textHeight = this.maxFontSizeInLine(lines[0]) + lineSpacing;
this.contents.fontSize = lastFontSize;
return textHeight;
};
Scene_Base.prototype.calcWindowHeight = function(numLines, selectable) {
if (selectable) {
return Window_Selectable.prototype.fittingHeight(numLines);
} else {
return Window_Base.prototype.fittingHeight(numLines);
}
};
So after your window content has a height higher than your window height, you can start working on the scroll feature.
For that, I advise you to take a look at the Window_ScrollText.
JavaScript:
Window_ScrollText.prototype.updateMessage = function() {
this.origin.y += this.scrollSpeed();
if (this.origin.y >= this.contents.height) {
this.terminateMessage();
}
};
As you can see, there is a property called "this.origin.y". And that is what you need to change.
if the origin.y is higher than zero, the content will scroll down. Otherwise, it will scroll up.
In my plugin, I made a function that checks the player input, if it is pressed down, I raise the origin.y. If is pressed up, I lower the origin.y value.
So I set a minimum value and a maximum value for the origin.y, so it can scroll only when possible.
Although there is the Window_Scrollable, I didn't check for it. So maybe you can check that too.