A guy at GameFAQs was asking about variables on the RPG Maker 3 board. From what I could gather, he knew next to nothing about them. I took it upon myself to attempt to disseminate my knowledge in a way that someone with no programming experience can wrap his mind around and grab onto. Much to my surprise, he said that my explanation was very helpful (I hadn't thought that it would be).
I'm posting this here because GameFAQs eventually purges old messages, and who knows... It may be a helpful variable resource to someone. As always, I'm just trying to help.
~*~*~
A variable is one of the most basic things in programming. Being able to manipulate variables enables us to create video games.
A variable is a "thing" that holds a number. It can be any number that you (the programmer) choose. All variables start with a value of zero. A variable's value can mean anything that you want it to. The value of the variable is what the computer is interpreting. The programming that we (the programmers) do with variables enables us to communicate with the computer in such a way that we and the computer are on the same page. The computer is interpreting what we've programmed and is acting on it, and we are giving the numbers a meaning.
So, Shared Variable 01 has a value of 0 (zero) at the start of the game. This value of zero can mean anything that you want it to mean. Let's explore some examples.
The player needs to collect five emeralds and trade them to a merchant for a useful weapon. We would use a variable here that tells the computer how many emeralds the player has collected. Make a treasure item and name it "Emerald". Now create five separate events and place them on the map. Each event where we find an emerald gives the player the treasure item and increases the variable by 1. The computer is tracking how many of these emeralds the player has collected. The merchant should use a Val Condition Branch that checks the value of the variable to see if it equals 5. If it equals 5, then the merchant can offer to trade a weapon for the five emeralds we've collected.
Another example: A townsperson says that a dragon has been attacking the village. The player needs to find this dragon and defeat him. For this situation, we would use a variable.
If Variable = 0 then [dragon hasn't been defeated yet]
If Variable = 1 then [player defeated the dragon]
The values I'm assigning to the variable here mean something to me, and they also mean something to the computer. I'm communicating with the computer to achieve my desired result. So when you talk to the townsperson, he should have a Val Condition Branch that checks the value of the variable. If it = 0, then he should tell you that the dragon has been attacking the town. If it = 1, then he should congratulate you for defeating the dragon.
Edit: Logically, the event where we defeat the dragon should increase the variable by 1 or modify it so it =1.
These are simple examples. You can take it much further than this, and add whatever you want. You can add any number of other conditions and meanings for variable values.
Use a different shared variable for each thing that you're keeping track of in your game. Internal variables work the same way, except that they are associated with specific objects (characters, events, and things). You can use shared or internal variables. Doesn't matter.
What's important to understand is that at any given time during the game, each variable has a value that means something. The value (number) that the variable holds is what the computer is interpreting (what it means to the computer). The meaning that you give the variable is how you are interpreting it. You and the computer are working as a team, each interpreting the variable in a different way but achieving the same desired result with it.
Increasing a variable's value adds to it. Decreasing it subtracts an amount from it. Modifying a variable sets the variable's value to that number regardless of what it was before. i.e. Shared Variable 01 = 5. I modify it so it = 10. It now = 10.
"Shared Variable 01" is the designation of which variable it is. It's the variable's name.
~*~*~
I'll give you something more to ponder.
Computers work with numbers. That's how they operate. It's the "language" that computers understand. They interpret numbers and give the numbers meaning for us, the users. Right now, as you read this, your computer is interpreting numbers and using them. It uses numbers to create the graphical display of this webpage.
When I type the letter "W" on my keyboard, the computer is rapidly interpreting the keypress of the "W" key, understanding what it means, and using numbers to generate a graphical representation of the letter "W" on my screen. It looks like a "W" to me, but to the computer it has a completely different meaning. The letter "W" is composed of numbers that the computer understands. It interprets the letter "W" as a bunch of numbers. We interpret it as the letter "W".
Your PS2 works the same way. It interprets numbers and uses them to generate the graphical display, text, animation, music, everything that goes on in a video game. The PS2's CPU (computer) speaks in a language of numbers. That's what it understands. The trick for any programmer is to understand how the computer thinks and what it understands. It understands numbers.
We give all those numbers a meaning. The graphical display is full of numbers that designate color, texture, and everything you see onscreen. It means something to us because it's been programmed to do that. The computer is speaking in its native language, and the programming is translating it into images that we understand.
Variables work the same way. The computer interprets a variable in its native language of numbers. We give the numbers a meaning.
Understand that you need to communicate with the computer in terms that both you and the computer can understand. The computer doesn't understand our language or the way we think. It understands numbers. The trick for any programmer is to learn the computer's language and use it to communicate with the computer. Then you can achieve whatever results you desire.
A variable is a way that you are communicating with the computer. It's a number, and you can use it any way you want and give it whatever meaning you want.
I'm posting this here because GameFAQs eventually purges old messages, and who knows... It may be a helpful variable resource to someone. As always, I'm just trying to help.
~*~*~
A variable is one of the most basic things in programming. Being able to manipulate variables enables us to create video games.
A variable is a "thing" that holds a number. It can be any number that you (the programmer) choose. All variables start with a value of zero. A variable's value can mean anything that you want it to. The value of the variable is what the computer is interpreting. The programming that we (the programmers) do with variables enables us to communicate with the computer in such a way that we and the computer are on the same page. The computer is interpreting what we've programmed and is acting on it, and we are giving the numbers a meaning.
So, Shared Variable 01 has a value of 0 (zero) at the start of the game. This value of zero can mean anything that you want it to mean. Let's explore some examples.
The player needs to collect five emeralds and trade them to a merchant for a useful weapon. We would use a variable here that tells the computer how many emeralds the player has collected. Make a treasure item and name it "Emerald". Now create five separate events and place them on the map. Each event where we find an emerald gives the player the treasure item and increases the variable by 1. The computer is tracking how many of these emeralds the player has collected. The merchant should use a Val Condition Branch that checks the value of the variable to see if it equals 5. If it equals 5, then the merchant can offer to trade a weapon for the five emeralds we've collected.
Another example: A townsperson says that a dragon has been attacking the village. The player needs to find this dragon and defeat him. For this situation, we would use a variable.
If Variable = 0 then [dragon hasn't been defeated yet]
If Variable = 1 then [player defeated the dragon]
The values I'm assigning to the variable here mean something to me, and they also mean something to the computer. I'm communicating with the computer to achieve my desired result. So when you talk to the townsperson, he should have a Val Condition Branch that checks the value of the variable. If it = 0, then he should tell you that the dragon has been attacking the town. If it = 1, then he should congratulate you for defeating the dragon.
Edit: Logically, the event where we defeat the dragon should increase the variable by 1 or modify it so it =1.
These are simple examples. You can take it much further than this, and add whatever you want. You can add any number of other conditions and meanings for variable values.
Use a different shared variable for each thing that you're keeping track of in your game. Internal variables work the same way, except that they are associated with specific objects (characters, events, and things). You can use shared or internal variables. Doesn't matter.
What's important to understand is that at any given time during the game, each variable has a value that means something. The value (number) that the variable holds is what the computer is interpreting (what it means to the computer). The meaning that you give the variable is how you are interpreting it. You and the computer are working as a team, each interpreting the variable in a different way but achieving the same desired result with it.
Increasing a variable's value adds to it. Decreasing it subtracts an amount from it. Modifying a variable sets the variable's value to that number regardless of what it was before. i.e. Shared Variable 01 = 5. I modify it so it = 10. It now = 10.
"Shared Variable 01" is the designation of which variable it is. It's the variable's name.
~*~*~
I'll give you something more to ponder.
Computers work with numbers. That's how they operate. It's the "language" that computers understand. They interpret numbers and give the numbers meaning for us, the users. Right now, as you read this, your computer is interpreting numbers and using them. It uses numbers to create the graphical display of this webpage.
When I type the letter "W" on my keyboard, the computer is rapidly interpreting the keypress of the "W" key, understanding what it means, and using numbers to generate a graphical representation of the letter "W" on my screen. It looks like a "W" to me, but to the computer it has a completely different meaning. The letter "W" is composed of numbers that the computer understands. It interprets the letter "W" as a bunch of numbers. We interpret it as the letter "W".
Your PS2 works the same way. It interprets numbers and uses them to generate the graphical display, text, animation, music, everything that goes on in a video game. The PS2's CPU (computer) speaks in a language of numbers. That's what it understands. The trick for any programmer is to understand how the computer thinks and what it understands. It understands numbers.
We give all those numbers a meaning. The graphical display is full of numbers that designate color, texture, and everything you see onscreen. It means something to us because it's been programmed to do that. The computer is speaking in its native language, and the programming is translating it into images that we understand.
Variables work the same way. The computer interprets a variable in its native language of numbers. We give the numbers a meaning.
Understand that you need to communicate with the computer in terms that both you and the computer can understand. The computer doesn't understand our language or the way we think. It understands numbers. The trick for any programmer is to learn the computer's language and use it to communicate with the computer. Then you can achieve whatever results you desire.
A variable is a way that you are communicating with the computer. It's a number, and you can use it any way you want and give it whatever meaning you want.




Comment