How can I push 3 rocks on 3 switches?

Hello,
I tried to make a game where you have to push rocks on switches, and then a door opens. I used X variables and Y variables (they belong to the coordinates) to ask if the rocks are on the switches, but I had problems to make this happen. One rock and one switch is quite easy, two are okay, but three are too difficult.
Does anyone know, how to code this?

Thanks for any replies! ^^
Can you tell us with what exactly you are struggling with? If you have your system already working for two rocks and two switches I genuinely don't quite understand why you can't just expand it to three rocks and three switches.
you just check each switch with each event if they are equal.
you mostly simply repeat the variable XY, eventA, eventB and eventC.

galv has puzzleFunctions to make those check easier.
conditionalBrance+ is also a way to make checks easier.

so you dont have to struggle to much, but the way you check 1 switch + rock
is the same for rock2, rock3, rock4, rock5 etc, just more conditions to check.
As eomereolsson said, exactly the same way you coded it for one or two. Whatever you did that correctly checks for one boulder to be in the right place, you simply do that two times, or three times, or one hundred times - nothing changes.

You'll have to explain more precisely what isn't working, hopefully with a screenshot of your event.
@eomereolsson
I'm sorry. I'll try to explain better ^^':
First of all, I set these 2 variables equal to the coordinates of the rock and of the switch.

Then I made 2 if-events into each other. The one asks, if the rock's X is the same as the switch's X, and the other one asks, if the Y variables are the same.
And if the coordinates are the same, then a switch called 'door' will turn on.

But the if-events have else-brackets too. In these 2 else-brackets I coded that 'door' will turn off.

Here's everything in the RPG Maker. I hope you can understand it, although the code is in German.


Spoiler: [ATTACH type="full
210168[/ATTACH]"]

But then I wanted to make another puzzle with 2 rocks. I did the if-system again. I coded, that if all of these variables from 'switchA' and 'rockA' are the same and the variables of 'switchB' and 'rockB', then 'door2' will be turned on. Every single if-event got its own else-bracket, in which the other combination ('switchA' with 'rockB' and 'switchB' with 'rockA') came in. And in every else-bracket of these new if-events came 'door2' is turned off.

Here is the code:

Spoiler: [ATTACH type="full
210172[/ATTACH]"]

Spoiler: [ATTACH type="full
210173[/ATTACH]"]

Spoiler: [ATTACH type="full
210174[/ATTACH]"]

Spoiler: [ATTACH type="full
210175[/ATTACH]"]

Spoiler: [ATTACH type="full
210176[/ATTACH]"]


With three rocks, I'd have 6 combination possibilities:

(A=B and C=D and E=F)
(A=B and C=F and E=D)
(A=D and C=B and E=F)
(A=D and C=F and E=😎
(A=F and C=D and E=😎
(A=F and C=B and E=D)

So 6 times I'd have to put the second possibility in the first else-brackets, in its 6 again, in theirs 6 again and so on.
At the end I'd have to write 6 by 6 by 6 by 6 by 6 if-constellations. So these are... 7,776 if-constellations.
Pretty much handwork. '^^

That's why I'm asking for other ideas how to make this.
Ok, I see your problem. Of course more than 7000 statements would be ridiculous. Luckily there is no need for that.
First, let's set this assumption: Two Boulders can never be on the same tile, particularly not on the same switch. I assume that is already the case in your puzzle with boulders being the same priority as characters, while switches are below them.
Corollary: If every boulder is on a switch, then there must be a boulder on every switch. (Since you have the same number of boulders and switches). We don't actually need to know which boulder is on which switch.
So you can use something along these lines:
Code:
Control Variables ...
//set the X and Y coordinates for your boulders and switches as you do already
Control Switch: 'Boulder A on Switch' is OFF
...
//this isn't actually necessary, as switches start as OFF per default

IF Boulder A X = Switch A X
  IF Boulder A Y = Switch A Y
    Control Switch: 'Boulder A on Switch' is ON
ELSE
  IF Boulder A X = Switch B X
    IF Boulder A Y = Switch B Y
      Control Switch: 'Boulder A on Switch' is ON
  ELSE
    IF Boulder A X = Switch C X
      IF Boulder A Y = Switch C Y
        Control Switch: 'Boulder A on Switch' is ON
...
//repeat this process for every Boulder
Control Switch: 'Should we open the door?' is ON

IF 'Boulder A on Switch' is OFF
  Control Switch: 'Should we open the door?' is OFF
...
//repeat this process for every Boulder Switch

IF 'Should we open the door?' is ON
  Control Switch: 'Actually open the door' is ON
ELSE
  Control Switch: 'Actually open the door' is OFF

There you go, done in 22 If-branches (if I didn't miscount). Still a lot, but not near the 7000+ 😀 You could narrow that down further if you wanted to use the script option of the If branch or straight up plugins. But I figured you were probably looking for a way using only the default event commands.

A word of caution though: The method outlined above relies on the fact that every switch has different X coordinate. Though you can easily adapt the logic to account for that. Let's assume for example that switches A and B have the same X coordinate. Then you could simply check like this:
Code:
...
IF Boulder A X = Switch A X
  IF Boulder A Y = Switch A Y
    Control Switch: 'Boulder A on Switch' is ON
  ELSE
    IF Boulder A Y = Switch B Y
      Control Switch: 'Boulder A on Switch' is ON
ELSE
  IF Boulder A X = Switch C X
    IF Boulder A Y = Switch C Y
      Control Switch: 'Boulder A on Switch' is ON
...

As you can probably tell by my habit of capitalizing nouns (or the fact that my first language is set to german), there was no language barrier involved in understanding your screenshots 😉
@eomereolsson
Thank you a lot for your advice! ☺️
Now my puzzle works perfectly. And also thank you for so much efford you have put in here.

Original thread: https://forums.rpgmakerweb.com/threads/how-can-i-push-3-rocks-on-3-switches.143108/