Rename a map with script

d_a_renoir

Veteran
Veteran
Joined
Jun 12, 2012
Messages
237
Reaction score
27
First Language
English
Primarily Uses
Is it possible to rename a map with a script? I saw modern algebra's script where the player can manually enter a name, but is it possible to instead use an item to rename the map? Or set the map name using Areas and such?

Modern Algebra's code under spoiler

Code:
#==============================================================================
#    Player-Named Maps
#    Version: 1.0
#    Author: modern algebra (rmrk.net)
#    Date: December 8, 2009
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#    This script allows you to call a scene that lets the player change the
#   name of the maps. It only really makes sense if you have another script
#   that shows the names of the maps.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#    Place this script in your editor, above Main and below the default scripts
#
#    To call the map naming scene, use this code in a call script:
#      call_map_name (map_id, max_chars)
#        map_id    : the ID of the map you want the player to name
#        max_chars : the maximum number of characters for the name. This
#          defaults to 10 if not set by you.
#
#    This script requires you to have a dummy actor who never appears in the
#   game and ought not be setup - it is his face graphic that will show up in
#   the map naming screen, so if you wanted to have the map represented by a
#   96x96 graphic you could import it as a face graphic and set it on the dummy
#   actor immediately prior to calling the map naming screen. Otherwise leave
#   it blank. To set the ID for that actor, go to line 45 and change the number
#   to the ID of that dummy actor. You may also determine whether you want the
#   database name of the map to initially show up while setting the name or
#   whether you just want it to be blank at line 48
#==============================================================================

#==============================================================================
# ** RPG::MapInfo
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new constant - MAMN_DUMMY_ACTOR
#    aliased method - name
#==============================================================================

class RPG::MapInfo
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * CONSTANT
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # Set this value to the ID of an actor to use as a dummy while naming maps
  MAMN_DUMMY_ACTOR = 9 
  # The following determines whether the naming scene starts by showing the
  #  database name or whether it starts blank
  MAMN_SHOW_CURRENT_NAME = true
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Get Name
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malg_jtswyr_namemps_7yu2 name
  def name (*args)
    real_name = malg_jtswyr_namemps_7yu2 (*args)
    return $game_system.ma_map_names[real_name] unless $game_system.nil? ||
                                      $game_system.ma_map_names[real_name].nil?
    return real_name
  end
end

#==============================================================================
# ** Game_System
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new public instance variable - ma_map_names, ma_map_name_id
#    aliased method - initialize
#==============================================================================

class Game_System
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_reader   :ma_map_names
  attr_accessor :ma_map_name_id
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialize
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_jsswyr_intlz_mpnmes_9kb3 initialize
  def initialize (*args)
    @ma_map_names = {}                  # Initialize Map name hash
    @ma_map_name_id = 1
    ma_jsswyr_intlz_mpnmes_9kb3 (*args) # Run Original Method
  end
end

#==============================================================================
# ** Game_Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - call_map_name
#==============================================================================

class Game_Interpreter
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Call Map Name
  #    map_id : ID of map to name
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def call_map_name (map_id, max_chars = 10)
    $game_system.ma_map_name_id = map_id
    $game_temp.name_max_char = max_chars
    $scene = Scene_MapName.new
  end
end

#==============================================================================
# ** Scene_MapName
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Subclass of Scene_Name
#  altered methods - start, return_scene
#==============================================================================

class Scene_MapName < Scene_Name
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Start Processing
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def start (*args)
    @map_id = $game_system.ma_map_name_id
    $game_temp.name_actor_id = RPG::MapInfo::MAMN_DUMMY_ACTOR
    $game_actors[$game_temp.name_actor_id].name = ""
    if RPG::MapInfo::MAMN_SHOW_CURRENT_NAME
      db_name = load_data ("Data/MapInfos.rvdata")[@map_id].name
      cnt_name = $game_system.ma_map_names[db_name]
      $game_actors[$game_temp.name_actor_id].name = cnt_name.nil? ? db_name : cnt_name
    end
    super (*args)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Return Scene
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def return_scene (*args)
    map_name = load_data ("Data/MapInfos.rvdata")[@map_id].name
    $game_system.ma_map_names[map_name] = @actor.name
    super (*args)
  end
end
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
Taking a look at the code, it seems that the only two lines that you actually need to put in your event/item to change the map name are these:
Code:
map_name = load_data ("Data/MapInfos.rvdata")[map_id].name
$game_system.ma_map_names[map_name] = new_name_goes_here
Provided that you are using the script you mentioned, those two lines (with appropriate values for "map_id" and "new_name_goes_here") should be enough to allow you to rename any map you want from anywhere.
 

d_a_renoir

Veteran
Veteran
Joined
Jun 12, 2012
Messages
237
Reaction score
27
First Language
English
Primarily Uses
The script is meant to call a "name input screen". I understand enough of RGSS to understand that this part is part of the name input screen (inserting the text you input into the database)

Code:
map_name = load_data ("Data/MapInfos.rvdata")[map_id].name
$game_system.ma_map_names[map_name] = new_name_goes_here
Do I need to modify or get rid of the name input screen first to make this work?
 

d_a_renoir

Veteran
Veteran
Joined
Jun 12, 2012
Messages
237
Reaction score
27
First Language
English
Primarily Uses
Tried calling this script

Code:
call_map_name (19, "new name")

Got a no method error. Undefined [] for nil:NilClass

The referred line goes like this:
Code:
$game_system.ma_map_names[real_name].nil?
 
Last edited:

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
@d_a_renoir the reason I specifically mentioned those two lines is because you have to use those two, nothing else. The reason why I told you to keep the script you posted in your project is because those two lines refer to a hash that is otherwise non-existent in the default VX engine, so they are not going to work if you remove the whole script.
 

d_a_renoir

Veteran
Veteran
Joined
Jun 12, 2012
Messages
237
Reaction score
27
First Language
English
Primarily Uses
@d_a_renoir the reason I specifically mentioned those two lines is because you have to use those two, nothing else. The reason why I told you to keep the script you posted in your project is because those two lines refer to a hash that is otherwise non-existent in the default VX engine, so they are not going to work if you remove the whole script.
I didn't remove anything. I actually thought you meant I should add your code into the script.
So based on Roninator's comment, did you mean I should've put them on the script call? Because I used the script call instructed in the original script itself.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
put in your event/item
As I said, you have to put them in your event/item, so yes, a script call is the way to go. Even a skill/item formula works, as long as you put both of them on the same line and use a semicolon as a separator (having both of them on the same line only works for the skill/item formula, if you put them in a script call use two separate lines instead).
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Yet another gaming question, i'm currently playing Last of Us 2 and want to get another game to play next but can't decide between Ghost of Tsushima, Miles Morales & Jedi Fallen Order. After the latest mandalorian i AM on a star wars kick, but i also LOVED the last spiderman game that prequels Miles Morales. Ghost of Tsushima is the bottom of my list but i heard it was AWESOME. Just want a good story & fun gameplay.
I checked out Genshin Impact gameplay out of curiosity. I can't believe it's available as a mobile game too. Smooth animation, great music, and stellar sound effects (the ambient sounds are pretty detailed).

I'm flabbergasted to see games have becoming more and more advanced. Maybe also because I'm oblivious to current trend for a long time, it almost feel like I'm being sent into distant future. xD
xDRAGOONx wrote on WaywardMartian's profile.
Your artwork is amazing!!!
:ewat:
Stream will be live shortly with a session of the Interactive Text Adventure! Feel free to drop by!
I should finish the cat video I'm editing and finish the indesign stuff. So far only 1 is done and 4 to go

Forum statistics

Threads
105,664
Messages
1,015,380
Members
137,341
Latest member
jasapembuatanwebsite
Top