RGSS scripting dissections and explinations
#13
(09-07-2017, 05:43 AM)DerVVulfman Wrote: 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.  This special hidden class 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?
so "include" is a common thing for scripting and "pacman" < allows scripters to cheat by using other scripts by effectively piggybacking while still adding something new?
and by the looks of things THIS is all throughout the BASE coding for XP!

so "Pacman" < can om-nom its way through the program itself and create lil portals between preexisting scripts at any given point so that scripters don't have to rewrite everything everytime? thats sneaky! but actually puts a good use to my naming convention of "Pacman"!...which is ironic as I've called it that for YEARS!

what about "reverse pacman" > I see it a few times in the base scripts
[Image: SP1-Writer.png]
[Image: 55e3faa432d9efb86b8f19a6f25c0126-dawz35x.png]

new logo for Yesteryear created by Lunarberry!
Reply }


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

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



Users browsing this thread: 8 Guest(s)