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.

How to add map location to menu?

Okey, im newb in scripting and I can barely edit scripts. I am currently trying to create menu to suit my means and i need to add "map location" to menu screen. Let's assume that we have blank menu and with piece of script I would like to add the map location there. I tried to figure it out by looking other people's scripts but without success.

Part of script where the location and details for "map location is defined" should look something like this, if I have understood correctly:

Code:
def refresh
 self.contents.font.color = system_color
 self.contents.font.size = 20
 self.contents.draw_text(10, 0, 220, 30, "Location")
 self.contents.font.size = 20
 self.contents.font.color = normal_color
 self.contents.draw_text(110, 15, 80, 30, $game_map.name)
end

Don't care about the locations of map name & location texts, they are just random.

So, where should I place this and what should I add, to make this show up in menu? And as I said, im newb in scripting ruby so correct me if I said something wrong. I will appreciate any kind of help.

Thanks.
 
Add this outside the class (before class Something)
Code:
$data_map_infos = load_data('Data/MapInfos.rxdata')

Map names are stored there.
Then, change:
Code:
$game_map.name

with:
Code:
$data_map_infos[$game_map.map_id].name
 
Or, you could just add the map name as a method to the Game_Map. You can do that by putting this in a new script.
Code:
class Game_Map
  #--------------------------------------------------------------------------
  # * Get Map Name
  #--------------------------------------------------------------------------
  def name(id = map_id)
    $map_data = load_data("Data/MapInfos.rxdata")
    return $map_data[map_id].name
  end
end
You could then just keep $game_map.name there, and you'd be able to add that where ever you please.

You could also get the map name of any map you want to without being present on that map when called.
 

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