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.

Automatic newline in message window?

tdog

Member

Hey folks, and yes, I know it's very typical of me, that my very first post is a request; I'm sure I'll contribute to RMXP.org in the near future ; )

So yeah, basically I was wondering if there was a way to automatically output new lines in message boxes? If you're confused, what I mean is that, would be possible to not have to use those silly little arrows built in to the "Show Text" editor, and be able to type normally without having to worry about the text going off the edge of the window skin.

Such a feature is present in Neo Message System, but unfortunately it cuts words in half while doing it. I've talked to the author himself, and he's just as eager to fix the problem as I am.

So yeah, if anyone has any insight, please reply. Oh, and it would have to be flexible enough to work with large facesets, too.
 
I need to do this for a system I'm working on for XP. To fix the problem with substitutions leaving too much blank space.

I plan to make a separate method that uses the logic from Tricksters "Show_Wrap_Text" method in the MACL to adjust
the newline characters in the string sent to the message window. So, it should work equally well in VX.
I won't be able to test it in VX, since my trial ran out & I haven't bothered to buy it yet. But, if no one has covered this
by the time I get it done, you're welcome to it.

Be Well
 
That's easier! :scruff:

But it still won't account for custom message commands. Where something like
"\FACE[faceset_12]" gets removed from the line leaving a big gap.

I expect they left a little extra space in the editor to account for the built-in substitutions (\v[10], \C[7], etc..). Allowing you to go past the arrow a bit
when you use them.

Be Well
 
What I usually do (with ccoa's UMS) is put a "\ign" in front of a long line of code (to skip it), use the "Call Script" function rather than putting it in the text, or put "\face[]\nm[]" at the END of the paragraph. Shortcuts and "Batch Text Entry" are also very useful. But it seems you have a problem, pity you're using VX...

I suppose a new script for this would be the easiest method.
 
I wrote this String method for XP. To use it in XP, you'd call it from the Window_Message 'refresh' method, right after the Gold Window substitution
Code:
      text.gsub!(/\\[Gg]/) { "\002" }
      # Rejustify the text
      text = text.justify_text(508)

I need to look at the VX scripts to see where to put it.

Code:
class String
  def justify_text(width = 448)
    self.gsub!(/\n/) {}
    words = self.scan(/[^ ]+/)
    bitmap = Bitmap.new(640, 32)
    space = bitmap.text_size(" ").width
    linesize = 0
    wordsize = 0
    output_string = ""
    for word in words
      wordsize = bitmap.text_size(word).width
      if linesize + wordsize < width
        output_string += word + " "
        linesize += wordsize + space
      else
        output_string += "\n" + word + " "
        linesize = wordsize + space
      end
    end
    return output_string
  end
end
 
Code:
class Window_Message
  alias :justify_conversion :convert_special_characters
  def convert_special_characters
    justify_conversion
    @text.justify_text(508)
  end
end

Above code, converted for VX.
 

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