puzzle system I need help

So what I am trying to do is make a puzzle system in my game where when a player touches 4 set events each one that is touched is a different color but I am having difficulty on how to sort of link the switches?


Any ideas?
Can you elaborate on exactly what is supposed to happen?
Can you elaborate on exactly what is supposed to happen?
It's supposed to trigger a door to spawn if the puzzle is triggered in the right order.
It's supposed to trigger a door to spawn if the puzzle is triggered in the right order.
maybe i could use a variable to link them
This code could be condensed a bit, but I kept the long version to show the logic. I think this is what you want to do. Pseudo-Code follows
Code:
Event #1
If Switch #1 is Off
   If Switch #2 is Off
      If Switch #3 is Off
         If Switch #4 is Off
            Turn on Switch #1
         Else
            Cue that puzzle is being reset
            Turn Switch #1 Off
            Turn Switch #2 Off
            Turn Switch #3 Off
            Turn Switch #4 Off
         End
      End
   End
End

Event #2
If Switch #1 is On
   If Switch #2 is Off
      If Switch #3 is Off
         If Switch #4 is Off
            Turn on Switch #2
         Else
            Cue that puzzle is being reset
            Turn Switch #1 Off
            Turn Switch #2 Off
            Turn Switch #3 Off
            Turn Switch #4 Off
         End
      End
   End
End

Event #3
If Switch #1 is On
   If Switch #2 is On
      If Switch #3 is Off
         If Switch #4 is Off
            Turn on Switch #3
         Else
            Cue that puzzle is being reset
            Turn Switch #1 Off
            Turn Switch #2 Off
            Turn Switch #3 Off
            Turn Switch #4 Off
         End
      End
   End
End

Event #4
If Switch #1 is On
   If Switch #2 is On
      If Switch #3 is On
         If Switch #4 is Off
            Turn on Switch #4
            Open Door
         Else
            Cue that puzzle is being reset
            Turn Switch #1 Off
            Turn Switch #2 Off
            Turn Switch #3 Off
            Turn Switch #4 Off
         End
      End
   End
End
Thank you this helps a lot
This code could be condensed a bit, but I kept the long version to show the logic. I think this is what you want to do. Pseudo-Code follows
Code:
Event #1
If Switch #1 is Off
   If Switch #2 is Off
      If Switch #3 is Off
         If Switch #4 is Off
            Turn on Switch #1
         Else
            Cue that puzzle is being reset
            Turn Switch #1 Off
            Turn Switch #2 Off
            Turn Switch #3 Off
            Turn Switch #4 Off
         End
      End
   End
End

Event #2
If Switch #1 is On
   If Switch #2 is Off
      If Switch #3 is Off
         If Switch #4 is Off
            Turn on Switch #2
         Else
            Cue that puzzle is being reset
            Turn Switch #1 Off
            Turn Switch #2 Off
            Turn Switch #3 Off
            Turn Switch #4 Off
         End
      End
   End
End

Event #3
If Switch #1 is On
   If Switch #2 is On
      If Switch #3 is Off
         If Switch #4 is Off
            Turn on Switch #3
         Else
            Cue that puzzle is being reset
            Turn Switch #1 Off
            Turn Switch #2 Off
            Turn Switch #3 Off
            Turn Switch #4 Off
         End
      End
   End
End

Event #4
If Switch #1 is On
   If Switch #2 is On
      If Switch #3 is On
         If Switch #4 is Off
            Turn on Switch #4
            Open Door
         Else
            Cue that puzzle is being reset
            Turn Switch #1 Off
            Turn Switch #2 Off
            Turn Switch #3 Off
            Turn Switch #4 Off
         End
      End
   End
End
so i've got this all in now but when i try to run it the door does not spawn. that was before i specified the switches locations but when i did specify them the blocks that were the foundation for the switch disappear as soon as i load into it
Double-post notice: @dragonborn101

If you need them to be touched in the right order, then you will need variables, not switches.

What happens if they touch the first two in the right order, but the third one is the wrong one? Does it reset immediately? Or do they have to touch all 4 before you do the check?
So the first two work but then it resets I think but I didn't make a way for the tileset to reset when the puzzle resets
Ack! Each of the 'else' statements needs to be addressed, not just the innermost. My fault for not testing. Trying to reset from each else would be way too convoluted, so let's just take a different approach. If the conditions are met, then set that switch to ON. At the end of the 4 nested conditions, look to see if the conditions were met, i.e., the switch is on. If the switch is on, all is good, give a cue. If the switch didn't turn on, then the conditions failed, and the puzzle is reset. I did test this and it does seem to work.
Spoiler
Event 1
◆If:Button 1 Pressed is OFF
◆If:Button 2 Pressed is OFF
◆If:Button 3 Pressed is OFF
◆If:Button 4 Pressed is OFF
◆Control Switches:#0001 Button 1 Pressed = ON
◆
:End
◆
:End
◆
:End
◆
:End
◆If:Button 1 Pressed is ON
◆Play SE:Chime1 (90, 100, 0)
◆
:Else
◆Play SE:Buzzer1 (90, 100, 0)
◆Control Switches:#0001 Button 1 Pressed = OFF
◆Control Switches:#0002 Button 2 Pressed = OFF
◆Control Switches:#0003 Button 3 Pressed = OFF
◆Control Switches:#0004 Button 4 Pressed = OFF
◆
:End

Event 2
◆If:Button 1 Pressed is ON
◆If:Button 2 Pressed is OFF
◆If:Button 3 Pressed is OFF
◆If:Button 4 Pressed is OFF
◆Control Switches:#0002 Button 2 Pressed = ON
◆
:End
◆
:End
◆
:End
◆
:End
◆If:Button 2 Pressed is ON
◆Play SE:Chime1 (90, 100, 0)
◆
:Else
◆Play SE:Buzzer1 (90, 100, 0)
◆Control Switches:#0001 Button 1 Pressed = OFF
◆Control Switches:#0002 Button 2 Pressed = OFF
◆Control Switches:#0003 Button 3 Pressed = OFF
◆Control Switches:#0004 Button 4 Pressed = OFF
◆
:End

Event 3
◆If:Button 1 Pressed is ON
◆If:Button 2 Pressed is ON
◆If:Button 3 Pressed is OFF
◆If:Button 4 Pressed is OFF
◆Control Switches:#0003 Button 3 Pressed = ON
◆
:End
◆
:End
◆
:End
◆
:End
◆If:Button 3 Pressed is ON
◆Play SE:Chime1 (90, 100, 0)
◆
:Else
◆Play SE:Buzzer1 (90, 100, 0)
◆Control Switches:#0001 Button 1 Pressed = OFF
◆Control Switches:#0002 Button 2 Pressed = OFF
◆Control Switches:#0003 Button 3 Pressed = OFF
◆Control Switches:#0004 Button 4 Pressed = OFF
◆
:End

Event 4
◆If:Button 1 Pressed is ON
◆If:Button 2 Pressed is ON
◆If:Button 3 Pressed is ON
◆If:Button 4 Pressed is OFF
◆Control Switches:#0004 Button 4 Pressed = ON
◆
:End
◆
:End
◆
:End
◆
:End
◆If:Button 4 Pressed is ON
◆Play SE:Chime1 (90, 100, 0)
◆Control Switches:#0005 Door Appears = ON
◆
:Else
◆Play SE:Buzzer1 (90, 100, 0)
◆Control Switches:#0001 Button 1 Pressed = OFF
◆Control Switches:#0002 Button 2 Pressed = OFF
◆Control Switches:#0003 Button 3 Pressed = OFF
◆Control Switches:#0004 Button 4 Pressed = OFF
◆
:End

1639706425281.png


1639706466996.png


If you need them to be touched in the right order, then you will need variables, not switches.

What happens if they touch the first two in the right order, but the third one is the wrong one? Does it reset immediately? Or do they have to touch all 4 before you do the check?
Shaz (who is a whole lot smarter than me) has a very valid question. My approach assumes you are resetting the puzzle immediately. If you want to touch all 4 before the check is made, then a different approach needs to be used. Probably using a little bit of js to concatenate a string, as in "1234" or "3214" and then checking if the order was "1234" but that's up to you.

Original thread: https://forums.rpgmakerweb.com/threads/puzzle-system-i-need-help.142997/