MapID to variable - transferring player

Hello everyone,

I am trying to make an affect that mimics the light world/dark world mechanic from Link to the Past. Player triggers something or makes a selection, and it takes them to an alternate version of the map in the same exact location. They need to be able to do this on the fly, in any map.

I'm using the Transfer Player option -



Which will work perfectly, but I need to be able to designate the target map as a variable so I can use the X,Y positioning. Using another tutorial, I've tried putting $gameMap.displayName() in as a control variable, as shown



but I'm not sure I'm using it correctly because I keep getting syntax errors. I also tried to use

$gameVariables.setValue(5, $gameMap._mapId)

as a script, but when I activate everything, it takes me to a black map with just a boat on it. I copy/paste it as above, but replace "mapId" with the number of my map, in this case 23 because it is 023.

Can someone tell me what I'm doing wrong, or explain another way to do this please? Again, my objective to be able to assign different maps to different variables for the purpose of transferring the player.

Thanks!
Hi,
Forget about $gameMap.displayName(), it only gives you the display name of your current map.
What you need is the ID, X and Y of your destination map.
So 3 variables, for exemple "MapID", "MapX" and "MapY".
You can get the X and Y from the "Get Location Info" option assuming your 2 maps are identical.
As for the ID, you'll need to check the ID number of your destination map and put it into your "MapID" variable.
How are you going to determine what the target map id is? Unless you have them all offset by a special amount (map 1 transfers to map 51 and vice versa, maps 2 and 52, 3 and 53, etc) you are going to have to set each destination map individually, using Control Variables and setting it to the exact map number. $gameMap._mapId will give you the map number you're ON - not the one you need to GO TO.

If you have them all equally offset as above, then you could simply do a Call Common Event, where the common event is set up something like this:

Code:
Control Variables: newMap = Game Data > Other > Map ID
Conditional Branch: newMap > 50
  Control Variables: newMap -= 50
Else
  Control Variables: newMap += 50
End
Control Variables: X = Game Data > Other > Player's Map X
Control Variables: Y = Game Data > Other > Player's Map Y
Transfer to variable newMap, variable X, variable Y

In this case, if you're on map 51, it will transfer you to map 1, but if you're on map 1, it will transfer you to 51.

If you hadn't planned to do this from the start, and your maps are not this organized, you'll need to do something like this instead (in this example, you'll transfer from the current map to map 18):
Code:
Control Variables: newMap = 18
// the below could still go into a common event, and you'd just put the Call Common Event command into your map event.
Control Variables: X = Game Data > Other > Player's Map X
Control Variables: Y = Game Data > Other > Player's Map Y
Transfer to variable newMap, variable X, variable Y
Hi,
Forget about $gameMap.displayName(), it only gives you the display name of your current map.
What you need is the ID, X and Y of your destination map.
So 3 variables, for exemple "MapID", "MapX" and "MapY".
You can get the X and Y from the "Get Location Info" option assuming your 2 maps are identical.
As for the ID, you'll need to check the ID number of your destination map and put it into your "MapID" variable.

This is what I am trying to figure out...how do I join the MapID to a variable?

How are you going to determine what the target map id is? Unless you have them all offset by a special amount (map 1 transfers to map 51 and vice versa, maps 2 and 52, 3 and 53, etc) you are going to have to set each destination map individually, using Control Variables and setting it to the exact map number. $gameMap._mapId will give you the map number you're ON - not the one you need to GO TO.

If you have them all equally offset as above, then you could simply do a Call Common Event, where the common event is set up something like this:

Code:
Control Variables: newMap = Game Data > Other > Map ID
Conditional Branch: newMap > 50
  Control Variables: newMap -= 50
Else
  Control Variables: newMap += 50
End
Control Variables: X = Game Data > Other > Player's Map X
Control Variables: Y = Game Data > Other > Player's Map Y
Transfer to variable newMap, variable X, variable Y

In this case, if you're on map 51, it will transfer you to map 1, but if you're on map 1, it will transfer you to 51.

If you hadn't planned to do this from the start, and your maps are not this organized, you'll need to do something like this instead (in this example, you'll transfer from the current map to map 18):
Code:
Control Variables: newMap = 18
// the below could still go into a common event, and you'd just put the Call Common Event command into your map event.
Control Variables: X = Game Data > Other > Player's Map X
Control Variables: Y = Game Data > Other > Player's Map Y
Transfer to variable newMap, variable X, variable Y

I am looking for something like your bottom example there. When you say "Control Variables: newMap = 18" is this what you mean?



I am at the point you guys are describing, I just cannot figure out how to link the map name/number to a variable that I can then call out later.
Yes, that's exactly how you simply put value into a variable.
Then you just use this, plus your X and Y in your transfer
Thanks, I just tried it, and that did indeed work. Thanks a lot for your help guys.

My skill with coding is only intermediate, so there are some things and concepts I still don't get. To me, it seems like using the above control variable would simply label Variable 005 as "18" to be called out later on down the road. At this point I don't quite understand where the program links that "18" with the mapID 018.

In


Control Variables: newMap = 18
// the below could still go into a common event, and you'd just put the Call Common Event command into your map event.
Control Variables: X = Game Data > Other > Player's Map X
Control Variables: Y = Game Data > Other > Player's Map Y
Transfer to variable newMap, variable X, variable Y




For instance, the MapID tag, or DisplayName, or anything else I would consider a behind the scenes mechanic isn't present anywhere. Are all variables as numbers just assumed to be MapID's by the system?

Either way, thanks a lot again. It was oh-so-simple for you guys, put this particular thing brought me to a stand still for like 5 hours 😛
It's much simpler that you'd think.

Your variables are basically just numbers. Map Ids are also just numbers.
So when you put "18" into your Variable 005, the game just read your Variable 005 as "18".
You can use your variables for anything that is expecting a number.
In this case, when using it in your transfer event, the game expect a Map ID number, so it will assume your "18" is corresponding to an existing Map ID number.
You transfer to a map number, not a map name or display name. When you use variables in the transfer command, the map id, x and y position are all just numbers. Map names and display names have no meaning at all when you're building the game - you won't find them in the command list, because you refer to a map by its id/number, not by its name.

The Map Id is certainly there - in Control Variables > Game Data > Other. But you don't need it, because that is giving you the map id of the map you are already on, and that is not what you want to transfer to.
For anyone else who happens to have the same question and doesn't quite get what these guys are saying like I did at first. The map ID variable

Capture1.PNG



Needs to be set to the map ID number (in this example "4")

Capture2.PNG


Hope that's a little more plain speak for those that need it.

@Carp0nastick, please refrain from necro-posting in a thread. Necro-posting is posting in a thread that has not had posting activity in over 30 days. You can review our forum rules here. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/mapid-to-variable-transferring-player.92565/