Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 RGSS scripting dissections and explinations
#43
(09-10-2017, 03:36 AM)DerVVulfman Wrote: Shocked An Evil PodPod?   Nooooes!!!!

Oh, you can TOTALLY screw things up with substitution... if you accidentally erase one thing with another by accident.  But on the subject of substitution, let me break Kyo's first example.

@substituted_player = Player.new
Here, we have a variable called @substituted_player.

In it, we tell it that it is equal to our Player class.  While nor ahown specifically, let's just assume it is like having the RPGMaker XP class "Game_Player", okay?  When we 'start up' that class, we run it like "Game_Player.new", so here we make THIS class run as "Player.new".

So here, we make @substituted_player become a new 'copy' of the Player class.  


@substituted_player.name = "Stan"

FIRST... let's assume that the 'Player' class we made has a property (a value it can read/write) called 'name'.

This is basically telling the @substituted_player (copy of Player) that its name property is now 'Stan'.

It wouldn't work if the Player class doesn't have a name property to change.  But for a point of argument, we're assuming that the Player class DOES have a name property.   I explain properties a little below.


print "#{@substituted_player.name}, the kind of old hockey player, steps out right now and gets a seat in no time."
This statement is printing out...
=> "Stan, the kind of old hockey player, steps out right now and gets a seat in no time."

Here, we see the odd bit of code...  #(@substituted_player.name)

When the program reaches the #( ..blahblahblah.. ) bit of code, it becomes replaced with the name stored within @substituted_player.name ... aka Stan.

Happy Being able to replace strings (aka the words in a message) is quite useful.  I mean, there is a 'Name Input' thingie in RPGMaker where you can change your character's name, right?  This is just another way to change a character's name.




Golf Rugby on ICE?    ROFL!!!   I LOVE IT!!!  Laughing




Now you heard me say (or read me type?) the word 'property' when I referred to the Player class in the example above.  It's a bit of tech jargon.

Most Classes are made from a whole bunch of methods.  But classes (like the Game_Player, Game_Character, etc) that deal with data have a whole lotta properties... or info that can be READ.

For example, you have in the Game_Actor class, a bunch of values near the top of the script, and a whole lotta methods.

When there is some bit of data that you can read from a class, it is a property.  For example, the Game_Actor class (which defines an individual actor or game hero) has a character's ID, an index, their name, and so on.  Some of this can be changed easier than others.  Some not so much.

Just a primer to prep you, knowing the learning curve you're struggling with ... I'm not being specific or anything.

thats ALOT of info!

I'll ponder over all this at another time and then get back to it once I have a better grasp!
thanks!
[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-10-2017, 05:30 AM

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



Users browsing this thread: