Complete Beginner Exploring rpg_windows.js


Suppose I wanted to have a text system where my text is displayed one letter at a time with a sound for each letter just like in that video there at 1:07:46 with the option of displaying the full message by having the player input something.

Would I be in the right place in order to do this? Because since there's no information I really wouldn't be able to tell. I'd like to know this to see if I could figure out how to modify the code to make it do what I want it to do.

I think Galv has a plugin that does that
https://forums.rpgmakerweb.com/index.php?threads/galvs-message-sound-effects.49418/

so does iavra
https://forums.rpgmakerweb.com/index.php?threads/iavra-text-sound.49347/

so you can see how a couple people approached this.
That's great, thank you, I will indeed check how they did it.
I'm currently studying classes so I thought it would tie in nicely to what we're discussing here.

upload_2019-8-22_9-32-10.png

This reminds me of the .prototype we talked about earlier.

a) So according to my search on Google:
upload_2019-8-22_9-35-31.png

b) 3. is probably what we were talking about with:
upload_2019-8-22_9-36-10.png

c) I just realized that in the case above: .prototype is a property while .drawItem is a method. From what I understand, this structure is typical of prototypal instantiation.

d) In the cons of that instantiation I read:
upload_2019-8-22_9-40-25.png

The constructor function is something we also talked about previously with Zevia.

e) Further into the exercise, there is discussion of the .constructor method which is limited to classes. Doing a quick 'ctrl+F', I find that method used in the windows.js:
upload_2019-8-22_9-45-2.png

Image 5
...which is cool when you see something you're learning actually used in practice.

f) The class I had to create in my exercise admittedly looks very different than the classes above:
upload_2019-8-22_9-52-23.png

For instance:
Line 1: I use curved braces after my class declaration while above only use parentheses.
Line 3: I use .this but there's none in image 5... although it used in a different class:
upload_2019-8-22_9-55-16.png

Image 6
which means we don't always use .this with every class, just some of them.
Line 1: I don't use the assignment operator while they do in image 6.

g) So an instance is:
An instance is an object that contains the property names and methods of a class, but with unique property values.

What would be considered an example of an instance in rpg_windows.js?
Looks like you're making good progress on learning so I'll just respond to a select few points.
The class I had to create in my exercise admittedly looks very different than the classes above:
What you learned in the exercise is using syntax available since 2015 (ES2015 specification) and is preferred by most JS developers. Under the hood, it still uses prototype inheritance, but it's considered a cleaner syntax. Personally I prefer the "class" keyword.

MV code could be rewritten to use this, like:
Code:
class Window_Gold extends Window_Base {
   constructor() {
      super()
   }
   // all the stuff for window gold goes here
}
The MV developers aren't going to do that rewrite because it's literally thousands of lines of code and I doubt they have the time.

What would be considered an example of an instance in rpg_windows.js?
You won't find an example of a window instance in rpg_windows.js. Why? Because that file defines what the windows are. It defines the hierarchy (all windows inherit from Window_Base, the Window_Command inherits from Window_Selectable, etc. etc.). That file defines the properties and methods used by the windows. But that file does not create any instance of windows.

You would find that in rpg_scenes.js. Take the gold window, where does it appear? What is it a component of?
It appears in the menu scene. It can also appear in the map scene too.
So looking at Scene_Menu, you will find a line that's something like:
Code:
this._goldWindow = new Window_Gold()
Where "this" is referring to the scene. You could describe that relationship as a "contains a" relationship, as in "the menu scene contains a gold window". That pattern is called Composition.
There's also the "inherits from" relationship as in "the gold window inherits from the base window". That pattern is called Inheritance.

As you can see, those patterns do not work against each other but worth together to make the menu do stuff.
The MV developers aren't going to do that rewrite because it's literally thousands of lines of code and I doubt they have the time.
in theory since it's a rigidly-defined find-and-replace problem you could automate it, but in practice...
That comic is spot-on haha.

This could be an interesting option to try:
https://github.com/lebab/lebab
I'm currently studying objects and classes and doing exercises about them. It's fairly exciting to finally be studying something more in context with what I ultimately aim to do.

I was told about JSON on a different forum which is a subset of Java Script. Is that something I should worry myself with or just I ignore this for now? I'd like to stick with learning about the essentials so I'd only learn about JSON if I absolutely have to.

I've scrolled through thousands of lines of codes in rpg_windows.js and almost every single entry has the .prototype.

So out of curiosity I checked rpg_scenes as well and same thing, from what I could tell everything was .prototype.

Admittedly I could check every single file but I figured I could also ask: are all the .js files or RMMV like that with the .prototype property? Is it because it's the source code that's it's like this?
I was told about JSON on a different forum which is a subset of Java Script. Is that something I should worry myself with or just I ignore this for now? I'd like to stick with learning about the essentials so I'd only learn about JSON if I absolutely have to.
JavaScript Object Notation are simply text files used to store data in object notation, because a file/data with a certain structure is easier to manipulate than a file/data without it. I'd treat it as a convenient naming convention than subset of Javascript for now as most of the time you don't use it (you use it pretty much only when you are dealing with files and most of the time you use only parse and stringify methods).

Admittedly I could check every single file but I figured I could also ask: are all the .js files or RMMV like that with the .prototype property? Is it because it's the source code that's it's like this?
Yes, almost everything in rpg_* files is prototype. It was written in ES5 standards and prototype was the only way to do something close to object oriented programming. And we're not going to see it rewritten to ES6, because there's no performance gain from just rewriting it in ES6. You'd need to upgrade it with optimizations, but even though MV needs optimizations like mad, they won't happen, because they reportedly want to keep the engine compatible with as many plugins as possible.
Oh I see thanks.

(By the way, as a slight tangent, I tried watching your tutorials. It's really a shame that the text is so small as I can't see anything. A 2 hours tutorial would be great but I personally can't see what you're writing, even in full screen.)

Original thread: https://forums.rpgmakerweb.com/threads/complete-beginner-exploring-rpg_windows-js.112247/