Push Puzzle Problem in MV

I've been trying to make a puzzle where you have to push random blocks to the exact map coordinates, I tried using "&&" and "//" witn a conditional Branch, but it wasn't working on how I planned it.

Like for example the puzzle of pushing blocks is

1 -
- 2

and the only way to do that is to push just the random blocks by Event ID into the map coordinates.
Can anyone help me on how to that? I actually never done scripting, and this is my first time doing it.
When you say "I tried ..." please show a screenshot so we can see exactly what you had. Otherwise we don't know if you just made a typo, have the syntax wrong, or something completely different. You also don't say how many blocks you have.

// is a comment in javascript, so anything you have after that on the line would be ignored.

If it doesn't matter which block goes on which spot, I would just use a region id to mark the places the blocks need to go (use the same region id for all of them), then I'd set up a common event (without a switch, so not parallel process), and on each block I'd do a Move Away From Player (wait for completion), then Call Common Event.

In the common event I'd do the check for all blocks on the required region id, and if they are, turn a switch on (and maybe do other stuff, depending on what you want to happen when it's done).

Now the check for all blocks on the required region id might be different, depending on how many you have. If you have 3 blocks and they're events 8, 9 and 10, and you've used region id 12 for example, you'd do this (in the Script line of the conditional branch):

Code:
$gameMap.event(8).regionId() == 12 && $gameMap.event(9).regionId() == 12 && $gameMap.event(10).regionId() == 12

but if you have many blocks you might be better off using a loop.
Note that, unless I'm misunderstanding something, you don't actually need to use any scripting for this.

Your event commands let you set variables to the coordinates of the current event. So you can simply check whether the event is in the spot you want it to be after it moves.
Screenshot 2023-02-18 002544.jpg

If you don't want each rock to be in a specific place, but either can be in a valid location, then you use the region ID.
Screenshot 2023-02-18 002806.jpg
So I don't see why any script calls are necessary, just a bit convenient if you know what you're doing.

That being said, if you want to learn how to do it including script calls, have you looked up any guides?
I don't have a screenshot, but I thought this picture I drew would help.

Untitled44_20230217212827.png

What I'm trying to say is you move a random block to it's placement. Once all blocks are moved to the placements, it unlocks the door.
...that's what the events I made for you will do.
Note that, unless I'm misunderstanding something, you don't actually need to use any scripting for this.

Your event commands let you set variables to the coordinates of the current event. So you can simply check whether the event is in the spot you want it to be after it moves.
View attachment 253543

If you don't want each rock to be in a specific place, but either can be in a valid location, then you use the region ID.
View attachment 253544
So I don't see why any script calls are necessary, just a bit convenient if you know what you're doing.

That being said, if you want to learn how to do it including script calls, have you looked up any guides?
I did see the guides, but I felt like this isn't what I wanedt. But I'll try what you showed me according to those screenshots.
If those corridors are only one tile wide, you are not going to be able to move those blocks to all those locations.

Also, are you having more blocks than needed? If so, the logic will probably be a little different, as some blocks will never be on any of the valid tiles.
Here is one way to build this. With Region Id like @Shaz mentioned.
Also i included a check so a sound effect is only played when the rock is moving, not when it is pushed against a Wall.
Everytime you Push a Rock onto the Correct RegionID, a Variable will count up +1, if a previous correct placed rock
enters the wrong Region, it will count down -1.
You can just copy paste the Rock and make as many as you need, even 100+.
The Idea of putting some of it into a common event for easier edits later on, is also a good idea.

Spoiler
◆Control Variables:#0010 Var10_Map_X = Map X of This Event
◆Control Variables:#0011 Var11_Map_Y = Map Y of This Event
◆Set Movement Route:This Event (Skip)
: :◇Turn away from Player
: :◇1 Step Forward
◆Wait:2 frames
◆Control Variables:#0010 Var10_Map_X -= Map X of This Event
◆Control Variables:#0011 Var11_Map_Y -= Map Y of This Event
◆If:Var10_Map_X ≠ Var11_Map_Y
◆Play SE:Push (60, 100, 0)
◆Set Movement Route:Player (Skip)
: :◇1 Step Forward
◆Comment:Bugfix for Spam Enter Button prevents double Move.
◆Set Movement Route:This Event (Wait)
: :◇Wait:1 frame
◆Comment:---------------------------------------------
◆
:End
◆Control Variables:#0010 Var10_Map_X = Map X of This Event
◆Control Variables:#0011 Var11_Map_Y = Map Y of This Event
◆Get Location Info:var12_RegionID, Region ID, ({Var10_Map_X},{Var11_Map_Y})
◆If:var12_RegionID = 10
◆If:Self Switch A is OFF
◆Control Self Switch:A = ON
◆Control Variables:#0013 var13_StoneCount += 1
◆
:End
◆
:Else
◆If:Self Switch A is ON
◆Control Self Switch:A = OFF
◆Control Variables:#0013 var13_StoneCount -= 1
◆
:End
◆
:End
◆If:var13_StoneCount ≥ 5
◆Control Switches:#0007 Puzzle Completed = ON
◆
:End
Edit: Here some Pictures.
rockhelp1256.png

rockhelp2356.png

but if you have many blocks you might be better off using a loop.
Do I use the Loop command on the Common Event or the Event itself?
That would depend on the details and the chosen approach for this.
There is no Loop or Parallel Event needed for this. But it would also work. If you want to learn more about that,
the others can surely give or link some examples.

Alternatively:
You could copy paste the above Event 5times (No changes needed),
Draw Region 10 onto 5 Maptiles.
Use the Puzzle Completed Switch, as 2nd Eventpage Condition for your open Door and maybe to make all Rocks disappear the same way.
Ready for testplay.

Edit: I will take a look at the code again, maybe its possible to make it even shorter.
Edit: Here a slightly shorter Version.
Edit: Shorter Version had a thought error and was buggy^^. XD
Do I use the Loop command on the Common Event or the Event itself?
Common event
i preffer you to share repair map for your puzzle.
.
Basicly you will open the lock if 2 event on same position?
Do I use the Loop command on the Common Event or the Event itself?
I strongly suggest you try to do something.

This thread reads like you are unfamiliar with basic eventing logic, which is fine because you're new.

But you're reading a number of different ways to do this and it seems like you're not actually trying to implement any of them and just sinking through a whirlpool of more confusion.

Do something. Make it in-game, see if it works. If it doesn't, then post screenshots of your event and describe what goes wrong.

It will be much easier for us to give you guidance on fixing an existing event than to get half a dozen people saying "You could do it like this."

As you can see from the length of the sample event I posted for you, this really doesn't need to be a very complicated thing.
I strongly suggest you try to do something.

This thread reads like you are unfamiliar with basic eventing logic, which is fine because you're new.

But you're reading a number of different ways to do this and it seems like you're not actually trying to implement any of them and just sinking through a whirlpool of more confusion.

Do something. Make it in-game, see if it works. If it doesn't, then post screenshots of your event and describe what goes wrong.

It will be much easier for us to give you guidance on fixing an existing event than to get half a dozen people saying "You could do it like this."

As you can see from the length of the sample event I posted for you, this really doesn't need to be a very complicated thing.
It's okay, I've already figured it out. I just did the script call in the conditional branch like what Shaz told me, and it worked.

Original thread: https://forums.rpgmakerweb.com/threads/push-puzzle-problem-in-mv.155059/