Transfer Based On Map Name

Hello, everyone.


I'm attempting to code something for MV, but I'm not very good with Javascript...


So, could I make a map transfer that takes you to a map based on it's name and not it's map ID?


I know that each map will need a unique name, but I don't know how to go about coding this.


Does a plugin for this already exist? If not, does anybody have any suggestions on how to go about coding this?


Thanks in advanced.
You can use this function. Just place it inside Game_Player section in rpg_objects.js


Game_Player.prototype.reserveTeleport = function(mapName, x, y, d, fadeType) {
var maps = $dataMapInfos.filter(function(map) { return map && (map.name === mapName) });
if (maps.length > 0) { // To make it sure that it found any map
var mapId = maps[0].id; // Only get the first map ID if found more than one map with the same name
this.reserveTransfer(mapId, x, y, d, fadeType);
}
};


Script Call:


$gamePlayer.reserveTeleport(mapName, x, y, direction, fadeType);



mapName = "YourMapNameHere"


direction = look at NumPad


fadeType = 0 - Black, 1 - White, 2 - None
Thank you so much Kadafi!
I've been trying to figure this out for hours, and I was worried that my problem would never be solved.

Original thread: https://forums.rpgmakerweb.com/threads/transfer-based-on-map-name.65309/