# How to make a Simple Puzzle with Variables, "The Lost Souls"

#### Bonkers

##### I haven't seen you since the plague.

The demonstration located here: http://goo.gl/fST5ac (1.47 MB FIle) is a self contained puzzle you can use for your games.

I've left it unencoded so you can not only play it, but look at how it was created.  No external resources were used or needed.  This example is kept very simple as a demonstration of what you can do with VX/ACE and nothing more than 0s and 1s.

The puzzle is kept with triggers and variables high enough to not interfere with most small games, so it's plug and play.

It can be kept as is with the minimum of map editing to fit a dungeon as it's just a single room.​

You may edit and alter this as you see fit.  It's for learning, and giving you a broader look into entry level puzzles to
help enrich any RPG.  The puzzle itself will not detract from the main plot or grind the game to a halt.

As part of this tutorial I will run down the basics of it's construction.
Before you continue reading I ask you play the demonstration, it takes 2 minutes to finish.

* * *​
​
EDIT:  Reworded the explanation under the spoiler to make the process more understandable.

The Long Explanation of how it works, and how you can make your own from scratch.​

Setting an event is something most people can do, and we'll start there.  I choose the flames since there were two already established colors in the RTP materials.  Conversing with the flame takes minimal effort, so I made sure the "C" button was the trigger, even though the event is 'action' when it was interacted with to preform the color swap.
Each event is controlled by a single variable.  Even the ones that control other flames, and change their variables.

The flame I started with had only the ability to change it's own color.  It has only one variable to change.  At the bottom of the event it needs the commands to change it's color.  If it's 0 it turns to blue, if it's 1 it changes the graphic to red with a conditional for each.  This must be at the bottom.  The variable needs to change on interaction before the conditional is read by the event.

Here you can see the inner workings of the event.

When I saw this wouldn't be enough of a challenge to simply go up to each flame to change them, I enabled a second flame to change not only itself but one of it's neighbors.

This was done by simple copying and pasting the first flame's controls for color change into the second flames controls-twice.  Once after the first conditional and one after the second.  You are in essence 'nesting' conditionals.  Here is why: if the second flame is blue, then touching it turns it red.  But it also effects the first flame to change despite what color it happens to be at the moment.

So, when the Second flame is red, talking to it turns it blue.  If the first flame happened to be red at that time, it's now blue because you touched the second flame; otherwise the first flame turns to red now.

Now we also need the other part of the conditional.  When the second flame is blue, talking to it turns it to red.  If the first flame happened to be red, it's now blue; otherwise the first flame was blue, and now it's red.

You must make sure you put in the second part of the conditionals from the first flame's controls under the second part of the second flame's controls as well, or else the second flame will only change the first flame when it is red.

How do we keep track of all this?  Comments of course.  They are the green text in the above screen shots.  Comments do not effect the event and help you keep your place and follow the process.  That is if you value your sanity, it's your choice.  In each of the events you will see a line which says "Red to Blue" or "Blue to Red".  This is the heart of the puzzle, and makes bug fixing a breeze.

Now we have two flames.  One which can only change it's own color, and a second which can change itself and the first regardless of it's current color.

We can now make it more complex since we have the basics down.  Since you  know how to change one flame and another, the process of making a flame change itself and two others it just as easy.  More copying and pasting will do the job for you.

Or you may do things the easy way, copy the whole event you just made from the second flame and rename the copied event.  The third flame now has all the second flame's controls.  Change the variables in the third flame to one variable higher for each of the existing conditionals.  Now copy the first flames conditionals into the third flame's controls as you did with the second.

So:

If the third flame is red, it changes to blue.
The second flame happens to be red, it's now blue.  Otherwise it's red.
The first flame is red, and turns to blue.  Otherwise it's red.
The second flame happens to be blue, it's now red.  Otherwise it's blue.
The first flame is red, and turns to blue.  Otherwise it's red.

See where I copy and pasted?  Writing it out ahead of time helps to plan.  You know where you can cut corners and simply reuse old events.

Again:
If the third flame is blue, it changes to red.
The second flame happens to be red, it's now blue.  Otherwise it's red.
The first flame is red, and turns to blue.  Otherwise it's red.
The second flame happens to be blue, it's now red.  Otherwise it's blue.
The first flame is red, and turns to blue.  Otherwise it's red.

So you will be copying and pasting the first flame's conditionals a total of 4 times into the third flame.

Now try a flame with 3 variables it can change aside from it's own.  The pattern continues in the same fashion much like induction, you continue to nest the conditionals like you did with the second flame.  Think of the first flame as your base case.

If you trigger a flame that is suppose to change and it remains the same color despite intending it's variable changed, then you know you forgot to change a variable; or insert the preceding conditionals of the previous flame\bottom controls for the intended variable.

To help me debug I created the candelabra and used the orbs as a means for tracking when I'd triggered all the flames a single color.  Staring at the screen after a length of time drains the eyes, and having the SFX to accompany it helped me stop and realize I was done.

This was not enough to complete the puzzle though.  The player needs a clue to realize what the goal of the puzzle is and when it would be considered complete.  A player cannot blindly feel out a goal when someone else sets that goal for them.  It needs to be told
up front and clearly enough that they understand the challenge.

I reinforced the object of the goal with an NPC, and a secondary NPC that appears when you complete the task telling the player they are done.  Also a little flourish  at the end never hurts.  Let the player know they did it so they can move on.
I hope this has been informative and entertaining to you.  Remember you can edit the puzzle, insert it as is; it's yours to  play around with and alter to your needs.  Please do credit me if you use my work.

Take care, and good luck making your games.

#### kaleemmcintyre

##### Blue Dragon
This was delicious!   Thank you.

#### Bonkers

##### I haven't seen you since the plague.
Oh sorry!  I'll have to reupload elsewhere.  To be honest I've progressed so much with variables, I've completely redone this puzzle since then with less of a mess.  I'll put it together before the end of the summer for people in MV.

#### wolfpak692

##### Regular
Just wondering if the RMMV version was up yet?  Also, is there a new upload for VX Ace since I am working with VX Ace and MV...

### Latest Profile Posts

I keep thinkin' that someday I'll be a real girl. I dunno, maybe today is the day.

Counting down to Wind Ryder release

Hello everyone, I inform you that you can now freely try my new Plugin: Dynamic Switch for RPG MAKER MZ.

You can see the official post in the forum: https://forums.rpgmakerweb.com/index.php?threads/rpg-maker-mz-plugin-dynamic-switches.161525/

I hope you like it and I'm looking forward to your comments and suggestions!
Right, finally responded to everyone who had an open commission query with me. If I've missed anyone, please let me know.
Okay, so it looks like I've bamboozled by that dastardly placebo effect again. Still taking the meds, which seemed to help at first, but yesterday evening my chest got this odd numbness, which didn't last long, but still. AND its still difficult to breathe. Guess I'll go spend the money I was saving for homebuying costs on another doctor visit :\