Storing Map Names into Variables?

Is there a way to do this? I know you can store the Map ID, but....what about the name?
Damn tootin!


Save current map name to var 6 anyone


$gameVariables.setVariable(6, $dataMap.displayName);


What are you trying to accomplish?
Use the regular Control Variables command, and put $gameMap.displayName() into the Script box under the Operand group.


 
0ea48e97bb.png



(that | at the end is the cursor - don't type that)
@Shaz Are you sure it is $gameMap? I could only find $dataMap when it concerns the displayName function...
Yes it is $gameMap.displayName(); $gameMap is a wrapper for $dataMap.displayName.


//Game Map Prototype
Game_Map.prototype.displayName = function() {
return $dataMap.displayName;
};



Hope this helps.
Use the regular Control Variables command, and put $gameMap.displayName() into the Script box under the Operand group.


 
0ea48e97bb.png



(that | at the end is the cursor - don't type that)



Got it to work, thanks so much!
@Shaz Are you sure it is $gameMap? I could only find $dataMap when it concerns the displayName function...



I just looked in the scripts at the Window_MapName class - that's exactly what it uses. 🙂
@Shaz


Yeah I looked over it again and saw it very clearly. lol Not sure how i missed it.
The global $dataMap class is something new with MV.  In all previous versions of the engine, this stuff used to belong in $gameMap (or $game_map).  So I'm used to using $game_map to get this sort of stuff, and immediately expected it to be related to that class.  I'm not really sure why they've made $dataMap global now - unless it's just to reduce the lookups to the $gameMap methods to get stuff from the @data variable (which is the old equivalent of $dataMap).
Cool Stuff! Quick question... how would I save the name of a specific map that is not the currently opened map to variable 6 as is shown in the example above?

For example, I'd like to save the name of Map# 165 to a variable.

//Game Map Prototype
Game_Map.prototype.displayName = function() {
return $dataMap.displayName;
};

$gameVariables.setVariable(6, $dataMap.displayName);

I am guessing that I have to replace displayName with something else that points to the specific map number, but I am not sure what.

I searched around a bit and found some folks talking about $gameMap._mapId so I tried putting $gameMap._mapId-165 in a variable but that doesn't seem to work.

I am trying to get the name of a map I am not on, and store that name in a variable.

Any help or insight on this would be greatly appreciated.
same question^^
Are you changing the name of the map somehow during the game?

If not... Just set the variable to that name. If the name of map 165 is "Town Hall", just set the variable to "Town Hall".
what script call do you use to call for the display name of a map you are not currently on?

Original thread: https://forums.rpgmakerweb.com/threads/storing-map-names-into-variables.56838/