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.

Wrap Item Description Text to 2 Lines in Item Sub-Menu?

Hello! I need longer two-line item descriptions that wrap to a second line (rather than just scrunching the whole thing ridiculously onto one short line as it already does). What do I need to change in the Window_Help script to make this word-wrap effect?

I already have re-sized the main box, but it looks silly since my long item description is squished into the top half of it, with plenty of empty space on the bottom half of the box.
 
Put this above main.

Code:
class Window_Help < Window_Base

  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

      text2 = text.split('\n')

      # Redraw text

      self.contents.clear

      self.contents.font.color = Color.new(255,255,255)

      for line in 0...text2.length

        self.contents.draw_text(4, line*self.contents.font.size+2, self.width - 40, 32, text2[line], align)

      end

      @text = text

      @align = align

      @actor = nil

    end

    self.visible = true

  end

end

This will mimic the 'Enter' button by placing a \n where an new line would be.

line1\nline2

Would make:

line1
line2

If that makes sense?
Also, this is a really good idea, too :)
 
Hey, thanks you a lot! I did what you said and it worked perfectly. I might try to make it 3 lines, even! What messed me up at first is that I was using a new script I made, Windows_BHelp instead of Help, so once I changed the new script to say "class Window_BHelp < Window_Base" it worked perfectly. Thanks again!

P.S. If I put this script like at the top of the script database, instead of right above main, would it still work? Does order matter? I know that is a noob question.
 
I didn't know that! I have a lot of customized scripts below or above their derivitative scripts (my BHelp is right below Help, for instance) and I haven't had any special troubles with it (or so I think!). What functionality am I sacrificing by keeping them there? Can I not use debug mode effectively? (I haven't used it, but it would be awesomely helpful I imagine).
 
The reason people say 'put it after main' is because all classes are already loaded, so if need be, the new scripts have access to everything.
Also, if there are class re-writes, the new sections can be added over the script, provided its loaded after (below).

Say there's 2 classes:

1 copy:
Code:
class Foo

  def initialize

    puts 'this is the original method'

  end

end

and a modified copy
Code:
class Foo

  def initialize

    puts 'new method here'

  end

end

If the second one came before the first, the method would still say 'this is the original method' because it was loaded last, overriding the modified copy.
So when you're adding new scripts, its best to add the modified ones last.

EDIT: Oh, and press F9 to open up the debug screen ;)
 
Very cool. I've not yet gotten the hang of modifying the pre-made scripts via a new script. I've usually done a much worse method, which is basically to copy any old script I need as a new script, make sure my custom menus call only that one instead, and modify that new copy only. It's safer, I guess, so I don't screw up anything that already worked, only the copy, but I have to go and reference the new one in any scripts I am modifying that formerly used the original.

I bet if I brush up on Ruby and how to create a new script to modify the parameters of an original from within my scene script, I could save a lot of leg work.

But how do I make sure I only modify a script for use with the new script only? For instance, if i want two different menu backgrounds, i'll usually create two menu windows and use them separately for each Menu scene. So you are saying I can take the default Menu Window and withing my Second Menu Style Scene adjust the default Menu's properties to make the Second menu Style Scene look different without affecting the First Menu Style Scene?
 

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