09-07-2017, 05:43 AM
(This post was last modified: 09-07-2017, 05:51 AM by DerVVulfman.)
The 'include' command to which Kyo is referring to is one that allows you to 'copy' said methods from one into another. So don't worry about the heiarchy. Modules are the largest of the structures and can hold classes.... and yes, can hold methods. But not the other way around. The include command makes it hella easy, like if two or more classes need the same methods or stuff.
EXAMPLE: The Dance Revolution system I am writing has both a player and an editor. Each needs to read a song, play a song and stop the song from playing. Instead of having the same methods appear in both the player and the editor, I could make a single DDR module that has those methods defined, and then use 'INCLUDE' in both my player class and my editor class!!! So the player can just open, play, close the song. And the Editor can open, play, and close the song too. I just create the methods ONCE and include them!
Now there is another thing SIMILAR to the include system, and that is called INHERITANCE, but it is not called by any phrase like
Inherit Dancing.
Nope nope nope. It might be easier for you to see it.
Go and look at the 'Window_Selectable' class in your editor, and you may see this:
class Window_Selectable < Window_Base
Looks odd, no? The '< Window_Base' thingie says 'WE CHEATED!!!' We just made a whole class called Window_Selectable, and we're re-using material from Window_Base without needing to retype it!!!
So the Window_Selectable class is not just what you see there, but it also 'inherits' every method found in Window_Base.
And if that doesn't blow ya away, look at Window_Command!
class Window_Command < Window_Selectable
OMG, that's right! Not only is Window_Command everything you read in that script, but everything from Windows_Selectable 'AND' from Window_Base. That is a HELL of a shortcut.
But that does explain why Window_Command refers to 'normal_color' which was defined as a method in Window_Base. Window_Command 'inherited' the method and is using it.
.... Now before you ask, I know. The Window_Base class begins with
class Window_Base < Window
Window_Base is actually inheriting special 'hidden' methods from the hidden WINDOW class. The Window class is a special hidden class that deals with things like reading the individual chunks from the windowskin and how to draw them, the borders, etc. WE don't have access to the actual code for the Window class itself, and it might not even be in Ruby but C++. BUT, the Window_Base class can still access the methods and use them.
Kewl?
EXAMPLE: The Dance Revolution system I am writing has both a player and an editor. Each needs to read a song, play a song and stop the song from playing. Instead of having the same methods appear in both the player and the editor, I could make a single DDR module that has those methods defined, and then use 'INCLUDE' in both my player class and my editor class!!! So the player can just open, play, close the song. And the Editor can open, play, and close the song too. I just create the methods ONCE and include them!
Now there is another thing SIMILAR to the include system, and that is called INHERITANCE, but it is not called by any phrase like
Inherit Dancing.
Nope nope nope. It might be easier for you to see it.
Go and look at the 'Window_Selectable' class in your editor, and you may see this:
class Window_Selectable < Window_Base
Looks odd, no? The '< Window_Base' thingie says 'WE CHEATED!!!' We just made a whole class called Window_Selectable, and we're re-using material from Window_Base without needing to retype it!!!
So the Window_Selectable class is not just what you see there, but it also 'inherits' every method found in Window_Base.
And if that doesn't blow ya away, look at Window_Command!
class Window_Command < Window_Selectable
OMG, that's right! Not only is Window_Command everything you read in that script, but everything from Windows_Selectable 'AND' from Window_Base. That is a HELL of a shortcut.
But that does explain why Window_Command refers to 'normal_color' which was defined as a method in Window_Base. Window_Command 'inherited' the method and is using it.
.... Now before you ask, I know. The Window_Base class begins with
class Window_Base < Window
Window_Base is actually inheriting special 'hidden' methods from the hidden WINDOW class. The Window class is a special hidden class that deals with things like reading the individual chunks from the windowskin and how to draw them, the borders, etc. WE don't have access to the actual code for the Window class itself, and it might not even be in Ruby but C++. BUT, the Window_Base class can still access the methods and use them.
Kewl?