Fork Conditions
- meetthemeese

- Sep 11, 2021
- 4 min read
Updated: Oct 6, 2022
I remember finding a whole page of text explaining the 'Fork Conditions' command back in the day and wondering why that was needed for such a basic command. I later realised that many who were not familiar with programming may have not found it as easy to understand in those days, even though it is a logical construct that I'm sure they would end up having to use often while building an RPG with RM2K.
I don't believe that to be the case anymore. I have no data to back up this claim, just my gut pheelings based on how ubiquitous computing tech is nowadays. But I'm still gonna write this post to up my post count ho ho ho.
What is a Fork?

Another common understanding we have for forks is from the phrase 'a fork in the road'. Or something.
A choice, basically.
Fork commands enable us to implement choices in our game. If (some condition is true)....then (this will happen)...else (this will happen instead).
They behave much the same way as the 'Conditions' Panel we've seen in the tutorial series. If someone's interested in the computer programming equivalent explanation for this, here's a nice beginner-friendly article I found on 'if' statements (don't be intimidated or embarrassed by how it's aimed at kids, that's more or less how we were introduced to programming concepts in college too).
Anywhoo, back to RM2K.
Fork conditions are used when you're faced with an if-else choice for the player. You can find it in the standard list of commands (in, say, a map event) at tab 3, column 2.
Their impact can be as small as 'IF player has this stat level, then NPC will say this line ELSE NPC will belt out some standard dialogue' to 'IF the player completed quests A, B and D in that order and collected the 4 hidden rare artefacts, then they can proceed to the tournament ELSE they get killed in an ambush on a loo break in the forest and the whole world will crash and burn because the heroes are too dead to save the day'. In this latter scenario, you'd most likely be using switches and variables to maintain the states of success/failure of the quest order and keep track of the found artefacts.
Switches and variables are just one set of objects that can be used for evaluation in a fork condition. Let's take a look at some of the others.

In the first tab, aside from switches and variables, we have:
Timer - If a timer you have running on the map has reached a certain value at the time this event is run. Naturally, if you need to wait for the timer to reach a value before doing something, then the event with this fork condition will need to run as a parallel event. An example would be timed mini-games, or timed dungeon escapes. A future post shall cover timers in detail.
Money - If your party has money above or below a certain amount.

In tab 2, we see:
Item - If the player has a certain item in their inventory (or not).
Hero - If a particular playable character is/has...and there's a bunch of self-explanatory options here.
Event - If an event on the map (player or otherwise) is facing a certain direction.
Vehicle - If a certain vehicle is being used at the time. Keep in mind that vehicles are really just special events. While a player rides a vehicle, they can't really interact with any tile on the map except to try and land/stop the vehicle there. So this option is really only useful in parallel or autorun events. A future post shall briefly go over vehicles, because they're fun to use.
Started by decision key - if the event was triggered by the decision key (Enter/Spacebar). I don't know where this is even a choice, unless you're triggering events that are on the same level and at player touch. Strangeness.
Play BGM once - If the BGM currently playing in your map finishes 1 loop. I have no idea where this may be used.
At the bottom of the window you'll see the option to 'Add ELSE case'. This just means if you select it, you get to specify what happens if the condition isn't met. If you don't select this, then you don't need to specify the ELSE case.


You can nest Forks
If you want multiple conditions to be satisfied, then you can nest a fork condition command in another (multiple times for more ...nestedness.).

Random Example
Let's build an NPC warrior that challenges all the strong fighters it comes across to a duel.
Here, our choice is IF main hero is strong enough, then NPC will want to fight ELSE do nothing.
I'm going to define "strong enough" as the main character's ATK power being >500 points.
There's no out-of-the-box option for ATK points in the fork condition command, but we do have it for variables. So we'll first store this value in a variable, and then use it in the fork condition. The basic structure of commands will look like this:

Then you add the battle or other commands in the (Fork condition = true) section (that is, the first part, where I have the message 'I challenge you to a fight!'). Pretty neat.




I think that about covers it. A basic command, more so because of how useful it is in a game than anything else.
- Meese







Comments