Script call to change the display name of a map?

Discussion in 'RGSSx Script Support' started by shiori4me, Apr 23, 2014.

  1. shiori4me

    shiori4me Veteran Veteran

    Messages:
    196
    Likes Received:
    6
    Location:
    Earth
    First Language:
    English
    Because 'the player knows that a town's name is Desmont before they get told that.

    Among other things.

    I want to be able to change the display name of a map in-game.
     
    #1
  2. Shaz

    Shaz Veteran Veteran

    Messages:
    37,953
    Likes Received:
    11,614
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    The map's display name is a part of the Mapxxx.rvdata2 file, and not something that's meant to be changed while playing the game (hence not something that gets saved with the player's data).


    So in addition to a way to change it, you'd also need a way to keep track of it in the sav file, so when the game is closed and loaded again, it'll remember what name it's supposed to display.


    I don't have Ace with me at the moment, but I wonder if the map name is printed using draw_text_ex. If it is, you could just assign variables to your maps' display name (in the map properties, put \V[1] instead of the name), at the beginning of the game change the variables to what you want to display when the player first enters the map, and after they enter, change the variable to the correct name. If it works, great - you can do it without scripts and the current name will already be saved (you'd need a different variable for each map). If it doesn't work, you're back to the scripting solution.
     
    #2
  3. shiori4me

    shiori4me Veteran Veteran

    Messages:
    196
    Likes Received:
    6
    Location:
    Earth
    First Language:
    English
    It doesn't work that way, apparently.
     
    #3
  4. Shaz

    Shaz Veteran Veteran

    Messages:
    37,953
    Likes Received:
    11,614
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    haha! That'd be right.

    Okay, so add this to your scripts, in its own slot:

    class Game_System #-------------------------------------------------------------------------- # * Set Map Display Name #-------------------------------------------------------------------------- def set_map_name(display_name, map_id = $game_map.map_id) @map_names ||= {} @map_names[map_id] = display_name end #-------------------------------------------------------------------------- # * Get Map Display Name #-------------------------------------------------------------------------- def get_map_name(map_id = $game_map.map_id) @map_names ||= {} return @map_names[map_id] if @map_names.has_key?(map_id) return $game_map.display_name if map_id == $game_map.map_id return '' endendclass Window_MapName < Window_Base #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh contents.clear unless $game_system.get_map_name.empty? draw_background(contents.rect) draw_text(contents.rect, $game_system.get_map_name, 1) end endendclass Game_Interpreter #-------------------------------------------------------------------------- # * Set Map Display Name #-------------------------------------------------------------------------- def set_map_name(display_name, map_id = $game_map.map_id) $game_system.set_map_name(display_name, map_id) endend
    To change the display name, you do a Script command like this:

    set_map_name("My Map Name")which changes the name of the current map, or
    Code:
    set_map_name("My Map Name", 10)
    which changes the name of a different map (10 being the map id, no leading zeros)I've also changed the map name window so it picks it up. If you've changed the name, it'll show the new name. If you haven't changed the name, it'll show whatever is on your map. If there is no value on the map properties for the display name, the window won't appear at all (which is already the default behaviour).
     
    Last edited by a moderator: Apr 24, 2014
    #4
    Archeia likes this.
  5. shiori4me

    shiori4me Veteran Veteran

    Messages:
    196
    Likes Received:
    6
    Location:
    Earth
    First Language:
    English
    That doesn't work for me.

    On a fresh project I tried 

    set_map_name("Goblin Cave: 1F", 1)and it just gave me this error

    Script 'Game_Interpreter' line 1409: NoMethodError occurred.undefined method 'set_map_name' for #<Game_Interpreter:0xb408994> I don't always plan to use the display map name feature. Sometimes I'd just like to use it for Yanfly's Save Engine.

    Like when you're transferring to the same floor or if you're just switching maps to "change the angle" (which I've done before) and whatnot.

    Referring to line 64 of Window>MapName (for my attempt, or wherever you'd add a snippet or make adjustments), how would one achieve the ability to turn this off and on with a switch or call?

    #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh contents.clear unless $game_map.display_name.empty? if $game_switches[23] == true then draw_background(contents.rect) draw_text(contents.rect, $game_map.display_name, 1) else end end endNo... that doesn't work...
     
    Last edited by a moderator: Apr 24, 2014
    #5
  6. Solistra

    Solistra Veteran Veteran

    Messages:
    593
    Likes Received:
    242
    Shaz made a typo. In the script, change class Interpreter to class Game_Interpreter -- then it should work.
     
    #6
    Shaz likes this.
  7. shiori4me

    shiori4me Veteran Veteran

    Messages:
    196
    Likes Received:
    6
    Location:
    Earth
    First Language:
    English
    Thanks. I didn't notice that either.

    I wonder if this will be submitted to the Master Script List.

    Aww, it doesn't work with http://yanflychannel.wordpress.com/rmvxa/menu-scripts/ace-save-engine/

    be it, that script doesn't update the location name to fit the change that Shaz's snippet makes. It will affect the display name when you go from map to map, however. 

    I think it would be on this part that it deals with the map name.

    If there is a display name, it will prioritize the name of the location on the save file to that over the editor map name.

    #-------------------------------------------------------------------------- # draw_save_location #-------------------------------------------------------------------------- def draw_save_location(dx, dy, dw) return if @header[:map].nil? reset_font_settings change_color(system_color) draw_text(dx, dy, dw, line_height, YEA::SAVE::LOCATION) change_color(normal_color) cx = text_size(YEA::SAVE::LOCATION).width return if $data_mapinfos[@header[:map].map_id].nil? text = @header[:map].display_name text = $data_mapinfos[@header[:map].map_id].name if text == "" draw_text(dx+cx, dy, dw-cx, line_height, text) end So even when the display name is updated to Goblin Cave, on save it will still be displayed as Unknown Area.

    Might either of you know on that?

    Since I was planning on having it so that the display name isn't always displayed on map transfer
     
    Last edited by a moderator: Apr 24, 2014
    #7
  8. Shaz

    Shaz Veteran Veteran

    Messages:
    37,953
    Likes Received:
    11,614
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    You didn't say you were using a script or that you wanted it shown in the save/load window ;)


    More work will be needed than just changing the one line that says where to get the name from, since $game_system doesn't actually exist unless a game HAS been loaded. Or if yu're at the save/load window after playing a game, $game_system will refer to the CURRENT game, not the SAVED game.


    So the script I gave you wouldn't work for the save/load window. You'd need to do something to store the map names in the save header instead of $game_system, and have each save slot refer to its own header for the list of map names as at the time THAT game was saved.


    I can't help you out much with this one at the moment as I don't have Ace installed on my work computer and I don't have my tablet with me. Hopefully someone else will be able to give you a better solution for your specific requirements.
     
    Last edited by a moderator: Apr 24, 2014
    #8
  9. shiori4me

    shiori4me Veteran Veteran

    Messages:
    196
    Likes Received:
    6
    Location:
    Earth
    First Language:
    English
    It wouldn't have to be now, of course. I wasn't rushing.

    I originally wasn't, but then I remembered Yanfly's Save was used for displaying map names.

    There aren't as many active forum scripters assisting people now that Ace has been out for a while.

    It isn't a requirement, but the more the player knows, the better.

    Do you know how to make it so that the process of displaying a map will only work if a given condition (like switch 1 being on) is met, if I may ask?
     
    Last edited by a moderator: Apr 24, 2014
    #9

Share This Page