dysphoria

Villager
Member
Joined
Jun 23, 2020
Messages
12
Reaction score
18
First Language
Spanish
Primarily Uses
RMMV
Hi there, I'm trying to replicate a kind of puzzle where the player have to push or put an object above a button to open a door or make something appears (similar to Zelda, see the image). I already figured how to make 'pushable objects', but I'm not sure how to make that the button detects that is something above it.

1664338105006.png

I'm thinking on a condition that checks if the object is in a determined coordenate, or if the object is on a region tile. However, I can't figurate how to do that condition, because the branch command doesn't have an option for coordinates.

This is my puzzle, the goal is to put the 'leaves' on the flowers tiles. After the four are in that position, a chest should appear.

1664338068777.png
 
Joined
Jul 12, 2020
Messages
460
Reaction score
250
First Language
English
Primarily Uses
RMMV
Hello!
Yes, this is absolutely possible!

I've recommended this before in similar threads, and while there are many methods to going about this, I think the easiest thing to do is use Variables, because you can copy and paste this setup pretty easily if you have multiple instances like this in your game.

Here the following setup:

1) Create a new parallel event on the map the pushable object is on, and start by create 2 variables. Call them Object X, and Object Y.

2) Set the Object X Variable to where it tracks the X Coordinate of the Object (aka, event) you want to track.
This can be done by simply going to:
Control Variables > Game Data > Character > (Event you want to track)
> Map X


3) Do the same thing as 2), but this time, do it with the Variable of Object Y, and make sure it tracks Map Y. Same exact process as 2).

4) You now have two variables that are constantly tracking the X and Y coordinate of your object(event) since this is a parallel event.

5) Right underneath these two Controlled Variables, setup a Conditional branch that has the following:

If Object X = (the X coordinate you want the Object to be at)
{If Object Y = (the Y coordinate you want the Object to be at)}
{-Control Switch to ON}
{-Self-Switch A ON}


*Notice how the Object Y is to be nested inside of your Object X coordinate condition in order for your Switch to turn ON.

If you follow this exact procedure, you should easily be able to have a parallel event that, when the pushable object is at the (X,Y) location on the map, will trigger a Switch to turn on. (And with this, you can trigger things to happen).

Thus, you can adjust things like Event properties for events being above/same as character since you want your object to be pushed onto a button. (This would require a little extra eventing steps, but I'm sure you could figure that part out).

**Just make sure to turn the Parallel Event OFF once the object is at the right spot so that it doesn't cause issues afterwards. That is why I include the Self-Switch A in the spoiler since it's the easiest way to do so.



I always like recommending this strategy because in my opinion, while it is a little tedious to setup at first, it's one of the easiest methods to track object locations without interference from other events or ID setups.

I hope that helped!!
 

fizzly

Veteran
Veteran
Joined
Mar 23, 2012
Messages
1,243
Reaction score
846
First Language
Polish
Primarily Uses
RMMZ
Instead of parallel process I recommend to check if the position is right while pushing the obstacle. This will compensate eventually FPS drops.
 

dysphoria

Villager
Member
Joined
Jun 23, 2020
Messages
12
Reaction score
18
First Language
Spanish
Primarily Uses
RMMV
1) Create a new parallel event on the map the pushable object is on, and start by create 2 variables. Call them Object X, and Object Y.
But I suppose I need to create a pair of variables for each pushable object, right? And the same for the parallel events.
 
Joined
Jul 12, 2020
Messages
460
Reaction score
250
First Language
English
Primarily Uses
RMMV
But I suppose I need to create a pair of variables for each pushable object, right? And the same for the parallel events.

Yes, I believe so if it's on the same map.
The way I see it, you don't want to use the same two variables to track different events since that can cause conflicting issues.

Now, in regards to using variables for different events, you could totally pull it off if the events are on different maps. You could theoretically use Object X and Object Y constantly, through different maps, and just have those variables track different things on those respective maps. Could be your "tracker" variables sorta speak. So it's not as though you have to use different variables every single time you have a pushing puzzle in your game.

As for the "parallel" event itself, there's no need to have variables for the parallel event. You're just using a parallel event to track an object. Here, I can show you an example if it doesn't make much sense on the surface:
Screen Shot 2022-09-28 at 11.32.24 AM.png

In my previous game, I had a snowball puzzle where you have to push a snowball into a certain spot on the map. So here, you can see that once the snowball (being tracked through Variables #41 and #42 that I named Object X and Object Y), reaches coordinate (2, 7) on my map, it falls into a hole and causes a buncha stuff to happen as you see here.


Instead of parallel process I recommend to check if the position is right while pushing the obstacle. This will compensate eventually FPS drops.

Personally, I've never tried this approach since my parallel events never cause lag issues since I don't ever have more than one or two on a map, but you could totally try this if it makes you more comfortable!
 
Last edited:

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
1,283
Reaction score
824
First Language
Javascript
Primarily Uses
RMMZ
I'm developing a plugin for this if you'd be interested...

Playable demo of the puzzles:
I made a plugin for personal use for a project a long time ago, currently I'm making it a bit more user friendly... but it does get the job done even in it's current state.

... ... ...

You're looking to do something like this right?

Without the plugin the basics are still the same..
...but the plugin can make things much easier (especially when I get it more user friendly)

basically as mentioned above...
Firstly I fully agree it's best to not use a parallel process. (I avoid as much as possible)

At the time of the moved object upon it's movement compare coordinates of the pushed objects vs the target landing objects.

Then for your scenario since you're wanting all 4 to have been placed to activate the chest.
Simply add 1 to a variable for every correctly moved object.

Then as a condition for the page of chest event have it be if that variable is greater then or equal to 4.

Hope that makes sense? See the video demonstration above to maybe make it a bit more understandable
 
Last edited:

dysphoria

Villager
Member
Joined
Jun 23, 2020
Messages
12
Reaction score
18
First Language
Spanish
Primarily Uses
RMMV
Yes, that's exactly the type of puzzle I'm trying to do. I did a similar way to do it by creating variables that checks on X and Y position of the events. The 'pushable objects' adds 1 to a variable named 'OnionRoom' when it is on the correct position. The self-switch is to stop the obect to move again after it reachs the target position.

1664414006521.png

After all 6 objects are placed in their correct spot, 'OnionRoom' reaches 6 and activates the condition of an automatic event that calls the animation of the chest. It also activates the switch 'ExtraPoint28' for the chest to be always visible there.

1664413970533.png1664413986683.png

So that's it, it's the way I figured to do this kind of puzzle. However, I noticed that the player could make a mistake by pushing the object to a spot where they can't move it anymore. So also did a reset button that resets the variable counter and returns the objects to their original position. But it entered in conflic with the self-switch that make the objects to stop moving.

I could change the layout of the room, or find a way to undo the self-switches, but I don't think there is a way to do this last thing.

1664414015874.png
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,401
Reaction score
5,090
First Language
English
Primarily Uses
RMMZ
Yes, that's exactly the type of puzzle I'm trying to do. I did a similar way to do it by creating variables that checks on X and Y position of the events. The 'pushable objects' adds 1 to a variable named 'OnionRoom' when it is on the correct position. The self-switch is to stop the obect to move again after it reachs the target position.

View attachment 241570

After all 6 objects are placed in their correct spot, 'OnionRoom' reaches 6 and activates the condition of an automatic event that calls the animation of the chest. It also activates the switch 'ExtraPoint28' for the chest to be always visible there.

View attachment 241567View attachment 241569

So that's it, it's the way I figured to do this kind of puzzle. However, I noticed that the player could make a mistake by pushing the object to a spot where they can't move it anymore. So also did a reset button that resets the variable counter and returns the objects to their original position. But it entered in conflic with the self-switch that make the objects to stop moving.

I could change the layout of the room, or find a way to undo the self-switches, but I don't think there is a way to do this last thing.

View attachment 241571
Self switches are just an array like switches but instead of the key being a single value, it's a composite array key consisting of the map ID, event ID and letter. Armed with that knowledge, you can manipulate self switches remotely by using the script call

$gameSelfSwitches.setValue([map id, event id, letter], true/false)
 

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
1,283
Reaction score
824
First Language
Javascript
Primarily Uses
RMMZ
Yes, that's exactly the type of puzzle I'm trying to do. I did a similar way to do it by creating variables that checks on X and Y position of the events. The 'pushable objects' adds 1 to a variable named 'OnionRoom' when it is on the correct position. The self-switch is to stop the obect to move again after it reachs the target position.

View attachment 241570

After all 6 objects are placed in their correct spot, 'OnionRoom' reaches 6 and activates the condition of an automatic event that calls the animation of the chest. It also activates the switch 'ExtraPoint28' for the chest to be always visible there.

View attachment 241567View attachment 241569

So that's it, it's the way I figured to do this kind of puzzle. However, I noticed that the player could make a mistake by pushing the object to a spot where they can't move it anymore. So also did a reset button that resets the variable counter and returns the objects to their original position. But it entered in conflic with the self-switch that make the objects to stop moving.

I could change the layout of the room, or find a way to undo the self-switches, but I don't think there is a way to do this last thing.

View attachment 241571
Awesome! Well done :)

Yep looks like @Trihan beat me to it lol
I was just about to say the same thing.

Example of how to turn off self switch 'A' in the current map would like this:
JavaScript:
$gameSelfSwitches.setValue([$gameMap._mapId, eventId, 'A'], false);
Just replace eventId with the eventId you want to turn off a self switch ;)

Soo if you want to do a group of events by giving an array of eventIds could do like this:
JavaScript:
[1,12,23,44,55].forEach(function(eventId){$gameSelfSwitches.setValue([$gameMap._mapId, eventId, 'A'], false);})
That would turn of self switch 'A' for events 1, 12, 23, 44, & 55 on the current map. ;)
 
Last edited:

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,401
Reaction score
5,090
First Language
English
Primarily Uses
RMMZ
Awesome! Well done :)

Yep looks like @Trihan beat me to it lol
I was just about to say the same thing.

Example of how to turn off self switch 'A' in the current map would like this:
JavaScript:
$gameSelfSwitches.setValue([$gameMap._mapId, eventId, 'A'], false);
Just replace eventId with the eventId you want to turn off a self switch ;)

Soo if you want to do a group of events by giving an array of eventIds could do like this:
JavaScript:
[1,12,23,44,55].forEach(function(eventId){$gameSelfSwitches.setValue([$gameMap._mapId, eventId, 'A'], false);})
That would turn of self switch 'A' for events 1, 12, 23, 44, & 55 on the current map. ;)
Or to make it even more efficient/concise you could use an arrow function or for...of

JavaScript:
[1, 12, 23, 44, 55].forEach(eventId => $gameSelfSwitches.setValue([$gameMap._mapId, eventId, 'A'], false));

for (const eventId of [1, 12, 23, 44, 55]) { $gameSelfSwitches.setValue($gameMap._mapId, eventId, 'A'], false); }
 

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
1,283
Reaction score
824
First Language
Javascript
Primarily Uses
RMMZ
Or to make it even more efficient/concise you could use an arrow function or for...of

JavaScript:
[1, 12, 23, 44, 55].forEach(eventId => $gameSelfSwitches.setValue([$gameMap._mapId, eventId, 'A'], false));

for (const eventId of [1, 12, 23, 44, 55]) { $gameSelfSwitches.setValue($gameMap._mapId, eventId, 'A'], false); }
Yep personally arrow function looks best with that for sure to me. :cutesmile:
Good thinking :popcorn: I always forget about that... still not used to ES6
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,401
Reaction score
5,090
First Language
English
Primarily Uses
RMMZ
Yep personally arrow function looks best with that for sure to me. :cutesmile:
Good thinking :popcorn: I always forget about that... still not used to ES6
I love being able to use class declarations in my plugins now, it makes the code look so much neater.
 

dysphoria

Villager
Member
Joined
Jun 23, 2020
Messages
12
Reaction score
18
First Language
Spanish
Primarily Uses
RMMV
JavaScript:
$gameSelfSwitches.setValue([$gameMap._mapId, eventId, 'A'], false);
Wooh, I didn't know you can do that, the code works as expected. Thank you. Now it's time to revisit some old events with this.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,401
Reaction score
5,090
First Language
English
Primarily Uses
RMMZ
Wooh, I didn't know you can do that, the code works as expected. Thank you. Now it's time to revisit some old events with this.
Once you realise RPG Maker MV is a pile of code wearing a neat hat, a whole new world of possibility opens up to you. The engine is almost completely editable for almost any conceivable game design goal.
 

Latest Threads

Latest Profile Posts

working on an A/V sync system for my game! was NOT expecting the first roadblock to be accessing a variable from a public class!! Computers are so finicky sometimes :kaosigh:
For the first real time since my game's inception I found myself actually having fun playing around with my party's skills while testing out some battles! So much so, that I actually forgot what I was doing for a minute and had to force myself to move on to the next thing! :guffaw:

That's got to be a good sign considering it only has place holder animations, enemy skills, troop comps, etc. right now. Feels good!
Bex
Finally upgraded to RMMZ.
ScreenShot_11_28_2022_7_52_34.png
FINALLY, I figured out how to get the "tail" to appear IN the window and not directly below it lol. now it looks like it's part of the window and not hanging from the bottom of it.
Twitch! Stream is about to go live with some Dark Souls 2! Feel free to drop by!

Forum statistics

Threads
126,925
Messages
1,182,398
Members
166,755
Latest member
Hahah520
Top