09-07-2017, 04:45 AM
(This post was last modified: 09-07-2017, 04:52 AM by DerVVulfman.)
( ) 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.
{ } 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.
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.
{ } 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.