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);
};
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);
};