RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Syns Variable Tutorial

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 88
Since I closed my site, and retired from the program I thought I should psot some works I have done over the years.

Syns Variable Tutorial
Explains which each of the commands and options in the variable screen does, and how you can manipulate them to your own liking.

Quote
-Intro-
Quote

X - 32(2)

Now, you might be thinking, what the hell is with that? All the equation above is saying is that X is subtracted from 32 which is doubled. If you know basic concepts in Math then this In-Depth look of Variables should be amazingly easy and straight forward for you.

Before we start looking how to use variables, how about we first look at what a variable is and what it can be used for. Simply stated, a 'variable' is an unknown value, it is a number that is unknown and can be anything as long as the resulting number is a real number. Commercial games don't have these 'switches' so they are based on numerical values to determine what happens and when it happens. In the make-up of a game, there are many unknown values, such as the Player level at a certain point. The range of the players level can be anywhere from really low or really high, so instead of having a ton of if branches for every single possible level variables store the data and are then used in equations to determine the outcome of a specific event. It may sound complicated, but all we are doing is working with an unknown value. If you know how to work with unknown values on paper then working with them on RMXP should be like eating a piece of pie.

Now, what can I do with variables? Well, matter of fact, you can do almost anything with them. You can store Numerical data in them, you can store Global variable data, you can display information on screen, add the variable into an equation to receive a result.

-Usage of Variables-

Like I stated above, you can use a variable for anything. Now, I am going to list possible events that can be done with use of a variable:
1 Bank System: The unknown value in a bank system is the amount of money stored into the bank. When the player adds money into his/her account then a specific variable which handles the amount of money in the bank is added. Once a certain amount is withdrawn, then a variable is subtracted. It is basic addition and subtraction.
2 Battle Systems: Battle system may use the most variables out of anything, you have each players HP, SP, STR, AGI, DEX, INT, the enemies stats, Attack power, weapon equips, and who knows what else. The Unknown Value is stored within a variable and then deposited into an equation which, after complete, does a specific function.
3 A lot more, getting late so I want to hurry up, lol :p

-Variable Operation Window, Explained-
I am lazy so now screens, sorry.

Specific Variable: This handles the 'specific variable.' For instance, if you had a variable named "Player Kills" any operations you do will result in the mathematical functions which change the value of this variable.

Variable Range: Instead of handling and changing the values of one variable, you can change the values of many variables at any given time.

Operations: Here is where you tell RMXP what you want to do with this variable. If you select "+" you are defining the addition of a specific value. "-" is the subtraction of the specific variable. "*" is the multiplication of a specific variable. "/" is the division of a specific variable. "Set" is where you can make a variable equal a specific value defined as a constant, for example, I want "Player kills" to equal 1. So I select set and 1 in the constant box.

Constant: This handles the amount you wish to Add, Subtract, Multiply or Divide. For example, if you want to have "Player Kills" add "1" then you select "+" in Operations and set the constant to "1."

Variable: This handles the same as a "Constant," however, instead of modifying the values of a unknown value with a known value you are now changing the values of the "Specific Value" with an unknown value. For example, if I want "Player Kills" to add by "Player Lives," I will select the respective variables. So if "Player Kills = 0" and "Player Lives = 3" the new result for "Player Kills" will be three as it adds the value from the "Player Lives" variable.

Random Number: The Random Number option works similiar to "Set." However, instead of setting the variable you allow RMXP to set the variable based upon the range specified. For example, I want "Player Kills" to be a random number of 2 and 4, I select the variable as a specfic variable, place "2" in the first random box and "4" in the next. Now, "Player Kills" is a random number everytime the event is ran.

Item: This refers back to when I said you can store 'almost anything' in a variable. With the Item option you can place the data of an item into a variable. Honestly, I don't sue this option often as a Conditional Branch has a similar option.

Hero: This option allows you to store the values of the stats or traits of any hero registered in your database. This comes in handy when you wish to check the heroes Health Points.

Monster: Similar to the "Hero" option, you can store the stats of a monster present on the battle field into a variable and then use the variable for other additional actions.

Sprite: I use this option the most. With this you can have a variable store 'Sprite' data. This includes the X and Y values of the specific sprite, the terrain tag (Map ID) or the Screen X and Y.

Other: With this option you can store a few interesting bonus stats, such as amount of times saved, money, number of seconds and etc.

----END----

Hopefully you enjoyed this tutorial. Although I mainly state what a Variable is and how you can use it, I hope you can benefit from this tutorial and understand the way the Variable Operation window works and eventually mater the commands. After all, Practice makes perfect. If you compare this tutorial to other Variable tutorials out there this one is almost 2-3 times as long :p

Enjoy,

Synthesize.