# Please, help with switch puzzles!

#### Lordlee91

##### Veteran
Okay guys I'm very confused and stuck with a certain type of puzzle.

I'm trying to make a switch puzzle, the one where you have to flick certain switches in order for a door

to open and then you can progress in the game.

I don't understand variables very well at all so if someone could just explain to me what I have

to do to make the puzzle work I'd learn by actually doing it instead of someone trying to explain

to me how I can make it work for myself.

Sounds kinda lazy but I've honestly tried for hours, I'm starting to go mad haha.

I'm trying to make it so you have to flick three switches in order for the door to open, doesn't

have to be in a particular order it just needs to be a certain three.

I'll post a screenshot, thanks in advance.

#### Shaz

##### Veteran
I've moved this thread to VX Ace Support (Tutorials is for people to post tutorials, not to ask for help on how to do something).. Please be sure to post your threads in the correct forum next time. Thank you.

I'm going to call them LEVERS, because using the term SWITCH for the visual things you've got on the map and the engine's internal switches that are true/false/on/off (the logic ones) is just going to confuse things.

Do you want the levers to turn off again if the wrong ones are turned on? Or should the player just have to keep trying different combinations until they get the right one?

If they have the correct three turned on but they also have one or more INcorrect ones on, should the door remain closed?

If you don't want them to reset automatically when a wrong lever is turned, and you don't want the door to open unless they have the correct three, and ONLY the correct three turned, here's what you need to do:

Allocate a different game switch for each lever. Each event will have 2 pages - the lever in its 'off' position, with no conditions, and a Control Switches command to turn that lever's switch on; and a second page with the lever in its 'on' position, with that lever's switch as a condition, and a Control Switches command to turn that lever's switch off again.

On each page, after the Control Switches command, add a Call Common Event command. Every event, on both pages, will call the SAME common event.

Now set up your common event (do not set it to parallel or autorun). For my example, I'll say switches 1-6 refer to levers 1-6, and the door will be opened ONLY if switches 1-3 are on, and 4-6 are off (so the conditional branches are checking for the OPPOSITE result - saying if 1-3 are off or 4-6 are on, we're going to stop checking because the correct levers aren't turned on):

Conditional Branch: Switch [0001: Lever 1] is OFF Exit Event ProcessingBranch EndConditional Branch: Switch [0002: Lever 2] is OFF Exit Event ProcessingBranch EndConditional Branch: Switch [0003: Lever 3] is OFF Exit Event ProcessingBranch EndConditional Branch: Switch [0004: Lever 4] is ON Exit Event ProcessingBranch EndConditional Branch: Switch [0005: Lever 5] is ON Exit Event ProcessingBranch EndConditional Branch: Switch [0006: Lever 6] is ON Exit Event ProcessingBranch End... if the event hasn't been exited by now, the correct three switches are on and the incorrect three are off, so you can do your open door stuffPart of the open door stuff might include turning on a final switch, and giving the door event and all the lever events an extra page conditioned by that switch, so they all stay in the final position. Otherwise the player can just keep changing the switches. Actually, if you do that, you might need to use Jump to Label instead of Exit Event Processing, so the door will close again.

Anyway - that'll get you pretty close. Any extras that you do will depend on what you want to happen AFTER the door has been opened the first time.

#### Lordlee91

##### Veteran
Hey Shaz thanks for helping me out and putting this topic in the right place.

The way you explained how I want the levers to work is correct.

Okay, so I think I understand what your talking about but I'm still trying to get my head round how to do

it so I'll post screenshots of two of the levers that I done and hopefully you can tell me weather I'm

on the right tracks or not.

1st Lever

2nd Lever

#### Shaz

##### Veteran
No, not at all. Way too complicated.

Lever 1

Page 1

No conditions

Sprite is lever in "off" position.

Control Switches: [0001: Lever 1] = ONCall Common Event: [0001: Check Lever Positions]Page 2Condition is Switch 1 is ON (this is in the PAGE CONDITIONS section - above the sprite - NOT a Conditional Branch in the event command list)

Sprite is lever in "on" position.

Control Switches: [0001: Lever 1] = OFFDo the same for lever 2, but use Switch 2 instead of Switch 1. Still call Common Event 1.The code I gave you in the previous post is what goes into Common Event 1.

Last edited by a moderator:

#### Lordlee91

##### Veteran
Awesome I think I've got it I'll post screenshots again.

Lever 1

Comment event

I can't tell if those are correct or not as even if they are, I don't know how to connect them to in

turn, open the door.

I don't mean to push it but would you know how?

#### whitesphere

##### Veteran
To make the door open, assuming it is an Event, create a second page.  When your desired condition is TRUE, set a Switch to ON.  For this example, I'll call it "Puzzle Door Solved" Make sure the second page (the open door) requires the Switch "Puzzle Door Solved" to be ON.

Then, the door will become open when the Switch "Puzzle Door Solved" is ON.

The trick here is events always execute their event pages from right to left.  The first page which matches the condition executes.  The event then does not execute any other pages.

This is why you have "Self Switch ON" as a valid event condition.  Page 1 of an Event might be, say, an NPC greeting the player.  Page 1 then sets the Self-Switch A to ON.  Page 2 requires Self Switch A to be ON.  On that page, the NPC gives a much briefer statement, so the NPC isn't always greeting the player.

#### Shaz

##### Veteran
I didn't have any ELSE statements in my common event. You can get rid of them by unchecking the box on the Conditional Branch. The way you have it, you've got the Exit Event Processing in the ELSE statement, for when the condition is false, not when the condition is true. So your conditions for opening the door would be the exact opposite of mine.

### Latest Profile Posts

Finally finished my first big game since joining the forums! Please check out Petal Knights! https://forums.rpgmakerweb.com/index.php?threads/petal-knights-playable-now.117898/
Back home now

Many thanks to all my fellow game devs. for all the support during this crazy time.

Feeling a bit rough but much better then bein' hospitalized at least.

Now time to get back to the code
Added skill ranges, and very basic implementation of scope, with a rule called "empty tile" that simply returns true if the selected tile is empty (has a battler), and false otherwise

This means movement range and attack ranges are all automatically implemented.

Stone masons are hard at work creating beautiful sculptures for your games...
When you realize @Kupotepo is a champion among RM Web users, and it all makes sense now: