![]() |
||||||||||||||
|
||||||||||||||
blade2k
» articles & tutorialsVariables
The variable is a crucial term in rm2k. It is one of the most important aspects a rpgmaker has to manipulate for a game to be fun. But what exactly is it? Simple. A variable is just a carrying case for a value. Any number you can think of can be stored into a variable, as long as it doesn't pass the rm2k limits. Why is it such a big deal? Because numbers are what computers understand. And it is what RM2K understands. The Change Variable function helps you manipulate variables any way you want by selecting a variable, the operation (set, add, subtract, multiply, devide, mod) and the value given to the operation. Why would you need variables? Well, lets say in your game you want to show how many baddies you've beaten with that sword: :SAMPLE CODE: New event - Parallel Process Event <>ChgVariable[001:Baddiesdead] set 0 <>Wait 50 <>ChgVariable[001:Baddiesdead] + 1 <>Wait 10 Try it out. The Change Variable command is on the first page of the event editor. A box with the words "variable management", or something to that extent, across the top will appear. Select your variable and the proper operation. See the help file for more help with the operators, if needed. That didn't do anything? Yes it did! It stored the number 0 into your variable, then added 1 to it! How can you be sure? Try this nifty tool: <>Mssg:"v[001]" This command returns the value of whatever variable number you put in there, between the []. Each variable will have a number corresponding to it in the variable manager. Use the above message command to check different values at different times in your game. You'll need it, eventually. Check the help file if needed. :SAMPLE CODE: New event - Parallel Process Event <>ChgVariable[001:Baddiesdead] set 0 <>Wait 50 <>ChgVariable[001:Baddiesdead] + 1 <>Mssg:"v[001] baddy killed" <>Wait 10 This is your new code. Every 5 seconds, it adds one to the baddiesdead variable. It thens shows a message, which reads "1 baddy killed". It waits a second, then resets. :APPLYING KNOWLEDGE: 1 - Jimmy has five sticks. He breaks two sticks. How many are left? 2 - Your HP, whcih is 45, is subtracted by a random number between 5 and 10 (HINT: Use the RANDOM fuction in the variable management window) 3 - Your MP is set to 21 due to a draining attack, but you use a Berry to give you back 15. You lost one of your sixteen berries. How much MP did you have? How many berries did you have left? Prophecy7k - wilikeh@hotmail.com Send any questions or comments. |
|
|||||||||||||
|
©2002-2008 blade2k.net - parsed in 0.012 seconds - view active users
[16241 members][newest member: Shimanloreth]
Active Users (0)
|
||||||||||||||