Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[VX] Requesting Actor name in maps

Hero

Member

To clarify what I'd like to have exactly, what I want is to be able to use certain tags that'll display a character's name in the map name. Like, say if I want Actor 1's name in the map, I would put in something like "[A1]'s Home" in the map editor and the game will display the map name as "Ralph's Home" when you're looking at the map location.

The reason why I want this is because in my project, I'm allowing you to choose one of 2 main characters (Boy or Girl) and their houses are in different location. To avoid confusion, I'm going to avoid using the map name "Home" for both of their houses and would rather have their names displayed along with the map name. As for why I don't just use their default names in the map name, it's because they don't have default names and you must name them both.
 
I haven't seen rgss2, but I assume it's very close to rgss.

If you can find the section of code that displays the map name, you could simply
add this code before the ".draw_text" statement.
(This is from the Window_Message class in RMXP)
Code:
      text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
        $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
      end
It replaces \N 
 
I wrote a Map Name Popup script for RMVX but I can't post it in the RGSS Section because I'm at work, and I can't create new topics while I'm at work.
So I'll post it here and repost it in the RGSS Section tonight.

Code:
#==============================================================================
# ** Map Name Popup
#------------------------------------------------------------------------------
#  © Dargor, 2008
#  06/03/08
#  Version 1.0
#------------------------------------------------------------------------------
#  INSTRUCTIONS:
#   - Paste this above main
#   - Edit the Exclude_Maps array in the Map_Name_Popup module
#  VERSION HISTORY:
#   - 1.0 (06/03/08), Initial release
#==============================================================================

#==============================================================================
#  ** Map Name Popup Configuration
#==============================================================================

module Map_Name_Popup
  # These maps will not popup the name window
  Exclude_Maps = [2,3]
end

#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :show_name
  #--------------------------------------------------------------------------
  # Alias Listing
  #--------------------------------------------------------------------------
  alias dargor_map_name_window_setup setup
  #--------------------------------------------------------------------------
  # * Setup
  #     map_id : map ID
  #--------------------------------------------------------------------------
  def setup(map_id)
    dargor_map_name_window_setup(map_id)
    @show_name = true
  end
  #--------------------------------------------------------------------------
  # * Get Map ID
  #--------------------------------------------------------------------------
  def name
    map_infos = load_data("Data/MapInfos.rvdata")
    name = map_infos[@map_id].name
    name.gsub!(/\\N\[([0-9]+)\]/i) { $game_actors[$1.to_i].name }
    return name
  end
end

#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
#  This class brings together map screen sprites, tilemaps, etc. It's used
# within the Scene_Map class.
#==============================================================================

class Spriteset_Map
  #--------------------------------------------------------------------------
  # Alias Listing
  #--------------------------------------------------------------------------
  alias dargor_spriteset_name_window_initialize initialize
  alias dargor_spriteset_name_window_update update
  alias dargor_spriteset_name_window_dispose dispose
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    create_windows
    dargor_spriteset_name_window_initialize
    update
  end
  #--------------------------------------------------------------------------
  # * Create Windows
  #--------------------------------------------------------------------------
  def create_windows
    @name_window = Window_MapName.new
    if $game_map.show_name
      @name_window.show_name($game_map.name, 128)
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    dargor_spriteset_name_window_update
    @name_window.update
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    dargor_spriteset_name_window_dispose
    @name_window.dispose
  end
end

#==============================================================================
# ** Window_Help
#------------------------------------------------------------------------------
#  This window shows skill and item explanations along with actor status.
#==============================================================================

class Window_MapName < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(name="", count=128)
    super(0, 0, 544, 64)
    self.visible = false
    self.openness = 0
    @name = name
    @count = count
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    #return unless $game_map.display_name
    self.visible = true
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.draw_text(0,0,504,32,@name,1)
    $game_map.show_name = false
  end
  #--------------------------------------------------------------------------
  # * Show Name
  #--------------------------------------------------------------------------
  def show_name(name=@name, count=@count)
    return if Map_Name_Popup::Exclude_Maps.include?($game_map.map_id)
    @name = name
    @count = count
    refresh
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    unless $scene.is_a?(Scene_Map) 
      self.visible = false
      return
    end
    if self.visible
      if @count == 0
        self.openness -= 24
        self.visible = false if self.openness == 0
        return
      end
      self.openness += 24
      @count -= 1
    end
  end
end

Simply add \N[actor_id] in the map name to display an actor's name.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top