A nice tutorial by andiaz concerning variables, from basics to advanced.

Alright, here we go, another tutorial by me. In this one, I’ll try to explain everything about Variables. It will be quite tough, but I hope I’ll manage. Let’s get started then:

Basic uses

If you haven’t heard the word Variable before, I suggest that you take look in a book about Algebra, and I’m sure that you’ll understand more. A variable is actually a slot that can hold different values. We all know that we can modify numbers, like adding 4 to 3, and we’ll get 7. If we add 4 to a variable, the variable will get 4 more than it had before. Quite simple.

There are 6 different operations you can perform with the variables in rm2k:

1. “Set” sets the variable equal to a number.

2. “+” adds a number to the variable.

3. “-“ subtracts a number from the variable.

4. “*” multiplies the variable by a number.

5. “/” divides the variable by a number. AND, it also cuts off the remainder. For example, if you have 3.4, it’ll be 3 in rm2k.

6. “Mod” divides the variable by a number, but it only keeps the remainder. For example, 3.4 would be 4 with the Mod function in rm2k.

More complex stuff

There are three sections in the variable management screen: “Variables”, “Set” and “Operand”. The first section, “Variables”, is the place where you choose the variable(s) you will modify. The most common use of this part is, of course, just to check the first button (One). The variable that you choose gets a number added, subtracted or whatever. But, the second option (Range) is actually quite useful. If you need to set a lot of variables to a specific value, just use the range function. If you for example want to add a number to the variables 1-10, just use the range function and select from 1 to 10. Simple, indeed.

The “Set” option was explained under ‘Basic uses’.

The “operand” section is quite useful, hehe. This is the place where you modify the variable’s value. The common use here is the “Set” option, but the other ones can definitely come in handy too. The set option works like this: If you select variable 1 (under choose variable, One), and then set the “Set” to “/”, and then take set at the bottom (in the “Operand” section) to 5, rm2k will divide the variable by 5.

The “Operand” can also be another variable, the value of an item, your hero’s stats, or the value of an equipped item. It can also be Y or X coordinates relative to the current screen position of an event. It can also be the amount of money, the timer seconds left on a current timer, the size of the party, number of saves, number of battles, number of victories, number of defeats, number of escapes, and even the MIDI tick position O_o! For example, a 4/4 MIDI on beat 2 of a given measure would make the number 2.

Why do I need variables?

Variables are good for a lot of things. It’s impossible to do a CBS or CMS without them. They can also be used to do minigames, or when you have a “stat counter”, that counts for example how many battles you have fought. To do this, just make a common event that checks how many battles you have fought all the time. Let’s say, if this is variable number 1, you’ll do the “stat counter” like this: Make a message command in the “stat counter’s” event that says: “You have fought \V[1] battles!”

Variables combined together with fork options are VERY useful. So, I might do a tutorial about fork options too someday. After all, they are just as important as variables; it’s very hard, if not impossible to make a CBS/CMS without them. I hope that you understand more about variables after reading this!

Basic uses

If you haven’t heard the word Variable before, I suggest that you take look in a book about Algebra, and I’m sure that you’ll understand more. A variable is actually a slot that can hold different values. We all know that we can modify numbers, like adding 4 to 3, and we’ll get 7. If we add 4 to a variable, the variable will get 4 more than it had before. Quite simple.

There are 6 different operations you can perform with the variables in rm2k:

1. “Set” sets the variable equal to a number.

2. “+” adds a number to the variable.

3. “-“ subtracts a number from the variable.

4. “*” multiplies the variable by a number.

5. “/” divides the variable by a number. AND, it also cuts off the remainder. For example, if you have 3.4, it’ll be 3 in rm2k.

6. “Mod” divides the variable by a number, but it only keeps the remainder. For example, 3.4 would be 4 with the Mod function in rm2k.

More complex stuff

There are three sections in the variable management screen: “Variables”, “Set” and “Operand”. The first section, “Variables”, is the place where you choose the variable(s) you will modify. The most common use of this part is, of course, just to check the first button (One). The variable that you choose gets a number added, subtracted or whatever. But, the second option (Range) is actually quite useful. If you need to set a lot of variables to a specific value, just use the range function. If you for example want to add a number to the variables 1-10, just use the range function and select from 1 to 10. Simple, indeed.

The “Set” option was explained under ‘Basic uses’.

The “operand” section is quite useful, hehe. This is the place where you modify the variable’s value. The common use here is the “Set” option, but the other ones can definitely come in handy too. The set option works like this: If you select variable 1 (under choose variable, One), and then set the “Set” to “/”, and then take set at the bottom (in the “Operand” section) to 5, rm2k will divide the variable by 5.

The “Operand” can also be another variable, the value of an item, your hero’s stats, or the value of an equipped item. It can also be Y or X coordinates relative to the current screen position of an event. It can also be the amount of money, the timer seconds left on a current timer, the size of the party, number of saves, number of battles, number of victories, number of defeats, number of escapes, and even the MIDI tick position O_o! For example, a 4/4 MIDI on beat 2 of a given measure would make the number 2.

Why do I need variables?

Variables are good for a lot of things. It’s impossible to do a CBS or CMS without them. They can also be used to do minigames, or when you have a “stat counter”, that counts for example how many battles you have fought. To do this, just make a common event that checks how many battles you have fought all the time. Let’s say, if this is variable number 1, you’ll do the “stat counter” like this: Make a message command in the “stat counter’s” event that says: “You have fought \V[1] battles!”

Variables combined together with fork options are VERY useful. So, I might do a tutorial about fork options too someday. After all, they are just as important as variables; it’s very hard, if not impossible to make a CBS/CMS without them. I hope that you understand more about variables after reading this!