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 }
#12
WOW cool!
so basically if I have a 3 module "barns" and I want to merge 1 and 2 into a jumbo module a "warehouse" I can do that by simply including them together like putting fruits into a blender? thats neat!


Quote:R,G,B,A? shoudent it be R,G,B,L as in Red Green Blue Luminescence/Light whats the A mean?


A stands for Alpha or transparency or luminous stuff, etc. 255 is completely visible, 120 looks like a ghost and 0 well, you can't tell where did it go because you can't see it.
(me while looking in a mirror) Hello stupid why diddent you think of that!? (my brain) I'm on coffee break leavemealone!

in all seriousness though its not brightness but transparency? that makes sense
Quote:+ for sums, - for substractions, / for divisions, * for multiplications and % for modulo
what is modulo?
I see percentage...like for a grade point average from a school... what is percentage/modulo and what does it DO in scripting?

also I keep seeing += and -= and =< and => and == why is the equal sign always there and how does "pacman" and "reverse pacman" work?

(also thank you! the more info this thread can gather the better it is for not just me but other noobs reading! please keep going! don't hesitate! my mind is actively cramming this info into every available position to the point where I'm probably gonna forget how to eat for a day or two!)
[Image: SP1-Writer.png]
[Image: 55e3faa432d9efb86b8f19a6f25c0126-dawz35x.png]

new logo for Yesteryear created by Lunarberry!
Reply }
#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 }
#14
Some of your previous questions were answered in my previous post that I kept updating without noticing there were new posts available here...

< is lesser than anything you can find to its right hand side

1 < 2

yeah, a one year old baby is younger than a two year old baby, the first one has less experience in general, has not attempted to utter a single word like dad or mom.

class MotherClass
def how_to_eat
@use_fork_or_spoon = true
end
end

class ChildClass < MotherClass
end

Child inherits attributes or abilities from his or her mother so it learns stuff so the child has learned how to eat properly at the table. Really, he or she will use a fork or spoon to pick a vegetable instead of using his or her hands to lift it.

And << two lesser than symbols means an assignment by pushing a value, a kiwi, a number, a name or just anything to an Array.

@ary = []
@ary << 1
print @ary #=> [1]
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }
#15
(09-07-2017, 06:05 AM)kyonides Wrote: Some of your previous questions were answered in my previous post that I kept updating without noticing there were new posts available here...

"Pacman" < has been solved but not "reverse Pacman" >

along with
+=
-=
<=
>=

any definitions on these would be great!

if you have time I wouldn't want to be a bother!
[Image: SP1-Writer.png]
[Image: 55e3faa432d9efb86b8f19a6f25c0126-dawz35x.png]

new logo for Yesteryear created by Lunarberry!
Reply }
#16
I already explained += with my age example on the first page so take a look at that post to find the answer.

>= greater than or equal to

if age >= 21
Siletrea.drinks_beer
else
Siletrea.gets_arrested_for_being_a_minor
end

modulo... well, it's a leftover, really, that's all the mystery behind it.

7 % 4 = 3

Why 3? Well, 3 doesn't fit in 4 so we still got 3 guys that couldn't enter in a cabinet to make a phone call to Shanghai while the other 4 are calling people in Minnesota, Hawaii, Guatemala and Turkey.

You may wonder why most classes define a specific method namely initialize

class AOne
def initialize
@teacher = 'Siletrea'
@students = []
@scores = {}
end
end

Well, it tells Ruby, not RGSS, that you need to make a new copy of Class A so every year you can accept new pupils in your AOne class (meaning A-1). You were hired to teach them how to bake stuff in an oven.

In 2016 you did this
@my_class = AOne.new

This year you repeated the same process.
@my_class = AOne.new

Why it isn't called new?

It's complicated, it's Ruby's fault. new does exist, or else you wouldn't get a new class at all, the catch is that its contents are protected except for a method namely initialize. Instead of making you create the whole AOne class object, Ruby does it for you (you or me or VVulf would get headaches if we had to do it manually by coding that on our own.) Since Ruby's intention is to make it easy for us to make new classes, guess what? It simplified it by making stuff for us and it's free as in beer and freedom of speech. This way we will only change or add stuff that we really care about like your students or their scores.
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }
#17
(09-07-2017, 06:13 AM)kyonides Wrote: I already explained += with my age example on the first page so take a look at that post to find the answer.

>= greater than or equal to

if age >= 21
Siletrea.drinks_beer
else
Siletrea.gets_arrested_for_being_a_minor
end

lol in canada the legal drinking age is 19!

so "reverse pacman" is more powerful then "pacman"?

but what if you just wanted a number higher then and not equal to?

like
if age > 18
canadians can get drunk
else
canadians goto juvi

would just having "reverse pacman" > give you an error if the = isent there?
[Image: SP1-Writer.png]
[Image: 55e3faa432d9efb86b8f19a6f25c0126-dawz35x.png]

new logo for Yesteryear created by Lunarberry!
Reply }
#18
(09-07-2017, 06:05 AM)kyonides Wrote: Some of your previous questions were answered in my previous post that I kept updating without noticing there were new posts available here...

< is lesser than anything you can find to its right hand side

1 < 2

yeah, a one year old baby is younger than a two year old baby, the first one has less experience in general, has not attempted to utter a single word like dad or mom.

class MotherClass
def how_to_eat
@use_fork_or_spoon = true
end
end

class ChildClass < MotherClass
end

Child inherits attributes or abilities from his or her mother so it learns stuff so the child has learned how to eat properly at the table. Really, he or she will use a fork or spoon to pick a vegetable instead of using his or her hands to lift it.

And << two lesser than symbols means an assignment by pushing a value, a kiwi, a number, a name or just anything to an Array.

@ary = []
@ary << 1
print @ary #=> [1]

OK so a child is weaker then mom (that makes sense!)

even if its written as Mom>child or child<Mom  its pretty much the same thing?

@ary? ok so @ means instance which is tighter scripting for calling up different parts of the script while $ can jump scripts but is wiggly like a loose cord

so the @ means its strong but whats "ary"?

and using 2 "pacman's"<< will launch whatever you use it on into a array/boxlist for sorting stuff?
[Image: SP1-Writer.png]
[Image: 55e3faa432d9efb86b8f19a6f25c0126-dawz35x.png]

new logo for Yesteryear created by Lunarberry!
Reply }
#19
+= Now that's a shortcut. Instead of saying a = a + 1, you say a += 1. So each time we see a value of 'a', we add 1 to it.

-= Another shortcut. Just like above, this one subtracts from the value in question.

< is a 'comparison' operator. It means 'lesser than', and is used in checks like if a < b. If the value of a is 15 and the value of b is 4, then it would be like if 15 is less than 3... Obviously not! That test would FAIL.

And yeah, it is also used for the whole inheritance thing. Laughing Pacman here does double duty.

> is another 'comparison' operator. It means 'greater than', and is used in checks like if a > b. So again, if the value of a is 15 and the value of b is 4, then it would be like if 15 is greater than 3... NOW it works! So that IF... block of code will run!

<= and >= respectively mean 'less than or equal to' and 'greater than or equal to' Remember the test of if a < b? If a was set to 5 and b was set to 5, then it would be if 5 was less than 5.... and again, FAIL. But if we did if a <= b, it would work because it was not if a was less than OR EQUAL TO!!!

Equal signs!!! What is different between = and == ? Well, the first replaces the contents of a variable and one does a comparison test.

a = 4 .... this replaces the contents of variable 'a' with the value of '4'

if a == 4 .... this tests if the contents of variable 'a' equals '4'

Oh, the MODULO symbol!!! It means the 'remainder'

%... otherwise the percentage symbol, it is used in programming to get the REMAINDER value of a division. Like... um...
If you divide 9 by 3, your value is 3, right? There's no remainder. It's clean and has nothing fractional. But if you divide 9 by 2, you get 4 1/2 (or 4.5)

NOW unless you tell the program that you are dealing with numbers with decimal values (we call them floats), you're only going to end up with whole numbers. So an INTEGER version of 9 divided by 2 would actually equal 4! That's where modulo comes in... it gets the remainder (or leftover part). So the 9 % 2 would be '1' It can handle dividing 8 by 2, and has a leftover 1 remaining.

EDIT: Was I typing so long?????? Shocked

Oh, a child class is not weaker than the parent. It is inheriting all the goodies from the parent class. BUT, the child class 'IS' dependent upon its parent. Without the Parent class of 'Window_Base', you would not be able to run 'Window_Selectable' unless Window_Selectable had all those methods already in it.

BUT, you need to have it written class Child < Parent. You are first defining the class itself (class Child) and then attaching the contents of the parent to it ( < Parent).

It cannot go in reverse with class Parent > child. Nope nope nope.
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 }
#20
I prefer my phone booth explanation on modulo he he XD

Yeah, I updated my previous post on this page again...

ary or @ary or $ary would just be a shortcut for array (still different because they can be called from different places, $ is global so it's a data eater that checks all classes and modules looking for some new pizza to eat or a new toy to play with... while the others would just look in fewer places for such stuff) but scripters are lazy and write ary instead XP

...like typing hsh instead of hash.

class Child < Mother
end

Yeah, VVulf is right, it's not weaker, it just LEARNS from Mother what she already knows like how to eat or brush his or her teeth or hair (it learns it can execute those methods at will).
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }


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



Users browsing this thread: 1 Guest(s)