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.

Simple help window help

I'm trying to make a help window, which displays actor 001's name and a variable, that displays on the map scene when called. I've tried a few things, but I just can't figure what I need to do. I made my scripting debut about ten minutes ago when I found ccoa's window tutorial.

Code:
class Window_MapHelp < Window_Base

  

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    super(0, 0, 640, 64)

    self.contents = Bitmap.new(width - 32, height - 32)

    refresh

  end

 

  #--------------------------------------------------------------------------

  # * Refresh

  #--------------------------------------------------------------------------

  def refresh

    self.contents.clear

    $game_switches[69] = true

    self.contents.draw_text(0, 0, 640, 32, "Name!", 1)

  end

end

I'd like for it to display the character's name, rather than just 'Name!' The switch is so that I can determine whether or not the window is displayed; I don't know any other way to do that.

I'd really appreciate it if any helping could detail how this is done. I don't want to have to ask for help in the future.

Thanks in advance!

EDIT: Also, I had it displaying the character's name before, but it wouldn't update when I changed the character's name, so I reverted it to how it is now. I guess I need to specify that the character's name changes frequently.
 
Neither of those worked P:

I've tried a few other things and searched few a couple of other tutorials, but I haven't figured it out yet.

EDIT: Ah, there were remnants of another try getting in my way. That worked, Miles. Thank you!
 
You could try using the $game_party variable:) You could display the leader of the team :p like this:

$game_party.members.first.name
( first return the 1st item in an array )

Side note on your code, you shouldn't set that game_switch in the refresh method, which can get called fairly often.
You need to call the refresh method right after the name has been changed as well. :) Because nothing will do it for you!

What you could do, is to do this instead:
[rgss] 
class Window_MapHelp < Window_Base
 
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 640, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    @name = ""
    $game_switches[69] = true
    refresh
  end
 
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @name = $game_party.members.first.name
    self.contents.draw_text(0, 0, 640, 32, @name, 1)
  end
 
  def update
    super #call the update from WindowBase
    refresh if @name != $game_party.members.first.name  # call refresh if the name of the 1st member is different than the one displayed
    # do other stuff that needs to happen at every frame
  end
end
 
[/rgss]
 

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