Variables are a bit like switches, but instead of being "on" or "off", they are set to a number. They can be used to keep track of pretty much any numerical data you could think of, which makes them invaluable in eventing complex systems.
The simplest example of variable usage would be a fetch quest.
Imagine there is an NPC who wants you to gather 3 mushrooms. For every mushroom you pick up, it increases a variable by one. Once that variable reaches three, the NPC would give you an award.
It's a pretty simple concept to understand, but it can be difficult to learn how to use variables to their full potential. Let's look at a more complex use of variables: a bank system.
This would require three variables: A variable for depositing and withdrawing money, a variable to hold the party's current gold amount, and a variable with the total amount of currency currently in the bank.
The first thing you would do is set the party gold variable to the party's current gold.
There are a lot of other options under game data that are useful to event systems, such as the X and Y coordinates that I mentioned in the list of event commands. For the sake of simplicity, we'll stick with the gold amount.
The deposit and withdrawal variable would be used in a number input command.
Using a conditional branch, you would check that the party's current gold variable is higher than the current deposit/withdrawal variable. In the case of a withdrawal, you would check that the current bank currency variable is greater than the current deposit/withdrawal variable.
If the conditions are met, you then have to give or take gold from the party if they withdrew or deposited respectively.
There's still one last thing to take care of, and that's making sure the bank currency is at the correct amount. In the case of a deposit, we'll be adding the deposited amount to the bank variable:
In the case of withdrawal, we would subtract from the variable.
And that's pretty much all you need for a working bank system. I hope this helps demonstrate some of the basic uses of variables. As you might be able to tell already, variable usage mostly boils down to basic math and knowing how to utilize it. If you need more examples to help you with variables, take a look around at some pre-made event systems and look how they did things. It's one of the best ways to learn.