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.

[Resolved]Location Window.

Status
Not open for further replies.

Juuhou

Sponsor

Something weird has come up when I tried to add a location window to my menu. This is the script:

Code:
#==============================================================================
# â–  Window_Location
#------------------------------------------------------------------------------
#  This displays your location via map name.
#==============================================================================

class Window_Location < Window_Base
  #--------------------------------------------------------------------------
  # ● Object Initialization
  #--------------------------------------------------------------------------
  def initialize
	super(0, 0, 193, 43)
	self.contents = Bitmap.new(width - 32, height - 32)
	self.contents.font.name = "Tahoma"
	self.contents.font.size = 13
	refresh
  end
  #--------------------------------------------------------------------------
  # ● Refresh
  #--------------------------------------------------------------------------
  def refresh
	self.contents.clear
	self.contents.font.color = system_color
	self.contents.draw_text(7, -3, 120, 15, "Location")
	self.contents.font.color = normal_color  
	self.contents.draw_text(25, -3, 120, 15, $game_map.name.to_s, 2)
  end
end

The error is on line 26 when it refers to the $game_map.name variable. For some reason it wont read it and gives me this error:

Code:
Script 'Window Location' line26: NoMethodError occurred.

Undefined method 'name' for #<Game_Map:0x17f1620>

Obviously the method is undefined...so for you scripters, how would I be able to make the method err...definable?? Its weird though because this location window works in every other game Ive put it in.
 

Culex

Member

Replace this:

Code:
self.contents.draw_text(25, -3, 120, 15, $game_map.name.to_s, 2)

With this:

Code:
[...]
$data_map_infos = load_data("Data/MapInfos.rxdata")
self.contents.draw_text(25, -3, 120, 15, $data_map_infos[$game_map.map_id].name)
[...]
 

Juuhou

Sponsor

Well that make sense. I actually just realized why it hadnt worked but had previously in all my other games. I was using DubeAlex's AMS and Im guessing that the map name mthod is utilized somewhere in there, thus allowing me to call it using those variables. Well, I see how it works now so I guess we can say. Topic resolved? Thanks anyways ^_^
 
This topic has been resolved. If Juuhou or any other users have any questions or further problems regarding this topic, please create a new thread about them.

Thank you!
 
Status
Not open for further replies.

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