Hello, I am having trouble finding a tutorial on how to do exactly this... I want the player to press the space bar while standing on a region square and go to that region's correlating map. So when they are on a grasslands tile (1) and press space bar, they'll go to the grasslands map. And if they press ESC while in the grasslands map, they'll go back to the world map. How do I do this? Any help is appreciated. Thank you.
Player transfer by region and button press
RPG Maker MZ SupportHello, I am having trouble finding a tutorial on how to do exactly this... I want the player to press the space bar while standing on a region square and go to that region's correlating map. So when they are on a grasslands tile (1) and press space bar, they'll go to the grasslands map. And if they press ESC while in the grasslands map, they'll go back to the world map. How do I do this? Any help is appreciated. Thank you.
Hello and welcome!
There's many ways that lead to Rome, but sticking just to vanilla RPG Maker, you could do something like this:
In this example, the player will be placed on the exact same coordinates on the new map. This is just to show you the principle, and I hope you can use this as a starting point to create something that fits your situation.
There's many ways that lead to Rome, but sticking just to vanilla RPG Maker, you could do something like this:
In this example, the player will be placed on the exact same coordinates on the new map. This is just to show you the principle, and I hope you can use this as a starting point to create something that fits your situation.
Thank you very much for the information!
Well I almost got it to work lol. But whenever I press space bar on the region I get "SyntaxError - Unexpected identifier" what am I doing wrong? I'm trying to go to a region 1 tile, press space bar, and go to the grasslands map.
Nevermind, I figured out what I was doing wrong, thanks again.
Well I almost got it to work lol. But whenever I press space bar on the region I get "SyntaxError - Unexpected identifier" what am I doing wrong? I'm trying to go to a region 1 tile, press space bar, and go to the grasslands map.
Nevermind, I figured out what I was doing wrong, thanks again.
"Unexpected identifier" generally signifies a grammatical mistake in a script.
Note that you can get the region ID of a character without scripting, by using Get Location Info instead of Control Variables:

It's much easier to make a mistake with scripting!
$gamePlayer.regionId() looks OK, so I guess it was a script call on the target map?Note that you can get the region ID of a character without scripting, by using Get Location Info instead of Control Variables:

It's much easier to make a mistake with scripting!
Cool! Thanks for the information! This next part might be a little more difficult...
So the Player is on the World Map and presses Space Bar and gets transferred to a grasslands map. The grasslands map loops so I would need them to press Space Bar again to exit the map.
How do I get them to return to the same spot they were at on the World Map?
So the Player is on the World Map and presses Space Bar and gets transferred to a grasslands map. The grasslands map loops so I would need them to press Space Bar again to exit the map.
How do I get them to return to the same spot they were at on the World Map?
What you would need to do is save the X and Y coordinates before you leave the world map, as well as the Map ID, using Control Variables.
Then, when returning to the world map, just do a transfer using the three variables:
Hope it helps.
I must not have done it correctly, how do you 'save' the location?
Each variable is like a "box" that holds a value. The Control Variables command lets you change what is in those boxes.
Here's a quote from a recent post of mine on a similar topic:
Here's a quote from a recent post of mine on a similar topic:
Thank you very much for your help
I'm sorry to keep asking for help but it's doing something weird... I leave map A to go to map B. I leave map B and it keeps the same x and y of my event location on map B, and places the player on those coordinates but on map A. I hope that made sense... I'm gonna include my events
Map A
Map B
I'm sorry to keep asking for help but it's doing something weird... I leave map A to go to map B. I leave map B and it keeps the same x and y of my event location on map B, and places the player on those coordinates but on map A. I hope that made sense... I'm gonna include my events
Map A
Map B
That’s because you’re resetting variables 81 and 82 to the x and y coordinates of map B. 81 and 82 are meant to store x and y of the original world map. So you don’t want to overwrite them when on the grasslands biome map.
Try to not blindly copy things that people here present you. You need to try and understand what each line is doing. Chew on it, if you will. You’ve done the tutorials included with RPG MAKER MZ, accessible from the help menu? If not, that is an absolute must, especially if you’re new to things like logic and programming.
Try to not blindly copy things that people here present you. You need to try and understand what each line is doing. Chew on it, if you will. You’ve done the tutorials included with RPG MAKER MZ, accessible from the help menu? If not, that is an absolute must, especially if you’re new to things like logic and programming.
Original thread: https://forums.rpgmakerweb.com/threads/player-transfer-by-region-and-button-press.175649/