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.

Window_Help

Is there any way to make a line break for the text that appears in the help window? For example:

For the description of a Copper Sword, this would show up as 1 line of text at the top of the screen where the Help window is situated:

Code:
"This sword is made of copper."

However, I'd like it to not be a single line going across, and I wanted it to have breaks in it like this:

Code:
"This sword is
made of copper."

Is there any way to make it do this? I thought that if I used the \n tag in the description in the Weapons Database section that it would work, but it doesn't. I also tried changing the size of the Help window to see if the text would wrap, but it doesn't wrap.
 

khmp

Sponsor

Here is what you are looking for. It splits the lines by looking for the newline,(\n). But I haven't readjusted the window size so the text will just barely be visible. I assume with your tweaking you have adjusted the size of it before. But if you need help with that just ask. Anyway insert an empty section above main and paste in the empty code section this:

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

class Window_Help < Window_Base
  WLH = 24
  #--------------------------------------------------------------------------
  # * Set Text
  #  text  : text string displayed in window
  #  align : alignment (0..flush left, 1..center, 2..flush right)
  #--------------------------------------------------------------------------
  def set_text(text, align = 0)
    # If at least one part of text and alignment differ from last time
    if text != @text or align != @align
      # Redraw text
      self.contents.clear
      self.contents.font.color = normal_color
      
      # Split the lines separated by newline.
      lines = text.split('\n')

      # Iterate through the lines and draw each of them.
      y = 0
      lines.each do |line|
        self.contents.draw_text(4, y, self.width - 40, WLH, line, align)
        y += WLH
      end
      
      @text = text
      @align = align
      @actor = nil
    end
    self.visible = true
  end
end

Good luck with it Xathia Vastar! :thumb:
 

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