Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 RGSS scripting dissections and explinations
#11
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?
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png] [Image: liM4ikn.png] [Image: fdzKgZA.png] [Image: sj0H81z.png]
[Image: QL7oRau.png] [Image: uSqjY09.png] [Image: GAA3qE9.png] [Image: 2Hmnx1G.png] [Image: BwtNdKw.png%5B]
Above are clickable links

Reply }


Messages In This Thread
RE: RGSS scripting dissections and explinations - by DerVVulfman - 09-07-2017, 05:43 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
   Help iwth script (RGSS Player crash) Whisper 3 6,524 06-17-2017, 05:03 PM
Last Post: Whisper
  How can I use the cmd of "require" in rgss superegp 2 5,346 11-03-2015, 06:16 AM
Last Post: kyonides
   Scripting in VX vs VX Ace Miharu 5 8,164 02-21-2015, 10:10 AM
Last Post: Taylor
   Combat animations via scripting; How? ZeroSum 2 4,544 09-20-2013, 06:58 PM
Last Post: ZeroSum
Question  RGSS stoped to work Chaos17 5 6,875 02-14-2013, 05:13 PM
Last Post: DerVVulfman
   Ruby, RGSS & General Code Discussion Kain Nobel 6 9,836 12-22-2012, 05:11 AM
Last Post: MechanicalPen
   [Request] Tut. for RGSS Eldur 9 10,545 12-07-2012, 04:27 AM
Last Post: DerVVulfman
   [ASK-RGSS] Behemoth's CBS alike Getsuga_kawaii 0 3,848 04-29-2010, 03:07 PM
Last Post: Getsuga_kawaii
   Scripting I think spazfire 7 8,903 04-12-2010, 03:21 AM
Last Post: DerVVulfman
   Beginner Scripting Tuts? KDawg08 1 3,666 03-31-2010, 11:03 PM
Last Post: Hsia_Nu



Users browsing this thread: