Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 RGSS scripting dissections and explinations
#8
( ) The Parenthesis.
Now this little beauty is STILL used in math, to denote modifications to normal order of operations (aka the precedence rules).
But if you've been looking at scripts, you may have seen methods or even ruby commands followed by a parenthesis holding some values. So it would be safe to accept that parenthesis are used in Ruby for either math purposes or to hold/list values that a Ruby Statement will be needing.

Such statements would be like Color.new(255,0,0,255,) ... That makes RED color if you know your R G B A coding.


[ ] The Brackets.
Oh this is used more for arrays, regardless of how the array is used. OR, it is used to identify a KEY in a hash array. Long story, not yet for beginniers.... it is another story.

Just think like this. If you look at Game_Actor and see the @skills array, this holds just the IDs of the skills an actor holds. Not really complex... When Aluxes starts playing, his own @skills array will have a value of 57 thrown into it (Crosscut) while Gloria's own @skills array will start with just '1' in it (Heal). Simple values, easy to manipulate to a degree.

Now if I told you that a string ( a variable that holds text data like their character names ) was actually an array, would you go bonkers?

You also pick the value in an array by its INDEX value, with 0 as the first value. So if an array is like [23, 5, 262, 4, 99], the INDEX value of 0 would retrieve '23'. And Index value 4 would return the value of '99'.

You may see something like $game_party.actors[0]. @actors is merely an array of actors by their ID. So the so-stated statement would get the ID of the first 'actor' in your party. Winking


{ } The Braces. This part is a bit more advanced....
Used to great extend in hash arrays, otherwise known as hashes. Whereas an array holds a list of values, a hash can hold a list of values 'or' a list of arrays!. While the Game_Actor class might have @skills for a regular array, the Game_Party class has an @items 'HASH' array which holds the items in a special manner. And you access the value of a specific hash value by a 'key' value instead of an Index.

I could access and see if the party has a Seed if Strength, by checking to see if @items[19] has a value other than 0. Do note that the key value I mentioned is in BRACKETS... so it is like HASH_ARRAY[key] = value . In the default scripts of RMXP, the values are typically just numeric values (for the quantity of items, weapons, skills) or true/false values for battle effects. Nothing TOO complex there.

And, man do I use these in my CONFIG setups... Stuff can be complex, so I try to give instructions how to fill them out.

Braces are also used in complex string manipulations, if the headaches of a MESSAGE system isn't enough.

And braces are used to encapsulate special LOOP systems that run similarly to the old FOR...NEXT loop. Like I said about the *arguments value earlier, it is a coder's shortcut. Hard to grasp, but surely takes fewer lines.
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, 04:45 AM

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



Users browsing this thread: