RPG Maker MV Show Conditional Text Using String Variables (Without Plugins)

Welcome, guideoui.com visitors. In this guide, We try to focus on RPG Maker MV Show Conditional Text Using String Variables (Without Plugins). While writing this guide, we pick up many pieces of information from several sites for you. We hope that this guide will help you.

In rpg games we often have more stats that gain levels than just the level of a character. The character may also have “swordsmanship”, “archery”, “cunning”, etc. All these may need their own xp to levelup, and, since the combinations are so many, you can’t put “Show Text” commands inside conditions. In this guide we will learn how to simply create a text that has conditional information with a single “Show Text” command without using any plugins and (almost) without using any script.

In this example we will have 4 stats that gain levels. “Swordsmanship”, “Archery”, “Cunning” and “Tactics”. The reason we have 4 is because showing all combinations would then need 16 “show text” commands. However, we will make it with just one text window.

Show Conditional Text Using String Variables

1. Setting up initial integer variables

Create an Autorun event that we will use for setting up our initial variables. This event will only be used once, so end it with a “self-switch A=true” and make a second page with “self-switch A” as a condition, action trigger and nothing inside

Now, back to the first page:

VswordLevel=1
VarchLevel=1
VtactLevel=1
VcunLevel=1

These are the starting levels of our skills. Let’s assume they always start with level 1.

VswordXp=0
VarchXp=0
VtactXp=0
VcunXp=0

These are the variables that hold our current xp for each skill. I assume they start at 0 xp.

VswordCost=40
VarchCost=40
VtactCost=40
VcunCost=40

These are the xp costs for our skills to levelup. So when these are reached, the skill will levelup.

VbaseXpGain=5

This is how much xp each skill will gain for each action.

For the next variables we will also need their IDs. So i will provide them below:

ID11: VswordAdd=0
ID12: VarchAdd=0
ID13: VtactAdd=0
ID14: VcunAdd=0

You don’t need to set up the ones that are 0 since they are automatically set to 0 at the beginning of the game. I am showing them to show which variables we will be using and their IDs.

2. Setting up initial string variables

A string variable is a variable that holds a series of letters instead of numbers. The question that comes in mind is “how on earth do i make a variable hold a string?”. Well the answer is pretty simple.

Control Variables -> Vstring1 -> Script -> “Enter string here” (with quotes)

Now the variable, when called, will show:
(text window starts)
Enter string here
(text window ends)

So now let’s set these up. The first string variable we need is an empty string, so that it can be called whenever we don’t want to show anything. Now, the string can never be empty (unfortunately, when it’s empty it just displays a 0), so we will just put the default color code inside:

ID:20 VstringEmpty=”\\c[0]”

Note the double backslashes there. They need to be double, because a double backslash in a text window is transformed to a single visible one. When the string is called in a text window, the single one will initiate a text code.

Now we will need to set up string variables for when it is time to show a skill xp gain.

ID: 21 VstringSword=”Swordsmanship +\\v[11] XP”
ID: 22 VstringArch=”Archery +\\v[12] XP”
ID: 23 VstringTact=”Tactics +\\v[13] XP”
ID: 24 VstringCun=”Cunning +\\v[14] XP”

Note that just like color codes, you can include other variables inside, but always with double backslashes. Now they will display our “Add” variables for each different skill.

3. Variables of Variables

Now we have to make a variable whose ID is another variable. So let’s make the variables of the IDs first:

ID: 31 VidSword=20
ID: 32 VidArch=20
ID: 33 VidTact=20
ID: 34 VidCun=20

Remember, ID: 20 is an empty string variable. So now let’s go on to make the variable we needed at first:

ID: 101 VshowSword=”\\v[\\v[31]]”
ID: 102 VshowArch=”\\v[\\v[32]]”
ID: 103 VshowTact=”\\v[\\v[33]]”
ID: 104 VshowCun=”\\v[\\v[34]]”

With this, our final text window, in the very end of this guide, will only have to show:

\v[101]
\v[102]
\v[103]
\v[104]

But we will end the guide with this. Before we do this, we need to set up a common event.

4. Common Event “Conditions”

Now we come to the crucial part. These conditions are the ones that choose to display text or leave it blank. Here is a list of what we know so far, that will help us better understand this:

ID11: VswordAdd=0
ID12: VarchAdd=0
ID13: VtactAdd=0
ID14: VcunAdd=0

ID: 21 VstringSword=”Swordsmanship +\\v[11] XP”
ID: 22 VstringArch=”Archery +\\v[12] XP”
ID: 23 VstringTact=”Tactics +\\v[13] XP”
ID: 24 VstringCun=”Cunning +\\v[14] XP”

ID: 31 VidSword=20
ID: 32 VidArch=20
ID: 33 VidTact=20
ID: 34 VidCun=20

Now to create the conditions:

IF VswordAdd>0, VidSword=21
ELSE VidSword=20

IF VarchAdd>0, VidArch=22
ELSE VidArch=20

IF VtactAdd>0, VidTact=23
ELSE VidTact=20

IF VcunAdd>0, VidCun=24
ELSE VidCun=20

In this manner, whenever we have xp to add to a specific skill, the specific variable ID will be called to show we did that, while if we don’t have any xp to add, we just call the empty string, not showing anything.

5. Common Event “Levelup Checks”

We need this event to check whether any of our skills has leveled up. Simply:

IF VswordXp>=VswordCost

VswordLevel+=1
VswordXp-=VswordCost
VswordCost*=2
Show text->”Swordsmanship level up!”

IF VarchXp>=VarchCost

VarchLevel+=1
VarchXp-=VarchCost
VarchCost*=2
Show text->”Archery level up!”

IF VtactXp>=VtactCost

VtactLevel+=1
VtactXp-=VtactCost
VtactCost*=2
Show text->”Tactics level up!”

IF VcunXp>=VcunCost

VcunLevel+=1
VcunXp-=VcunCost
VcunningCost*=2
Show text->”Cunning level up!”

6. Seeing it in action

So now we have everything set up to see it in action. So let’s say your character is at a series of decision making points:

Show text->”An enemy goblin appeared! You quickly grab for your…”
Show choices->Bow, Sword

When Bow
VarchAdd+=VbaseXpGain
Show text->”…bow and shoot it down!”

When Sword
VswordAdd+=VbaseXpGain
Show text->”…sword and slice it in half!”

Show text->”As you were battling it, another one came from behind you! You quickly thought that it would be wise to assume a better position, or to pretend you didn’t see it! You…”
Show choices->Position, Pretend

When Position
VtactAdd+=VbaseXpGain
Show text->”…jump forwards to gain some distance, while turning around to face it!”

When Pretend
VcunAdd+=VbaseXpGain
Show text->”…pretend you didn’t see it, so that you catch it off guard!”

Show text->”The goblin marches towards you with its weapon pointing at you! You decide to…”
Show choices->Bow, Sword

When Bow
VarchAdd+=VbaseXpGain
Show text->”…use your bow and shoot it down!”

When Sword
VswordAdd+=VbaseXpGain
Show text->”…use your sword and slice it in half!”

Run common event “Conditions”

Show text dim,top->”Fight Results”
Show text dim,middle->

\v[101]
\v[102]
\v[103]
\v[104]

VswordXp+=VswordAdd
VarchXp+=VarchAdd
VtactXp+=VtactAdd
VcunXp+=VcunAdd

Run common event “Levelup Checks”

VswordAdd=0
VarchAdd=0
VtactAdd=0
VcunAdd=0

Et voila! Now this simple 4-line text covers ALL combinations of xp adding, even if you had 100 choices one after the other. You could make a huge battle, with potions that raise xp gain, with specific level requirements for specific actions, with time travel enabling you to go backwards in your choices if you have enough energy, etc etc. It would all end to a single text window of the fight’s results.

Some Notes

Always remember that in string variables, ANY text codes must have a double backslash “\\”.

You could work with Yanfly’s message plugins to create a large message window of results, since it supports up to 16 lines. This could mean that you can have up to 16 different skills displayed there. The logic is the same as the one we followed in this example.

Yanfly’s plugins would also enable you to Disable or Hide Choices, depending on conditions – for example if your swordsmanship skill is too low. You could go wild with these conditions. For example, a cunning option which uses your sword would require cunning but would also award sword xp.

You could also work with other plugins that allow events at battle-end to incorporate this logic in your actual battles! A swordsmanship skill can then do what you want it to do and add swordsmanship xp additionally!

Always remember to initialize your variables so that they aren’t added in the next instance. In my opinion, you should always have START variables, that hold the initial values, so that you don’t always have to initialize them with numbers. Also, this could come really handy if you want to change a variable temporarily, like xp gain potions, that would raise your xp gain for this battle, but their effect would wear off after it. Then, instead of doing xpgain=5, you would just do xpgain=xpgainSTART

You could also add color codes to the strings to better show the skills you are showing. For example, cunning could be purple, so in the appropriate string you could add a \\c[31] at the start. Alternatively, you could always include all the xp gain strings, but keep them white if they don’t show any change, or green when you gain xp. Although the code would need some transformation, the logic is pretty much the same.

To enhance gameplay, it’s not wise to always have the player know which stat they are affecting by which option. Drinking a health potion just before you die might be “cunning” while drinking a health potion early on might be “tactics”. The point is to categorize truly tactical and cunning actions and assign them according to the player’s playing style. For the player, it would be intuitive that drinking a potion early on means thinking ahead (therefore “tactics”), without having to see it written.

These skills may unlock additional options, or even passages, in the game map. “Cunning” for example could unlock passages. “Tactics” could unlock starting a fight with buffs, since the party assumed a more tactical position (for example “this cliff is perfect as an advantage point! Let’s draw them here!”)

Typos:

As always, i could have made typos, which are crucial when writing guides like this which show code – or at least pseudo code. A single typo could make the whole thing not work. So please, if you find any, tell me.

This is the ending of RPG Maker MV Show Conditional Text Using String Variables (Without Plugins) guide. I hope it will help you. If there is wrong or you have suggestions, please let’s know and comment us. Have fun.

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *