RPG Maker MZ

RPG Maker MZ

Not enough ratings
Advancing Your Game with Variables
By degicagames
In this Official RPG Maker MZ Guide, we'll take a look at how to control the flow of your game's story using variables by starting a simple game about finding a lost cat.
   
Award
Favorite
Favorited
Unfavorite
Intro
Official Guide from bgillisp

Variables in RPGMaker are very powerful. One way they can be utilized is to control the flow of the plot in a game so that the player has to do events in a particular order. In this tutorial we will show how to use variables to do just that, at the beginning of a find the missing kitty quest.

First, we need to designate a variable for our plot flow. I usually use variable 61 for this, though any variable that your plug-ins (or scripts if using XP, VX or VXAce) are not using works fine for this. Name the variable so you know what it is. I named this one plot flow variable.

Set Up Map
Next, we start the game on a blank map that we call set up map. This is so we can do anything we need to do before the game starts like give the party items and such. In this case I give the party 99 of many potions, but you can use this for anything you wish. Once I’m done with that, I transfer the party to the next map, and advance my plot flow variable by 1. The event looks like this when finished.

Starting Map
Next, on the first map of our game, we have an event set to run with our plot variable is greater than or equal to 1. At the end of the event, we set our plot variable to 2 before we end the entire cutscene. The event is set up as follows:



Also the autorun has a page 2 set to run when the plot variable is greater than or equal to 2, like so:



This way the autorun never runs again, as our variable is now set to 2.
Finding the First NPC
But that is not all we can do. Let’s say we want you to find an NPC to continue the game. The NPC is set to no condition as it is impossible for you to skip this scene first, though if you want to be really safe set them to also only show when the game plot flow variable is greater than or equal to 2. However once you interact with the NPC we set the plot flow variable to 10, as shown here:



The reason for 10 instead of 3 is if you decide later to add more events between the intro event and talking to this NPC it is easier to do it as you still have some unused numbers than if you have all events go exactly in numerical order.

Also note that page 2 of the NPC is set up so that you have new dialogue now after talking to them the first time. This page 2 shows up when the plot flow variable is greater than or equal to 10, the same value we set on page 1.



You can set up more NPCs on the same map and have their dialogue change based on if you have spoken to this one as well using the same method too if you wished!

Locked Door
And finally, let’s assume that to go rescue this cat you need to go past a locked door, which you had to talk to this NPC to get the key to first. The locked door is initially set so you can’t unlock it if you haven’t spoken to the NPC by an event on page 1 that is set as follows:



Page 2 is then set to if plot variable is greater or equal to 10. This way page 1 only runs until you’ve spoken to the key NPC as we set our plot variable to 10 after talking to them. After talking to them, page 2 will take priority and will run instead. Page 2 is set up as follows:



Notice that at the end of page 2 the plot variable is set to 20. This is in case you wanted to have more events between getting the key and going to the door. Also, there is a page 3, which is set to run when our plot variable is greater than or equal to 20, so that we do not have to unlock the door again. Page 3 looks as follows:

Homework
This tutorial has shown one of the many ways we can use variables. Now for homework, try extending the tutorial game so that it is possible to find the missing kitty.

Now that you have seen how to use variables for plot flow, how will you use them in your game?