RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[VXA] ATS: Formatting 1.1.5

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
ATS: Formatting
Version: 1.1.5
Author: modern algebra
Date: 26 February 2015

Version History


  • <Version 1.1.5> 2015.02.26 - Fixed error when used with Face Options
  • <Version 1.1.3> 2014.04.30 - Fixed error with mid-line size changes and incomplete lines after forcing a new page with \pn. Also updated ParagraphFormatter to version 1.0.1
  • <Version 1.1.2> 2012.10.04 - Fixed an error where alignment would erase the text if paragraph formatting was not on and if there were wait codes in the text.
  • <Version 1.1.1> 2012.09.24 - Fixed an error where alignment would not work if there was a space before an explicit line break.
  • <Version 1.1.0> 2012.09.08 - Modified the paragraph formatting methods in this script to be more consistent with my other scripts, and I also fixed an error where \n would not break a line if there was nothing in it.
  • <Version 1.0.3> 2012.08.01 - Added \lb as an alternate code to break a line
  • <Version 1.0.2> 2012.07.31 - Fixed an incompatibility that could occur with other message scripts
  • <Version 1.0a> 2012.04.23 - Included the Escape Codes Fix in the body of the script
  • <Version 1.0> 2012.01.28 - Original Release

Description


This script adds a few features when using the Display Text event command. Most notably, the paragraph formatting feature allows you to write text without any fear that it will get cut off when it shows up in-game. This should work with any font and it is designed to recognize most message codes that are added, even by unrelated scripts. Supplementary to that, you can set it so that subsequent text boxes are appended, which allows you to write long dialogues using paragraph format without fear of weird page breaks. Finally, it adds a feature that allows you to align the text differently.

Features

  • Paragraph Formatting permits you to ignore the markers when displaying text - nothing will get cut off.
  • Appended Text supplements paragraph formatting for long dialogues
  • Can align the text

Screenshots



Instructions

Paste this script into its own slot in the Script Editor, above Main but below Materials. If you are using another message script, I recommend that this script be placed below it.

Please see the header of the script for instructions on use.

Script


Code: [Select]
#==============================================================================
#    ATS: Formatting [VXA]
#    Version: 1.1.5
#    Author: modern algebra (rmrk.net)
#    Date: 26 February 2015
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This script essentially adds three features to your messages, all of which
#   may be familiar if you used the VX version of the ATS. The first feature is
#   paragraph formatting, and if that is on then the script will essentially
#   draw the text so that only as much text as can fit on a line is included.
#   In other words, if you have put so much text in a message such that it
#   would normally be cut off on the right, this script will make it so that
#   instead, if the text is in danger of being cut off, it will simply draw it
#   on the next line. Along with this, this script will also bring in a new
#   message code to start a new line (since the traditional line breaks are
#   wiped out when you use paragraph format).
#
#    The second feature is appended text, which in this context is really only
#   useful if you are using paragraph format. When you have this feature on,
#   what it will do is make it so that the text in any immediately subsequent
#   Display Text event command with the same settings will be joined to the
#   first text window, and then they will be shown in the same window if there
#   is room. What this means is that if, for instance, you have two messages,
#   and the first would only show two lines and the second would show three
#   lines, then in-game, if appended text is on, the first two lines of the
#   second command would be shown with the two lines of the first command, and
#   the next page would only show the last line of the second command. It is a
#   useful feature when using paragraph formatting, since otherwise when
#   writing long dialogues with the same character, you would need to be
#   writing in sets of four lines so that it doesn't have weird stops.
#
#    The third feature is text alignment, so you can now set it so that text is
#   aligned to the left, right or centre in the message box.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  ATS Series:
#
#    This script is part of the Advanced Text System series of scripts. These
#   scripts are based off the Advanced Text System for RMVX, but since RMVX Ace
#   has a much more sensibly designed message system, it is no longer necessary
#   that it be one large script. For that reason, and responding to feedback on
#   the ATS, I have split the ATS into multiple different scripts so that you
#   only need to pick up the components for the features that you want. It is
#   therefore easier to customize and configure.
#
#    To find more scripts in the ATS Series, please visit:
#      http://rmrk.net/index.php/topic,44525.0.html
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Paste this script into its own slot in the Script Editor, above Main but
#   below Materials. If you are using another message system, such as Yanfly's
#   Ace Message System, I recommend that this script be placed underneath it.
#
#    You can change the default setting for paragraph formatting at line 127.
#   Currently, it is set to true, which means that it will be operative in
#   every message unless you specifically turn it off. To change this default
#   value in-game, use one of the following codes in a script call:
#
#      ats_all(:paragraph_format, true)    # Turns paragraph format on
#      ats_all(:paragraph_format, false)   # Turns paragraph format off
#
#    Similarly, you can change it for just the very next display text command. 
#   Simply use one of the following codes in a script call:
#
#      ats_next(:paragraph_format, true)   # Turns paragraph format on
#      ats_next(:paragraph_format, false)  # Turns paragraph format off
#
#   Alternatively, you can turn paragraph format on or off for a message by
#   message codes. See the special message codes list at lines 96 and 97.
#
#    You can change the default setting for appended text at line 135. If true,
#   then any immediately subsequent display text commands with the same
#   same settings (same face, background, position) will be added to the
#   message shown.
#
#    Similar to paragraph format, you can use the following commands in a
#   script call
#
#      ats_all(:append_text, true)    # Turns default appended text on
#      ats_all(:append_text, false)   # Turns default appended text off
#      ats_next(:append_text, true)   # Turns appended text on for next message
#      ats_next(:append_text, false)  # Turns appended text off for next message
#
#    Finally, you can also change the alignment of text with the special
#   message codes listed below at lines 100, 101 & 102.
#
#    Lastly, I would draw your attention to the \n and \pn codes, which allows
#   you to make new lines and new pages, respectively. These are useful for
#   when you are using paragraph format and appended text, as it allows you
#   more control. They are described at line 98 and 99.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  List of Special Message Codes Added:
#
# \pf   - Turn on paragraph format for this message.
# /pf   - Turn off paragraph format for this message.
# \n    - Start a new line.
# \lb   - Start a new line.
# \pn   - Start a new page.
# \a[L] - Aligns the text to the left for this line. Can also use \a[0].
# \a[C] - Aligns the text to the centre for this line. Can also use \a[1].
# \a[R] - Aligns the text to the right for this line. Can also use \a[2].
#==============================================================================

$imported ||= {}
if !$imported[:ATS_Formatting]
$imported[:ATS_Formatting] = true

#==============================================================================
# ** Game_ATS
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new public instance variables - ats_paragraph_formatting; ats_alignment;
#      paragraph_format
#==============================================================================

class Game_ATS
  CONFIG ||= {}
  CONFIG[:ats_formatting] = {
    ats_formatting: true,
    ats_alignment: 0,
    #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    #  EDITABLE REGION
    #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    #  Set the below value to either true or false. If true, then paragraph
    # format will be on by default. If false, then paragraph_format will be
    # off by default.
    paragraph_format: true,
    #  Set the below value to either true or false. If true, then any
    # immediately subsequent display text event commands with the same settings
    # will be joined together and they will show in the same message window if
    # there is space. This option is only useful if using paragraph format. If
    # you are using ATS: Message Options, it will only recognize the value of
    # :append_text set up in that script.
    append_text:      true,   
    #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    #  END EDITABLE REGION
    #////////////////////////////////////////////////////////////////////////
  }
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  CONFIG[:ats_formatting].delete(:append_text) if $imported[:ATS_MessageOptions]
  CONFIG[:ats_formatting].keys.each { |key| attr_accessor key }
end

#==============================================================================
#  Initialize Common ATS Data if no other ATS script interpreted first
#==============================================================================

if !$imported[:AdvancedTextSystem]
  #============================================================================
  # *** DataManager
  #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  #  Summary of Changes:
  #    aliased method - create_game_objects; make_save_contents;
  #      extract_save_contents
  #============================================================================
  module DataManager
    class << self
      alias modb_ats_crtgmobj_6yh7 create_game_objects
      alias mlba_ats_mksave_5tg9 make_save_contents
      alias ma_ats_extrcsvcon_8uj2 extract_save_contents
    end
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # * Create Game Objects
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def self.create_game_objects(*args, &block)
      modb_ats_crtgmobj_6yh7(*args, &block)
      $game_ats = Game_ATS.new
      $game_ats.init_new_installs
    end
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # * Make Save Contents
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def self.make_save_contents(*args, &block)
      contents = mlba_ats_mksave_5tg9(*args, &block)
      contents[:ats] = $game_ats
      contents
    end
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # * Extract Save Contents
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def self.extract_save_contents(contents, *args, &block)
      ma_ats_extrcsvcon_8uj2(contents, *args, &block)
      $game_ats = contents[:ats] ? contents[:ats] : Game_ATS.new
      $game_ats.init_new_installs
    end
  end
 
  #============================================================================
  # ** Game_ATS
  #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  #  This class holds the default data for all scripts in the ATS series
  #============================================================================
 
  class Game_ATS
    def initialize; reset; end
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # * Reset any or all installed ATS scripts
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def reset(script_name = nil)
      if script_name.is_a? (Symbol) # If script to reset specified
        CONFIG[script_name].each_pair { |key, value|
          self.send("#{key}=".to_sym, value)
          $game_message.send("#{key}=".to_sym, value)
        }
      else                          # Reset all ATS scripts
        CONFIG.keys.each { |script| reset(script) }
      end
    end
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # * Initialize any newly installed ATS scripts
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def init_new_installs
      CONFIG.keys.each { |script| reset(script) unless self.send(script) }
    end
  end
 
  #============================================================================
  # ** Game_Message
  #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  #  Summary of Changes:
  #    aliased method - clear
  #============================================================================
 
  class Game_Message
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # * Clear
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    alias mlb_ats_clrats_5tv1 clear
    def clear(*args, &block)
      mlb_ats_clrats_5tv1(*args, &block) # Run Original Method
      return if !$game_ats
      Game_ATS::CONFIG.values.each { |installed|
        installed.keys.each { |key| self.send("#{key}=".to_sym, $game_ats.send(key)) }
      }
    end
  end
 
  #============================================================================
  # ** Game_Interpreter
  #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  #  Summary of Changes:
  #    new methods - ats_all; ats_next
  #============================================================================
 
  class Game_Interpreter
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # * ATS All
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def ats_all(sym, *args, &block)
      $game_ats.send("#{sym}=".to_sym, *args, &block)
      ats_next(sym, *args, &block)
    end
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # * ATS Next
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def ats_next(sym, *args, &block)
      $game_message.send("#{sym}=".to_sym, *args, &block)
    end
  end

  $imported[:AdvancedTextSystem] = true
end

# Fix the error with Escape codes
unless $imported[:MA_EscapeCodesFix]
  #============================================================================
  # ** Window_Base
  #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  #  Summary of Changes:
  #    aliased method - obtain_escape_code
  #============================================================================

  class Window_Base
    alias maatspf_obtainesccode_2jk3 obtain_escape_code
    def obtain_escape_code(*args, &block)
      code = maatspf_obtainesccode_2jk3(*args, &block)
      if code.nil?
        p "ERROR in #{self}:\nThere is no escaped code between \ and [ in your text."
        ""
      else
        code
      end
    end
  end
 
  $imported[:MA_EscapeCodesFix] = true
end

unless $imported[:"MA_ParagraphFormat_1.0.1"]
#==============================================================================
# ** MA_Window_ParagraphFormat
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  This module inserts into Window_Base and provides a method to format the
# strings so as to go to the next line if it exceeds a set limit. This is
# designed to work with draw_text_ex, and a string formatted by this method
# should go through that, not draw_text.
#==============================================================================

module MA_Window_ParagraphFormat
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Calc Line Width
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def mapf_calc_line_width(line, tw = 0, contents_dummy = false)
    return tw if line.nil?
    line = line.clone
    unless contents_dummy
      real_contents = contents # Preserve Real Contents
      # Create a dummy contents
      self.contents = Bitmap.new(24, 24)
      reset_font_settings
    end
    pos = {x: 0, y: 0, new_x: 0, height: calc_line_height(line)}
    while line[/^(.*?)\e(.*)/]
      tw += text_size($1).width
      line = $2
      # Remove all ancillaries to the code, like parameters
      code = obtain_escape_code(line)
      # If direct setting of x, reset tw.
      tw = 0 if ($imported[:ATS_SpecialMessageCodes] && code.upcase == 'X') ||
        ($imported["YEA-MessageSystem"] && code.upcase == 'PX')
      #  If I need to do something special on the basis that it is testing,
      # alias process_escape_character and differentiate using @atsf_testing
      process_escape_character(code, line, pos)
    end
    #  Add width of remaining text, as well as the value of pos[:x] under the
    # assumption that any additions to it are because the special code is
    # replaced by something which requires space (like icons)
    tw += text_size(line).width + pos[:x]
    unless contents_dummy
      contents.dispose # Dispose dummy contents
      self.contents = real_contents # Restore real contents
    end
    return tw
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Format Paragraph
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def mapf_format_paragraph(text, max_width = contents_width)
    text = text.clone
    #  Create a Dummy Contents - I wanted to boost compatibility by using the
    # default process method for escape codes. It may have the opposite effect,
    # for some :(
    real_contents = contents # Preserve Real Contents
    self.contents = Bitmap.new(24, 24)
    reset_font_settings
    paragraph = ""
    while !text.empty?
      text.lstrip!
      oline, nline, tw = mapf_format_by_line(text.clone, max_width)
      # Replace old line with the new one
      text.sub!(/#{Regexp.escape(oline)}/m, nline)
      paragraph += text.slice!(/.*?(\n|$)/)
    end
    contents.dispose # Dispose dummy contents
    self.contents = real_contents # Restore real contents
    return paragraph
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Format By Line
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def mapf_format_by_line(text, max_width = contents_width)
    oline, nline, tw = "", "", 0
    loop do
      #  Format each word until reach the width limit
      oline, nline, tw, done = mapf_format_by_word(text, nline, tw, max_width)
      return oline, nline, tw if done
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Format By Word
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def mapf_format_by_word(text, line, tw, max_width)
    return line, line, tw, true if text.nil? || text.empty?
    # Extract next word
    if text.sub!(/([ \t\r]*)(\S*)([\n\f]?)/, "") != nil
      prespace, word, line_end = $1, $2, $3
      ntw = mapf_calc_line_width(word, tw, true)
      pw = contents.text_size(prespace).width
      if (pw + ntw >= max_width)
        # Insert
        if line.empty?
          # If one word takes entire line
          return prespace + word, word + "\n", ntw, true
        else
          return line + prespace + word, line + "\n" + word, tw, true
        end
      else
        line += prespace + word
        tw = pw + ntw
        # If the line is force ended, then end
        return line, line, tw, true if !line_end.strip.empty?
      end
    else
      return line, line, tw, true
    end
    return line, line, tw, false
  end
end

class Window_Base
  include MA_Window_ParagraphFormat
end

  $imported[:"MA_ParagraphFormat_1.0"] = true
  $imported[:"MA_ParagraphFormat_1.0.1"] = true
end

#==============================================================================
# ** Game Message
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new public instance variables - ats_paragraph_formatting; paragraph_format;
#      ats_alignment; append_text
#    aliased method - all_text
#==============================================================================

class Game_Message
  Game_ATS::CONFIG[:ats_formatting].keys.each { |key| attr_accessor key }
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * All Text
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maatsf_alltex_6hu7 all_text
  def all_text(*args, &block)
    result = maatsf_alltex_6hu7(*args, &block) # Call Original Method
    # Look for the Paragraph Format Code
    result.gsub!(/([\/\\])PF/i) { |match| self.paragraph_format = (match[0] == "\\"); "" }
    # Remove natural \n if paragraph format is ON
    result.gsub!(/\s*[\r\n\f]\s*/)  {" "} if paragraph_format
    result
  end
end

#==============================================================================
# ** Game_Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - command_101; next_event_code
#    new method - maatsf_same_message_conditions?
#==============================================================================

if !$imported[:ATS_MessageOptions]
  class Game_Interpreter
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # * Display Text Message
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    alias maatsf_disptext_3jf5 command_101
    def command_101(*args, &block)
      @ats_appending_text = $game_message.append_text
      maatsf_disptext_3jf5(*args, &block) # Call Original Method
      @ats_appending_text = false
    end
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # * Next Event Code
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    alias maatsf_nexcode_5rq9 next_event_code
    def next_event_code(*args, &block)
      result = maatsf_nexcode_5rq9(*args, &block) # Call Original Method
      if @ats_appending_text && result == 101
        if maats_same_message_conditions?(@index + 1)
          @index += 1
          result = next_event_code(*args, &block)
        end
      end
      result
    end
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # * Same Message Conditions?
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def maats_same_message_conditions?(list_index)
      n_params = @list[list_index].parameters
      if ($imported[:MA_CompositeGraphics] || $imported[:ATS_FaceOptions]) &&
        @list[list_index + 1] && @list[list_index + 1].parameters[0][/^\\([AP])F\[(\d+)\]/i]
        param = $2.to_i
        actor = ($1 == 'A') ? $game_actors[param] : $game_party.members[param - 1]
        return (actor.face_name == $game_message.face_name &&
          actor.face_index == $game_message.face_index &&
          n_params[2] == $game_message.background && n_params[3] == $game_message.position)
      end
      n_params[0] == $game_message.face_name && n_params[1] == $game_message.face_index &&
        n_params[2] == $game_message.background && n_params[3] == $game_message.position
    end
  end
end

#==============================================================================
# *** Paragraph Formatting for Message Windows
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  This module is included in Window_Message and Window_ScrollText
#==============================================================================

module ATS_Formatting_WindowMessage
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Convert Escape Characters
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def maatsf_convert_escape_characters(text, *args, &block)
    # Alignment
    text.gsub!(/\eA\[([012])\]/i) { "\eALIGN\[#{$1}\]" }
    text.gsub!(/\eA\[([LRC])\]/i) { "\eALIGN\[#{$1.upcase == 'L' ? 0 : $1.upcase == 'C' ? 1 : 2}\]" }
    text.gsub!(/\ePN/i,  "\f") # New Page
    # New Line
    text.gsub!(/\e(N|LB)/i, "\n") unless $imported[:ATS_SpecialMessageCodes]
    text
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Paragraph New Line
  #``````````````````````````````````````````````````````````````````````````
  # This adds processing for paragraph format and alignment to these methods
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def maatsf_paragraph_new_line(orig_method, text, pos, *args, &block)
    tw = nil
    tw = maatsf_set_next_line(text, pos) if $game_message.paragraph_format && !text.nil? && !text.empty?
    orig_method.call(text, pos, *args, &block) # Call original Method
    # Alignment
    next_line = text[/^[^\n\f]*/]
    align = maatsf_line_alignment(next_line)
    if align != 0 # If not left aligned
      if tw.nil?
        @atsf_testing = true
        tw = mapf_calc_line_width(next_line)
        @atsf_testing = false
      end
      space = maatsf_total_line_width(pos[:y]) - tw
      pos[:x] = [pos[:x] + (space / (align == 1 ? 2 : 1)), pos[:x]].max
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Paragraph Line
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def maatsf_set_next_line(text, pos)
    text.gsub!(/^[ \t\r\f]*/, "")
    max_width = maatsf_total_line_width(pos[:y])
    #  Create a Dummy Contents
    real_contents = contents # Preserve Real Contents
    self.contents = Bitmap.new(24, 24)
    self.contents.font = real_contents.font.dup
    @atsf_testing = true
    # Do everything
    oline, nline, tw = mapf_format_by_line(text.clone, max_width)
    # Replace old line with the new one
    text.sub!(/#{Regexp.escape(oline)}/m, nline)
    contents.dispose # Dispose dummy contents
    self.contents = real_contents # Restore real contents
    @atsf_testing = false
    return tw
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Alignment
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def maatsf_line_alignment(line)
    line[/\eALIGN\[([012])\]/] != nil ? $1.to_i : $game_message.ats_alignment
  end
end

#==============================================================================
# ** Window_Message
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - convert_escape_characters; new_page; process_new_line;
#      wait; wait_for_one_character; input_pause; process_escape_character
#    new methods - maatsf_set_next_line; mapf_format_by_word;
#      mapf_calc_line_width; maatsf_total_line_width;
#      maatsf_line_alignment; maats_convert_escape_characters;
#      maatsf_paragraph_new_line
#==============================================================================

class Window_Message
  include ATS_Formatting_WindowMessage
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Convert Escape Characters
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  if instance_methods(false).include?(:convert_escape_characters)
    # If convert_escape_characters already defined in Window_Message, just alias
    alias maatsf_convrtescchars_8ju5 convert_escape_characters
    def convert_escape_characters(*args, &block)
      maatsf_convert_escape_characters(maatsf_convrtescchars_8ju5(*args, &block))
    end
  else
    # If convert_escape_characters undefined in Window_Message, call super method
    def convert_escape_characters(*args, &block)
      maatsf_convert_escape_characters(super(*args, &block))
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * New Page / Process New Line
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  [:new_page, :process_new_line].each { |meth|
    alias_method(:"maatsf_#{meth}_3wj9", meth)
    define_method(meth) do |*args|
      maatsf_paragraph_new_line(method(:"maatsf_#{meth}_3wj9"), *args)
    end
  }
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Wait / Wait for One Character / Process Input
  #``````````````````````````````````````````````````````````````````````````
  # Do not permit these to run when testing
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  [:wait, :wait_for_one_character, :input_pause].each { |meth|
    alias_method(:"maatsf_#{meth}_2hd4", meth)
    define_method(meth) do |*args|
      send(:"maatsf_#{meth}_2hd4", *args) unless @atsf_testing
    end
  }
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Process Escape Character
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maatsf_proceschar_4fq6 process_escape_character
  def process_escape_character(code, text, *args, &block)
    if code.upcase == 'ALIGN'
      $game_message.ats_alignment = obtain_escape_param(text)
    else
      maatsf_proceschar_4fq6(code, text, *args, &block) # Call Original Method
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Total Line Width
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def maatsf_total_line_width(y = 0)
    contents_width - new_line_x
  end
end

#==============================================================================
# ** Window_ScrollText
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - convert_escape_characters; process_new_line;
#      update_all_text_height
#    new methods - maatsf_set_next_line; mapf_format_by_word;
#      mapf_calc_line_width; maatsf_total_line_width;
#      maatsf_line_alignment; maats_convert_escape_characters;
#      maatsf_paragraph_new_line
#==============================================================================

class Window_ScrollText
  include ATS_Formatting_WindowMessage
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Convert Escape Characters
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maatsf_convescchrs_3wv5 convert_escape_characters
  def convert_escape_characters(*args, &block)
    maatsf_convert_escape_characters(maatsf_convescchrs_3wv5(*args, &block))
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Process New Line
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maatsf_procenewlin_2gv5 process_new_line
  def process_new_line(*args, &block)
    maatsf_paragraph_new_line(method(:maatsf_procenewlin_2gv5), *args, &block)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Has to be done in process Character
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maatsf_updalltextheight_2sd8 update_all_text_height
  def update_all_text_height(*args, &block)
    text = convert_escape_characters(@text)
    if $game_message.paragraph_format
      new_text = ""
      pos = { x: 4, y: 0, new_x: 4, height: fitting_height(1) }
      while !text.nil? && !text.empty?
        maatsf_set_next_line(text, pos)
        if text.sub!(/^([^\n\f]*)([\n\f])/, "")
          new_text += $1 + $2
        else
          new_text += text
          break
        end
      end
      @text = new_text
    end
    maatsf_updalltextheight_2sd8(*args, &block) # Run Original Method
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Process Escape Character
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maatsf_processesc_2hk8 process_escape_character
  def process_escape_character(code, text, *args, &block)
    if code.upcase == 'ALIGN'
      $game_message.ats_alignment = obtain_escape_param(text)
    else
      maatsf_processesc_2hk8(code, text, *args, &block) # Call Original Method
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Total Line Width
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def maatsf_total_line_width(y = 0)
    contents_width
  end
end
else
  p "You have two copies of ATS: Formatting installed. Please remove one."
end

Credit


  • modern algebra

Thanks

  • djDarkX, for a bug report.
  • titan_strife, for a bug report.
  • ThatRandomGuy00, for a bug report.

Support


Please post in this topic at RMRK if you require any assistance with this script at all. If you encounter any bugs or incompatibilities, please let me know about them so that I can fix them.

Known Compatibility Issues

It should be compatible with all other scripts in the ATS series, and it might also be compatible with other message systems as long as this script is placed below them in the Script Editor (though still above Main).

Spoiler for Yanfly's Victory Aftermath:
If using Yanfly's Victory Aftermath with the Formatting, then \n will not work in quotes to break lines. You can fix that in two ways (Note: In some older versions of the Victory Aftermath script, \n would not work at all. The following fixes apply only to versions of Yanfly's Victory Aftermath that are v. 1.04 or greater):

If you want to turn off paragraph formatting altogether, you can simply go to line 171 of the Victory Aftermath script and add /pf anywhere the following line:
Code: [Select]
    HEADER_TEXT = "\e>\eC[6]%s\eC[0]\e<\n"  # Always at start of messages.

Like this:
Code: [Select]
    HEADER_TEXT = "/pf\e>\eC[6]%s\eC[0]\e<\n"  # Always at start of messages.

Alternatively, if you have ATS: Formatting 1.0.3. or later, the \lb code can be used. So, if you want paragraph formatting to apply to the body of the quote but not to the header, you would change the same line and replace \n with \elb, like so:
Code: [Select]
    HEADER_TEXT = "\e>\eC[6]%s\eC[0]\e<\elb"  # Always at start of messages.

You can also use \lb in the notefields to break a line manually.
« Last Edit: February 27, 2015, 01:00:03 AM by modern algebra »

*
Rep: +0/-0Level 57
RMRK Junior
I may have found a compatibility issue between this script and your Composite Graphics script. (that, or something else is interfeering, or I just mucked it up myself).

As soon as I made an event show text where there is a \af[3] reference on top, and a fairly long line of text underneath that (enough to require formating from this script) it gave an error:

Quote
Script 'ATSTextAlignment' line 334: NoMethodError ocurred.
undefined method 'face_name' for nil:NilClass

Funny thing is that this text I want to show has two other show texts before it, and the error occurs between the first and second show texts (which also have an \af reference, but the text bellow is too short to require formating of any kind)

Line 334, btw, is in this code:


Quote
   def maats_same_message_conditions?(list_index)
      n_params = @list[list_index].parameters
      if ($imported[:MA_CompositeGraphics] || $imported[:ATS_FaceOptions]) &&
        @list[list_index + 1] && @list[list_index + 1].parameters[0][/^\\([AP])F\[(\d+)\]/i]
        param = $2.to_i
        actor = ($1 == 'A') ? $game_actors[param] : $game_party.members[param - 1]
        return (actor.face_name == $game_message.face_name &&                                              <===== This is line 334
          actor.face_index == $game_message.face_index &&
          n_params[2] == $game_message.background && n_params[3] == $game_message.position)
      end
      n_params[0] == $game_message.face_name && n_params[1] == $game_message.face_index &&
        n_params[2] == $game_message.background && n_params[3] == $game_message.position
    end
  end
end

P.S - The scripts I have are, in this order, between Materials and Main Process:

Composite Graphics
Custom Item Categories
Receipt Window
ATS Special Message Codes
ATS Text Alignment
Customizable Main Menu
Quest Journal

all from RMRK
« Last Edit: March 18, 2012, 02:00:40 AM by nibor7301 »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Alrighty, I will look into it tomorrow. Thank you for the error report.

*
Rep: +0/-0Level 70
RMRK Junior
First of all, I want to say I've always loved your scripts! Now then, just wanted to quickly report another (possible) issue. I don't get an error per se, but all naturally displayed text without alignment code is automatically aligned to the right for some reason, including some that are harder to control (like the after battle text). Nothing else, like menus and so on, seems to be affected. Just text displayed in the message window. Of course, it may just be something stupid I did, but removing your script fixes the issue. Also,  I haven't modified it at all.

I'm using yanfly's Ace Message System, but you specifically note it in your code so I doubt it's a compatibility issue. I browsed through the code but unfortunately couldn't find the problem or a way to permanently align everything to the left. Thus I'm stumped, which is a shame, because this script of yours makes dialogue a whole lot less of an annoyance! Anyway, sorry for troubling you.

EDIT:

It actually seems to be a combatability issue with one of my other scripts, as putting yours at the very bottom seems to have fixed my problem. I'm not sure which, but I'll see if I can go through a process of elimination and find out. Besides yanfly's, I really don't use many other scripts, I'm an old fashioned eventing knid of guy.
« Last Edit: March 20, 2012, 02:11:50 AM by Cerulean Shaman »

*
Rep:
Level 85
I am the wood of my broom
2010 Project of the YearProject of the Month winner for January 2010Project of the Month winner for January 2009Project of the Month winner for April 2010
<just a sec>
« Last Edit: April 08, 2012, 07:15:47 AM by Nessiah »


**
Rep:
Level 56
RMRK Junior
Have I ever mentioned how I love you forever, Seamus?
It's more like a big ball of wibbly wobbly...timey wimey...stuff.

**
Rep: +0/-0Level 56
RMRK Junior
is there a way to force a new message window using this script, to stop it putting text from two separate text events in the same 'box'?

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Yes:

    #  Set the below value to either true or false. If true, then any
    # immediately subsequent display text event commands with the same settings
    # will be joined together and they will show in the same message window if
    # there is space. This option is only useful if using paragraph format. If
    # you are using ATS: Message Options, then this script should be below it
    # and it will only recognize the value of :append_text set up in that
    # script.
    append_text:      true,   

#    Similar to paragraph format, you can use the following commands in a
#   script call
#
#      ats_all(:append_text, true)    # Turns default appended text on
#      ats_all(:append_text, false)   # Turns default appended text off
#      ats_next(:append_text, true)   # Turns appended text on for next message
#      ats_next(:append_text, false)  # Turns appended text off for next message

In other words, if you want to turn that feature off for all messages then set that line in the configuration to false:

Code: [Select]
    append_text:      false,

If you only want to turn it off for the next message but want it on generally, leave the above line as true and instead insert the following in a Script command above the message:

Code: [Select]
ats_next(:append_text, false)

Alternately, you can insert a blank comment between the two message commands.

**
Rep: +0/-0Level 56
RMRK Junior
Alternately, you can insert a blank comment between the two message commands.

simple, thanks

*
*crack*
Rep:
Level 64
2012 Best Newbie2012 Most Unsung MemberFor frequently finding and reporting spam and spam bots
Modern Algebra I seem to be getting a script error in regards to your 'Process Escape Character' section.

Here is the error


And this is what that person is saying
All of my scripts are totally free to use for commercial use. You don't need to ask me for permission. I'm too lazy to update every single script post I ever made with this addendum. So ignore whatever "rule" I posted there. :)

All scripts can be found at: https://pastebin.com/u/diamondandplatinum3

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Hmm, can I see a demo with the error recreated?

What's happening is that it is calling the process_escape_character and passing nil as the code, but that would cause an error with or without my script. I need to see a demo of the error in order to see where in the script the method call is happening and work from there.

*
*crack*
Rep:
Level 64
2012 Best Newbie2012 Most Unsung MemberFor frequently finding and reporting spam and spam bots
I was gonna post a demo with the error in the first post, but I thought it was something simple, so I chose not to.

Anyway, here.
All of my scripts are totally free to use for commercial use. You don't need to ask me for permission. I'm too lazy to update every single script post I ever made with this addendum. So ignore whatever "rule" I posted there. :)

All scripts can be found at: https://pastebin.com/u/diamondandplatinum3

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Ah, well it's because you forgot the c between \[0]. It shouldn't be:

Why hello \c[12]Azula\[0], what brings you to my lovely home?

It should be:

Why hello \c[12]Azula\c[0], what brings you to my lovely home?


That error happens whether or not you have my ATS: Formatting script - it's an error inherited from the default scripts. That said, it's a nasty error for such a small oversight. I will have to fix it.
« Last Edit: April 23, 2012, 06:25:17 PM by Seamus »

*
*crack*
Rep:
Level 64
2012 Best Newbie2012 Most Unsung MemberFor frequently finding and reporting spam and spam bots
In the time frame between you looking at the project and me proof reading my text, I realised that very same thing ;_;


My mistake 8)


Also thanks for this script MA, it's doing wonders in speeding up the text process ;D
All of my scripts are totally free to use for commercial use. You don't need to ask me for permission. I'm too lazy to update every single script post I ever made with this addendum. So ignore whatever "rule" I posted there. :)

All scripts can be found at: https://pastebin.com/u/diamondandplatinum3

**
Rep:
Level 57
RMRK Junior
Hello,

Your script seems to not work with Ace Message System

Because this is what happen and I've put your script below it :


*
Rep:
Level 85
I am the wood of my broom
2010 Project of the YearProject of the Month winner for January 2010Project of the Month winner for January 2009Project of the Month winner for April 2010
Did you try doing \n (new line) or \pn (new page)
Example:
My test \n My test \pn My test

The following above will result to

Messagebox:
My test
My test

New Message Box
My test


**
Rep:
Level 57
RMRK Junior
I just tried it and it didn't work.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Well, what is your input, and what are you trying to make it look like?

**
Rep:
Level 57
RMRK Junior
Just the normal thing :


Here how I set it up :
First example > http://uppix.net/e/1/8/10cda5815710ae16fd000dba02309.gif
Result > http://uppix.net/f/5/3/aac157670051d9d7cc90fe2ed5909.gif

Second example (on another map) > http://uppix.net/7/4/a/35d95d8a7c36fdaca93d7c483283f.gif
Result > http://uppix.net/c/8/8/e793af5e6d10d4df528b3f549b7c9.gif

I don't know why the display is different from map n°1 and 2... I only changed the font size in Yanfly script and didn't touch anything else even in your script.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
So, is the problem that your window is only one line high? Are you sure that when you say you changed the font size, you didn't accidentally just change the window size?

Anyway, the first example picture has different input from your first result picture so I can't really tell anything from that. One thing I can say is that YEA uses \n<> for a code, so that might be interfering with the line break code. The other thing I can say is that the formatting script won't divide a line into syllables, so you should put spaces in your test string. In other words, if you have a long string like:

Code: [Select]
TestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTest

then the script will draw it all on one line and most of it will thus be invisible; it won't automatically break the string. So, put spaces in your test strings.

Anyway, I think the easiest thing would be for you to recreate the error in a test project and share it with me. That way I will be able to assist you more quickly and accurately.
« Last Edit: May 27, 2012, 06:07:46 PM by modern algebra »

**
Rep:
Level 57
RMRK Junior
I've found why I got the result in the first screenshot, it's because I used game variable 21 and 22 and Yanfly use them too in his script.

So the only problem remain is the result I got in the second screenshot because I can't get automaticly the same result like you showed in your example in your first post. I can't get this feature with Yanfly script+your script.
Quote
Paragraph Formatting permits you to ignore the markers when displaying text - nothing will get cut off.

Demo is in the attachement.





*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
I tested the demo and am still unsure what your objective is. As I mentioned earlier, you should use spaces, but in this case everything that you put in the text box was able to fit on one line, so it was all drawn on one line. Nothing was cut off, so there was no reason to bring the text to a second line. I also tested using \n to break the lines, and that worked too. I'm not sure what problem you are detecting with the script since it is operating the way it is supposed to operate.
« Last Edit: May 27, 2012, 11:23:57 PM by modern algebra »

**
Rep:
Level 57
RMRK Junior
I understood wrong your instructions because my english is bad.
I though your script automaticly break line.
Sorry, for the bother.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
It does automatically break lines, but only when it's necessary. If everything you write in a text box can fit on one line, it will be shown on one line. It does automatically break lines when it's necessary though.

Your tests are such that the entire text you input can fit on one line - that is the reason the text is not being broken up. If you wrote something such that it couldn't all fit on just one line, then this script would put it on more than one line.

**
Rep:
Level 57
RMRK Junior
Just tried and copy pasted what you said in my dialog and indeed it work.
I though it will automaticly break line if my words gone beyond the margin.

Thank you very much for your help.  :)

p.s : will upload a demo for the quest journal script ?