Modifying the global Window_Message behavior?

Occupant

Hypothetical
Member
Joined
Dec 4, 2017
Messages
15
Reaction score
9
First Language
English
Primarily Uses
RMMV
Hello all. I'm writing a plugin wherein I am trying to change the _helpWindow property of the Window_Message class during certain events.

However, it seems that this global class only sets the _helpWindow during its createSubWindows method, which it only calls in its initialize method. So even if I override the prototype for createSubWindows, by the time any of my events occur, the _helpWindow is instantiated, and I can't find a way to change it. What I'm hoping to do is change the _helpWindow (number of lines, specifically) repeatedly based on event variables.

So is there a way to do this? I thought I would call my overridden createSubWindows method again, but I can't find a hook into the Window_Message class instance to call it with the right context (attempts to call it from the prototype result in complaints about missing parent references).

Thanks for any help!
Occupant
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,639
First Language
Czech
Primarily Uses
RMMV
However, it seems that this global class only sets the _helpWindow during its createSubWindows method, which it only calls in its initialize method.
Well, first of all, you aren't fully correct here.
createSubWindows has nothing to do with _helpWindow by default as you can see here.
Screenshot_435.png
So if your function looks different, it is either older rpg maker or user input.
Or of course a plugin that adds a help window, somehow.

Nevertheless, there is a way to change it.
Step 1. Look at what exactly wants new Window_Message. That is very important, because that is where you'll search your window in game.
Screenshot_436.png
The only other option is Scene_Battle btw. But it is important to know the variable, which is this._messageWindow.

Step 2. Now that we know where to search the window, let's return to Window_Message inside rpg_windows and create a function.
Window_Message.prototype.createHelpWindow = function () {
this._helpWindow = new Window_Help ($gameVariables.value (x)) - substitute x for a number. this will ensure the new window gets called with certain amount of lines depending on the value of that variable.
this.addWindow (this._helpWindow)
}
And now when you are in game, simply call this function through script when you need it.
SceneManager._scene._messageWindow.createHelpWindow ();

Prototype functions are object oriented programming. By default they are useless. To make them useful, you need to create new object, which will then have all applicable functions.
For example SceneManager._scene is the stage of the game. When you're in title screen, it is Scene_Title and has its' functions. When it is a map, it is Scene_Map. When it is Scene_Battle, it has prototype functions of Scene_Battle. But it always gets created through new Scene_Title. new Scene_Battle. Etc.
Just like the window message got created through new Window_Message. So calling a function through prototype is useless, since it doesn't target any particular message window. Instead you need to find the message window and call the function through it.

If you don't get what I am saying, don't worry about that. You need experience to understand that and it took me two months to understand the prototype system MV works on.
 

Occupant

Hypothetical
Member
Joined
Dec 4, 2017
Messages
15
Reaction score
9
First Language
English
Primarily Uses
RMMV
Thanks for the reply! There's a lot to unpack, so I'll respond directly to your quotes.

createSubWindows has nothing to do with _helpWindow
Sorry, of course you're right. I was conflating Window_Message with Window_Selectable. Window_Message has a _choiceWindow property, which is Window_Selectable (via Window_Command inheritance), and Window_Selectable has the _helpWindow property. At some point my wires were crossed and I remembered _helpWindow being part of Window_Message itself, and not part of the Window_Selectable instance, _choiceWindow. I've been staring at these objects for too long!

Step 1. Look at what exactly wants new Window_Message
Ahh, yes, that is exactly the hook into the instance I was looking for! Thank you! This has put me on the right track.

If you don't get what I am saying, don't worry about that. You need experience to understand that and it took me two months to understand the prototype system MV works on.
Thanks. I am new to prototype chains, and they are quite different from the OO programming I'm used to (strongly typed class definitions). But I am a veteran of coding in other languages, so I was able to follow you.
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,858
Messages
1,017,023
Members
137,565
Latest member
Callmelogann
Top