Help with custom messages/scenes

Hi - newbie here, appreciate this forum's patience and assistance! For my game, the initial scene starts out with a bunch of information and asks the user to make a few choices to set up the game. The default messages are too small and I need to customize the selectable message input as well.

I am just learning to make a custom scene/message/plug in. I am starting small by just copying the Scene_Message code, but I can't figure out how to actually create a message. My code is below (but again, just a copy with a new name).

First question: when I run this I get an error that says: "Type Error: Cannot read property 'addChild' of undefined." How do I fix this?

Second question: assuming someone can help me fix the first error - how do I actually create a message, tell it what variable to display, etc.? This is a fundamental piece of javascript that I am struggling with.

Third question: I was able to create a basic scene with text using a youtube tutorial but found that the text doesn't wrap, I'd have to implement a "next" button, etc, so I figured the best thing to do was start was the Scene_Message class and go from there. Does this sound right?

Code:
function Scene_budgetMessageMenu() {
this.initialize(...arguments);
}
Scene_budgetMessageMenu.prototype = Object.create(Scene_Base.prototype);
Scene_budgetMessageMenu.prototype.constructor = Scene_budgetMessageMenu;
Scene_budgetMessageMenu.prototype.initialize = function() {
Scene_Base.prototype.initialize.call(this);
this.createAllWindows();
//add more here?
};
Scene_budgetMessageMenu.prototype.isMessageWindowClosing = function() {
return this._messageWindow.isClosing();
};
Scene_budgetMessageMenu.prototype.createAllWindows = function() {
this.createMessageWindow();
this.createScrollTextWindow();
this.createGoldWindow();
this.createNameBoxWindow();
this.createChoiceListWindow();
this.createNumberInputWindow();
this.createEventItemWindow();
this.associateWindows();
};
Scene_budgetMessageMenu.prototype.createMessageWindow = function() {
const rect = this.messageWindowRect();
this._messageWindow = new Window_Message(rect);
this.addWindow(this._messageWindow);
};
Scene_budgetMessageMenu.prototype.messageWindowRect = function() {
const ww = Graphics.boxWidth;
const wh = this.calcWindowHeight(40, false) + 8;
const wx = (Graphics.boxWidth - ww) / 2;
const wy = 0;
return new Rectangle(wx, wy, ww, wh);
};
Scene_budgetMessageMenu.prototype.createScrollTextWindow = function() {
const rect = this.scrollTextWindowRect();
this._scrollTextWindow = new Window_ScrollText(rect);
this.addWindow(this._scrollTextWindow);
};
Scene_budgetMessageMenu.prototype.scrollTextWindowRect = function() {
const wx = 0;
const wy = 0;
const ww = Graphics.boxWidth;
const wh = Graphics.boxHeight;
return new Rectangle(wx, wy, ww, wh);
};
Scene_budgetMessageMenu.prototype.createGoldWindow = function() {
const rect = this.goldWindowRect();
this._goldWindow = new Window_Gold(rect);
this._goldWindow.openness = 0;
this.addWindow(this._goldWindow);
};
Scene_budgetMessageMenu.prototype.goldWindowRect = function() {
const ww = this.mainCommandWidth();
const wh = this.calcWindowHeight(1, true);
const wx = Graphics.boxWidth - ww;
const wy = 0;
return new Rectangle(wx, wy, ww, wh);
};
Scene_budgetMessageMenu.prototype.createNameBoxWindow = function() {
this._nameBoxWindow = new Window_NameBox();
this.addWindow(this._nameBoxWindow);
};
Scene_budgetMessageMenu.prototype.createChoiceListWindow = function() {
this._choiceListWindow = new Window_ChoiceList();
this.addWindow(this._choiceListWindow);
};
Scene_budgetMessageMenu.prototype.createNumberInputWindow = function() {
this._numberInputWindow = new Window_NumberInput();
this.addWindow(this._numberInputWindow);
};
Scene_budgetMessageMenu.prototype.createEventItemWindow = function() {
const rect = this.eventItemWindowRect();
this._eventItemWindow = new Window_EventItem(rect);
this.addWindow(this._eventItemWindow);
};
Scene_budgetMessageMenu.prototype.eventItemWindowRect = function() {
const wx = 0;
const wy = 0;
const ww = Graphics.boxWidth;
const wh = this.calcWindowHeight(40, true);
return new Rectangle(wx, wy, ww, wh);
};
Scene_budgetMessageMenu.prototype.associateWindows = function() {
const messageWindow = this._messageWindow;
messageWindow.setGoldWindow(this._goldWindow);
messageWindow.setNameBoxWindow(this._nameBoxWindow);
messageWindow.setChoiceListWindow(this._choiceListWindow);
messageWindow.setNumberInputWindow(this._numberInputWindow);
messageWindow.setEventItemWindow(this._eventItemWindow);
this._nameBoxWindow.setMessageWindow(messageWindow);
this._choiceListWindow.setMessageWindow(messageWindow);
this._numberInputWindow.setMessageWindow(messageWindow);
this._eventItemWindow.setMessageWindow(messageWindow);
};
A couple of notes: when posting code, please use the CODE tag (the </> in the edit bar). This preserves indentation and brackets - what you have there is pretty hard to read.

Second - you should be able to do what you want pretty easily with existing or simpler plugins. There's no need for you to try to learn JavaScript for this, unless you just want to.

For example, changing the size of a window is 1 or 2 lines of code. You don't have to recode the entire scene and all the windows just to change a few properties.

There are existing plugins like VisuStella's Message Core that have wordwrap (that also allows you to resize the message window).

when I run this I get an error that says: "Type Error: Cannot read property 'addChild' of undefined." How do I fix this?
First, you provide the full error trace. Press F8 in the game, go to the Console tab, and take a screenshot of that. That will show which file and line of code is producing the error.

Second question: assuming someone can help me fix the first error - how do I actually create a message, tell it what variable to display, etc.?
That's the downside to trying to recreate your own entire system, you have to understand some of the more intricate and low-level stuff. As opposed to just resizing the existing windows to what you want, and all of the default event commands would simply work with them.

I don't see anything in your code that would deal with that at all; drawing text into a window is all done at the window level, it's nothing to do with the scene.

For example, the default message window looks at the global $gameMessage variable and pulls any text from it inside of Window_Message.startMessage().
sorry about the code! Thanks for the tip, well noted for the future. And thanks for the help with the simple plugin. I think I will definitely go that way and found the one you referenced easy to use. Your help is much appreciated!

Any thoughts on the following (like you do know of a plugin or other way to do this)?

I want to have a message where some of the words might be confusing to the game players. On a webpage I would put a link over those words that you could click on or hover over to get more info. But I am not sure how I could accomplish this in a menu, particularly because anywhere you click in a message takes you to the next screen.
I Googled "rpg maker mz hover text" and this thread was the first result. Seems to have several options to do what you want.

ha - thank you for being a better googler than me 🙂 I'll try those!

Have you used the Visustella MessageKeywords plugin referred to above? When I set it up and add the tooltip text, it works, but the hover only displays for about 3/4 second. I want the hover to continue until I move my mouse off of the word (which seems like the expected behavior and not an anomaly). I tried googling this problem and didn't have any luck. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/help-with-custom-messages-scenes.168698/