[Eventing]The Global Value RM(XP/VX), (Amateur) Break free from Event restrictions |
|
|
|
|
Aug 8 2011, 01:21 PM
|

Guru of Water

Group: Revolutionary
Posts: 1,096
Type: None
RM Skill: Masterful
Rev Points: 5

|
Hopefully if you're reading this you have a good grasp on variables and switches.
Now, I want to bring up the lesser known Global Value.
If you understand scripting, this tutorial may not offer you much, as it introduces simple scripting ideas. You will already know most of what is in here. But for those who don't know much of any scripting, here is your chance to learn easily learn some basics.
Let me start off with the global value, and touch on it's brethren.
As you should know, a Variable is something that holds a number. A switch is something that holds a value of ON or OFF. (true/false)
What you may not know is variable is a bit misleading. Both a switch and a "variable" are variables. The variable that holds only numbers is more specifically a fixnum. It holds values of numbers, whereas a variable can hold any data (words, numbers, true/false,etc.) and is able to be changed. I need to teach you this because I need to separate them for you.
From now on, think of variables as something that can hold any kind of data.
...
Great! You're set. So lets move on to how to use these variables.
First, we gotta decide on where we can and can't use these variables. We'll call where we can use them local, class, and global. Explaining local and class would require me to go into more scripting detail than you'd like, so we'll skip them. Suffice to say, you won't be using them in this tutorial.
That leaves Global. Global variables can be used anywhere. That's great, cause then we can tell the game hey, lets make a global variable at level 1 then at level 20 we can still reference that variable. The drawback is that at any time it can be changed, so you have to be careful with it. Compatibility issues may arise if you name one variable, forget, and create another variable with the same name and overwrite your old variable. So always name your variables with care and thoughtfulness.
Now, the proper way to set up a global variable is like so:
$variablename
The $ always starts a global variable. "variablename" is where you put the name of the variable.
So, $apple could be a good variable name. Especially if you're trying to keep track of information about an apple.
Lets say we want to make that variable hold how many apples we have. The proper way to do that would be:
$apple = 10
But hey, how do we even do this in our RPG Maker program? Well, there should be an Event called "Script..." We just put it on one line in the space it gives us.
Now, we have told the game we have a global variable called apple. It's value is 10. To us, that means we have 10 apples.
But what use is this?
Well, lets say we want to give apples away.
So, if we talk to someone and give them an apple, we'd reduce apples by 1.
$apple = $apple - 1
It may be beneficial at this point to learn a little bit of basic programming somewhere.
(Putting this tutorial on hold. I feel it could be very beneficial for people starting to get the hang of Events and Scripts so they can integrate very low level scripting into their work. This allows for much more robust game play. However, I'm not sure how difficult the concepts ahead will be, and how to explain them without explaining a class period worth of material.)
__________________________

|
|
|
|
|
|
|
|
 |
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
RPG RPG Revolution is an Privacy
Policy and Legal
|
|