Variables and conditional branches, and variables IN conditional branches. A tutoriel
Hewwo, I make tutoriel yes! Anon made a request to make a tutorial on how variables and conditional branches work. and variables IN conditional branches work. I’m still sleepy, but I’ll try my best to spruce something up! There are many tutorials you can look up on google, there is even a video you can find here that goes a little bit more into detail on variables and switches.
first up, let’s introduce variables into the picture, before we can proceed to the conditional branches. So what are variables? I’m copying this from google just as an explanation. “A variable in RPG Maker is an internal number used by an RPG Maker game. Variable values can be changed by events using event commands, and can also be used for calculations and determining if parts of an event should be executed. A common use for variables is to introduce a secondary currency into a game.”
That’s the explanation from Google. Now, the way I’d explain variables is that it’s mostly used in puzzle creation, but these things can also be used for setting up simple tasks, and if you’re variable savvy enough, to make the custom title screens, but they are a pain to make. *dabs* So let’s get straight to the point.
This page is the control variables page, you see there’s a lot going on here, let me simplify it for you, just a bit y’know! To kinda.. show you what’s important in this case.
Priority takes single variables, operations are set, add and subtract, operands are constant, item, player, event and other. I wouldn’t recommend using batches, because sometimes rpgmaker can be an ass with that so I’d highly recommend only using single variables! Think of this like... pfft.. basic Math. Where you only have to do is add or subtract from the equation. Multiply, divide and... uh.. the last thing which I believe has to do with percentage, aren’t as much used. Operands are mostly constant (which is usually set to 0, but you can add any number you’d like), item, player, event and other, but items and player are mostly used.. according to me at least! Here’s a simple example of setting up a block puzzle that uses variables. apologies in advance if it comes off as rambly, and in one part, I mention the second block, but it’s actually the third block so... yea ^^;
this is, to put it simply, the first level of variables, the simple ones that is. This isn’t just limited to block puzzles, you can make a little quest where you have to collect a number of items and then bring it back to the person who requested said items. This one is a two way street because you can either add or subtract. add the items, or subtract them. so for example, person A gives you a job to do, you have to collect x amount of chickens. after the dialogue ends, you have to set up a variable of the amount of chickens you must collect. here let me show you. this is from my game ofc.
So for this one, the variable is set to 20, which means there are 20 chickens to collect. So the thing you will do here, is when you enter the area where the chickens are located, you will add a conditional branch, you said that you don’t get that part, so I’ll elaborate later. This is what it looks like upon entering the barns.
You have the conditional branch (and I see I spotted a thing that needs to be removed oops). so pay attention to the cond branch variable 106. that’s the chicken part. when it’s set to 0, there’s nothing below it. it showcases that you have finished the quest, and the usual there are/is v/106 chickens left in the barn won’t appear. when the quest of course is activated, you will get the v/106 variable dialogue that tells you how many chickens you need to collect.
this here is the page of one of the chickens, once more, it has a conditional branch, this time, the branch has a dialogue where it says the chickens are safe. point being, in order to set up the chicken event where you collect it, you have to set up 2 pages. this is the first page, the second page has a switch that will activate upon collecting it, the second page of course contains blank graphic, indicating that you have indeed collected the item. Now, you add the item, and you add your control variable, and subtract it by 1. You can copy/paste the event, but ensure that the switches are changed, so you won’t end up triggering one switch and it all goes to poof. You can also make a puzzle using a 1-9 digit code. This one is simple, you find the input number which is on the first page, choose the designated variable for it, set it to which ever digit you prefer, and then you set up a conditional branch. I will get to that part real quick.. Now don’t get me started on custom title screens, I don’t know how I can explain that one ^^; it’s.. a little complicated. ^^;
In certain parts when you are making puzzles, you will need to use conditional branches. Now what are those? Think of them as like a tree. a tree with protruding branches. Branches have their own branches, said branches grow out their own branches, so on and so forth that it becomes an entire family tree, to say the least.
This is the page for a conditional branch, you can see there are 2 pages here.
the second page looks like this. The most commonly used are switch, variable, timer, money, item, actor or event. Setting up a conditional branch is actually quite easy, all you have to do is go to page 3, click conditional branch where it loads up the picture above, and depending on the event, puzzle, whichever, you set up a conditional branch that goes like so
cond branch > switch is on > > else handler > >
or
cond branch > variable is equal to x > > else handler: > >
so on and so forth.
there is always an option to set else handler when conditions don’t apply, in 99% of the cases, it’s used in certain puzzles where if you mess up, it says: wrong, try again! in rest of the cases, it’s used to determine a number of items that you need to collect, destroy.. you know the gist of it. Oh yea, you can also stack up said branches on top of the branches, and it looks like this. it’s from.. one of my uuh.. puzzles in my game. ^^;
Now, the one problem that the anon had was that they had no idea how cond. branches in variables work. What I think they were trying to ask is how variables work in conditional branches.
It’s actually simple, you set up a branch consisting of a variable that is set to an x number (check previous screenshots above for example). The variable in the branch is activated when the conditions are met (again, referring to the chickens in the barns quest). This can also apply for number puzzles and the stuff.. Of course, some puzzles may be a little complicated to set up, like for example, a puzzle involving pushing an object from A to B. This can involve a little bit of brainstorming, but I’ll just show you the cheats.
This is from my old version of my fangame, I’ll include the puzzle in the future updates, but for now, I’ll use that as reference. So for this one, it’s a little complicated because it involves a couple of things. 2 variables for each object, both x and y, set up to track the coordinates of the object, and both conditional branches stacked upon one another below the control variables for both x and y. But how do you get to that point? you see the screenshot below the event editor? it has both x and y coordinates set to 8 - you put the coordinate number in both variables, in this case, both are 8, that will be the spot where you need to put in the object. Once you put in the object, add a switch so you won’t be able to move it again!
one final note I’d like to give you, is that you can learn variables and branches by looking through any game itself and checking out how things are made. any game made in rpgmaker 2003 can be opened with the program itself as long as you have said program. I am certain that you’d be able to learn more through there than me rambling on like this, but I did try my best to explain what I know about the stuff in a bit of detail as I possibly could share! But I do hope you find this useful! ;;















