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 Message - Why doesn't message go away during battle?

Okay I figured out what I was doing wrong, but now I need to know why the Message won't go away during Scene_Battle. Here, I guess I forgot to post the script.

When you go into battle and a message shows, the window won't go away after you've cleared the message, and everything just freezes.

Code:
#===============================================================================
# ** Window_Message+
#-------------------------------------------------------------------------------
#   This window's methods have been broken down into many sub-methods for easier
# aliasing code to.
#===============================================================================
#-------------------------------------------------------------------------------
# * SDK Log
#-------------------------------------------------------------------------------
SDK.log('Window_Message+', 'Kain Nobel', 0.1, '2008-20-08')
#-------------------------------------------------------------------------------
# * SDK Enabled Test - BEGIN
#-------------------------------------------------------------------------------
if SDK.enabled?('Window_Message+')
#===============================================================================
# ** Window_Base - Quick Position
#-------------------------------------------------------------------------------
#   This is my submitted MACL method for quickly setting window positions, I
# use it in this script to set the position of the Gold window.
#===============================================================================
class Window_Base < Window
  #-----------------------------------------------------------------------------
  # * Set Quick Position
  #-----------------------------------------------------------------------------
  def position(edge = 0, offset = 0)
    if edge.is_a?(Integer)
      if edge == 5 || edge == -5 || edge > 9 || edge < -9
        edge = 0
      end
    else ; return
    end
    o = offset.is_a?(Integer) ? offset : 0
    case edge
    when 0 # Center
      self.x, self.y = (320 - (self.width / 2)) , (240 - (self.height / 2))
    when 2 # Center Bottom
      self.x, self.y = (320 - (self.width / 2)) , (480 - (self.height))
      unless o.zero? ; self.y -= o ; end
    when 4 # Center Left
      self.x, self.y = 0                        , (240 - (self.height / 2))
      unless o.zero? ; self.x += o ; end
    when 6 # Center Right
      self.x, self.y = (640 - self.width)       , (240 - (self.height / 2))
      unless o.zero? ; self.x -= o ; end
    when 8 # Center Top
      self.x, self.y = (320 - (self.width / 2)) , 0
      unless o.zero? ; self.y += o ; end
    when 1 # Lower Left
      self.x, self.y = (0)                      , (480 - self.height)
      unless o.zero? ; self.x += o ; self.y -= o ; end
    when 3 # Lower Right
      self.x, self.y = (640 - self.width)       , (480 - self.height)
      unless o.zero? ; self.x -= o ; self.y -= o ; end
    when 7 # Upper Left
      self.x, self.y = 0                        , 0
      unless o.zero? ; self.x += o ; self.y += o ; end
    when 9 # Upper Right
      self.x, self.y = 640 - self.width         , 0
      unless o.zero? ; self.x -= o ; self.y += o ; end
    when -2 # Center Bottom Outside
      self.x, self.y = (320 - (self.width / 2)) , 480
    when -4 # Center Left Outside
      self.x, self.y = (0 - self.width)         , (240 - (self.height / 2))
    when -6 # Center Right Outside
      self.x, self.y = (640 + self.width)       , (240 - (self.height / 2))
    when -8 # Center Top Outside
      self.x, self.y = (320 - (self.width / 2)) , (0 - self.height)
    when -1 # Lower Left Outside
      self.x, self.y = (0 - self.width)         , (480 + self.height)
    when -3 # Lower Right Outside
      self.x, self.y = (640 + self.width)       , (480 + self.height)
    when -7 # Upper Right Outside
      self.x, self.y = (0 - self.width)         , (0 - self.height)
    when -9 # Upper Left Outside
      self.x, self.y = (640 - self.width)       , (0 - self.height)
    end
  end
end

#===============================================================================
# ** Window_Message
#-------------------------------------------------------------------------------
#   This class and all of it's functions have been broken down and re-written
# entirely to make scripting in general easier. You can use this with or without
# the Xtreme Message system, and Window_Message will still function normally.
#   However, don't remove this script because it is the base of the Xtreme Msg
# System's laws of coding, and will break the script without it.
#===============================================================================
class Window_Message < Window_Selectable
  #-----------------------------------------------------------------------------
  # * Customizable Constants
  #-----------------------------------------------------------------------------
  Default_Width  = 480
  Default_Height = 160
  #-----------------------------------------------------------------------------
  # * Object Initialization
  #-----------------------------------------------------------------------------
  def initialize
    super(80, 304, Default_Width, Default_Height)
    self.contents     = Bitmap.new(width - 32, height - 32)
    self.visible      = false
    self.z            = 9998
    self.active       = false
    self.index        = -1
    initialize_variables
    update_settings_text
  end
  #-----------------------------------------------------------------------------
  # * Initialize Variables
  #-----------------------------------------------------------------------------
  def initialize_variables
    @fade_in          = false
    @fade_out         = false
    @contents_showing = false
    @cursor_width     = 0
  end
  #-----------------------------------------------------------------------------
  # * Update Settings Text
  #-----------------------------------------------------------------------------
  def update_settings_text
    self.contents.font.name     = Font.default_name
    self.contents.font.size     = Font.default_size
    self.contents.font.bold     = Font.default_bold
    self.contents.font.italic   = Font.default_italic
    self.contents.font.color    = Font.default_color
  end
  #-----------------------------------------------------------------------------
  # * Dispose
  #-----------------------------------------------------------------------------
  def dispose
    terminate_message
    $game_temp.message_window_showing = false
    dispose_input_number
    super
  end
  #-----------------------------------------------------------------------------
  # * Dispose Input Number Window
  #-----------------------------------------------------------------------------
  def dispose_input_number
    unless @input_number_window.nil?
      @input_number_window.dispose
    end
  end
  #-----------------------------------------------------------------------------
  # * Dispose Gold Window
  #-----------------------------------------------------------------------------
  def dispose_gold
    unless @gold_window.nil?
      @gold_window.dispose
      @gold_window = nil
    end
  end
  #-----------------------------------------------------------------------------
  # * Clear Game Temp
  #-----------------------------------------------------------------------------
  def clear_game_temp
    $game_temp.message_text = nil
    $game_temp.message_proc = nil
    $game_temp.choice_start = 99
    $game_temp.choice_max = 0
    $game_temp.choice_cancel_type = 0
    $game_temp.choice_proc = nil
    $game_temp.num_input_start = 99
    $game_temp.num_input_variable_id = 0
    $game_temp.num_input_digits_max = 0
  end
  #-----------------------------------------------------------------------------
  # * Refresh
  #-----------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @x = $game_temp.choice_start.zero? ? 8 : 0
    @y = 0
    @cursor_width = 0
    unless $game_temp.message_text.nil?
      @text = $game_temp.message_text
      begin
        last_text = @text.clone
      end until @text == last_text
      convert_message_codes
      while ((c = @text.slice!(/./m)) != nil)
        interpret_message_codes(c)
        write_message(c)
      end
    end
    refresh_choices
    refresh_input_number
  end
  #-----------------------------------------------------------------------------
  # * Refresh Choices
  #-----------------------------------------------------------------------------
  def refresh_choices
    unless $game_temp.choice_max.zero? || $game_temp.choice_max < 0
      @item_max = $game_temp.choice_max
      self.active = true
      self.index  = 0
    end
  end
  #-----------------------------------------------------------------------------
  # * Refresh Input Number
  #-----------------------------------------------------------------------------
  def refresh_input_number
    if $game_temp.num_input_variable_id > 0
      digits_max = $game_temp.num_input_digits_max
      number = $game_variables[$game_temp.num_input_variable_id]
      @input_number_window = Window_InputNumber.new(digits_max)
      @input_number_window.number = number
      @input_number_window.x = self.x + 8
      @input_number_window.y = self.y + $game_temp.num_input_start * 32
    end
  end
  #-----------------------------------------------------------------------------
  # * Terminate Message
  #-----------------------------------------------------------------------------
  def terminate_message
    self.active = false
    self.pause = false
    self.index = -1
    self.contents.clear
    @contents_showing = false
    unless $game_temp.message_proc.nil?
      $game_temp.message_proc.call
    end
    clear_game_temp
    dispose_gold
  end
  #-----------------------------------------------------------------------------
  # * Convert Message Codes
  #-----------------------------------------------------------------------------
  def convert_message_codes
    # Convert Variable
    @text.gsub!(/\\[Vv]\[([0-9]+)\]/)      { $game_variables[$1.to_i] }
    # Convert Game Actor Name
    @text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
      !$game_actors[$1.to_i].nil? ? $game_actors[$1.to_i].name : ""
    end
    # Change \\\\ to \000
    @text.gsub!(/\\\\/)                    { "\000" }
    # Change \C[#] to Color
    @text.gsub!(/\\[Cc]\[([0-9]+)\]/)      { "\001[#{$1}]" }
    # Show Gold Window
    @text.gsub!(/\\[Gg]/)                  { "\002" }
  end
  #-----------------------------------------------------------------------------
  # * Interpret Message Codes
  #-----------------------------------------------------------------------------
  def interpret_message_codes(c)
    # If \\
    case c
    when "\000" ; c = "\\"
    when "\001" ; change_text_color ; return
    when "\002" ; create_gold_window ; return
    when "\n"
      if @y >= $game_temp.choice_start
        @cursor_width = [@cursor_width, @x].max
      end
      @y += 1
      @x = 0
      if @y >= $game_temp.choice_start
        @x = 8
      end
      return
    end
  end
  #-----------------------------------------------------------------------------
  # * Write Message
  #-----------------------------------------------------------------------------
  def write_message(c)
    self.contents.draw_text(4 + @x, 32 * @y, 40, 32, c)
    @x += self.contents.text_size(c.to_s).width
  end
  #-----------------------------------------------------------------------------
  # * Change Text Color
  #-----------------------------------------------------------------------------
  def change_text_color
    @text.sub!(/\[([0-9]+)\]/, "")
    color = $1.to_i
    if color >= 0 and color <= 7
      self.contents.font.color = text_color(color)
    end
  end
  #-----------------------------------------------------------------------------
  # * Create Gold Window
  #-----------------------------------------------------------------------------
  def create_gold_window
    if @gold_window.nil?
      @gold_window   = Window_Gold.new
      @gold_window.z = 9998
      @gold_window.opacity = self.opacity
      @gold_window.back_opacity = self.back_opacity
      if $game_temp.in_battle ; @gold_window.position(3, 16)
      else                    ; @gold_window.position(9, 16)
      end
    end
  end
  #-----------------------------------------------------------------------------
  # * Frame Update
  #-----------------------------------------------------------------------------
  def update
    super
    # Step 1 : Create Message
    if @fade_in
      create_message
      return
    end
    # Step 2 : Proccess Input Number (if applicable)
    unless @input_number_window.nil?
      update_input_number
      return
    end
    # Step 3 : Process Show Choices (if applicable)
    if @contents_showing
      update_show_choices
      return
    end
    # Step 4 : Update Message Idle
    if !@fade_out && !$game_temp.message_text.nil?
    #if @fade_out == false and $game_temp.message_text != nil
      update_message_idle
      return
    end
    # Step 5 : Clear Message
    if self.visible
      clear_message
      return
    end
  end
  #-----------------------------------------------------------------------------
  # * Update Fade In
  #-----------------------------------------------------------------------------
  def create_message
    self.contents_opacity += 24
    unless @input_number_window.nil?
      @input_number_window.contents_opacity += 24
    end
    if self.contents_opacity == 255
      @fade_in = false
    end
  end
  #-----------------------------------------------------------------------------
  # * Update Input Number
  #-----------------------------------------------------------------------------
  def update_input_number
    @input_number_window.update
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      $game_variables[$game_temp.num_input_variable_id] =
        @input_number_window.number
      $game_map.need_refresh = true
      @input_number_window.dispose
      @input_number_window = nil
      terminate_message
    end
  end
  #-----------------------------------------------------------------------------
  # * Update Show Choices
  #-----------------------------------------------------------------------------
  def update_show_choices
    # If choice isn't being displayed, show pause sign
    if $game_temp.choice_max.zero? ; self.pause = true
    end
    # Cancel
    if Input.trigger?(Input::B)
      if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
        $game_system.se_play($data_system.cancel_se)
        $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
        terminate_message
      end
    end
    # Confirm
    if Input.trigger?(Input::C)
      if $game_temp.choice_max > 0
        $game_system.se_play($data_system.decision_se)
        $game_temp.choice_proc.call(self.index)
      end
      terminate_message
    end
  end
  #-----------------------------------------------------------------------------
  # * Update Message Waiting
  #-----------------------------------------------------------------------------
  def update_message_idle
    @contents_showing = true
    $game_temp.message_window_showing = true
    reset_window
    refresh
    Graphics.frame_reset
    self.visible = true
    self.contents_opacity = 0
    if @input_number_window != nil
      @input_number_window.contents_opacity = 0
    end
    @fade_in = true
  end
  #-----------------------------------------------------------------------------
  # * Close Message
  #-----------------------------------------------------------------------------
  def clear_message
    @fade_out = true
    self.opacity -= 48
    if self.opacity == 0
      self.visible = false
      @fade_out = false
      $game_temp.message_window_showing = false
    end
    update_settings_text
  end  
  #-----------------------------------------------------------------------------
  # * Reset Window
  #-----------------------------------------------------------------------------
  def reset_window
    if $game_temp.in_battle ; self.y = 16
    else
      case $game_system.message_position
      when 0 ; self.y = 16
      when 1 ; self.y = 160
      when 2 ; self.y = 304
      end
    end
    if $game_system.message_frame.zero? ; self.opacity = 255
    else                                ; self.opacity = 0
    end
    self.back_opacity = 160
  end
  #-----------------------------------------------------------------------------
  # * Update Cursor Rect
  #-----------------------------------------------------------------------------
  def update_cursor_rect
    if @index >= 0
      n = $game_temp.choice_start + @index
      self.cursor_rect.set(8, n * 32, @cursor_width, 32)
    else
      self.cursor_rect.empty
    end
  end
end
#-------------------------------------------------------------------------------
# * SDK Enabled Test - END
#-------------------------------------------------------------------------------
end
Code:
#===============================================================================
# ~** Xtreme Message System **~
#-------------------------------------------------------------------------------
# Written by  : Kain Nobel
# Version     : 0.1
# Last Update : 08/27/2008
# Created On  : 08/20/2008
#-------------------------------------------------------------------------------
# * Description :
#
#   This script is supposed to clean up and combine features of many popular
#   message systems, such as Dubealex's AMS and Ccoa's UMS. Unlike other 
#   systems of the same nature, everything is actually set through a simple
#   module known as the "Message" module, can you dig it?
#-------------------------------------------------------------------------------
# * Instructions : Call Script Codes
#
#   Message.window_mode(number/constant)  # Toggle Window Modes
#   Message.set_bold(true/false)          # Toggle Text Bold
#   Message.set_italics(true/false)       # Toggle Text Italics
#   Message.set_font(name, size)          # Change Text Font Name & Font Size
#   Message.set_color(Color.new())        # Change Text Font Color
#   Message.set_faces(true/false)         # Toggle Facesets on or off
#   Message.justify_window(number/string) # Justify Window Left, Center or Right
#   Message.justify_text(number/string)   # Justify Text Left, Center or Right
#-------------------------------------------------------------------------------
# * Instructions : Message Codes
#
#   -NOTE-
#     These codes aren't case sensitive, you can do upcase or lowcase.
#   \V[#]   - Show Variable Value       - ($game_variable[#])
#   \N[?]   - Show Actor Name           - (Actor ID from database)
#   \PN[#]  - Show Party Actor Name     - (Actor's index in Game Party)
#   \B      - Auto Bold ON/OFF
#   \+B     - Set Bold ON
#   \-B     - Set Bold OFF
#   \I      - Auto Italic ON/OFF
#   \+I     - Set Italic ON
#   \-I     - Set Italic OFF
#   \TJL    - Text Justify Left
#   \TJC    - Text Justify Center
#   \TJR    - Text Justify Right
#   \WJL    - Window Justify Left
#   \WJC    - Window Justify Center
#   \WJR    - Window Justify Right
#   \FN[?]  - Set Font Name             - (Must be something Arial, not "Arial")
#   \-FN    - Default Font Name
#   \FS[#]  - Set Font Size             - (Must be Integer)
#   \-FS    - Default Font Size
#   \WP0    - Window Position Top
#   \WP1    - Window Position Middle
#   \WP2    - Window Position Bottom
#   \HIDE   - Hide Message Window
#   \SHOW   - Show Message Window
#-------------------------------------------------------------------------------
# * Compatibility :
#
#   This script requires my Window_Message+ (submitted for SDK approval), and
#   aliases to its many methods, so without it the script shouldn't work.
#===============================================================================
#-------------------------------------------------------------------------------
# * SDK Log
#-------------------------------------------------------------------------------
SDK.log('Xtreme Message System', 'Kain Nobel', 0.1, '2008-27-08')
SDK.check_requirements(2.2, [1,2], 'Window_Message+')
#-------------------------------------------------------------------------------
# * SDK Enabled Test - BEGIN
#-------------------------------------------------------------------------------
if SDK.enabled?('Xtreme Message System')
#===============================================================================
# ** Message
#-------------------------------------------------------------------------------
#   This module is the data & control structure of Kain Nobel's Message System.
#===============================================================================
module Message
  #-----------------------------------------------------------------------------
  # * Constants
  #-----------------------------------------------------------------------------
  Default_H = 160
  Default_W = 480
  #-----------------------------------------------------------------------------
  # * Message.set_font(name, -size)
  #-----------------------------------------------------------------------------
  def self.set_font(name = Font.default_name, size = Font.default_size)
    return if !name.is_a?(String) || !size.is_a?(Numeric)
    @font_name, @font_size = name, size
  end
  #-----------------------------------------------------------------------------
  # * Message.set_bold(-boolean)
  #-----------------------------------------------------------------------------
  def self.set_bold(boolean = nil)
    if boolean.nil? ; @bold = !@bold
    else            ; @bold = boolean
    end
  end
  #-----------------------------------------------------------------------------
  # * Message.set_italic(-boolean)
  #-----------------------------------------------------------------------------
  def self.set_italic(boolean = nil)
    if boolean.nil? ; @italic = !@italic
    else            ; @italic = boolean
    end
  end
  #-----------------------------------------------------------------------------
  # * Message.set_color(r, g, b, a)
  #-----------------------------------------------------------------------------
  def self.set_color(r = nil, g = nil, b = nil, a = 255)
    new_color = r.nil? ? nil : Color.new(r, g, b, a)
    if new_color.nil? ; @font_color = Font.default_color
    else              ; @font_color = new_color
    end
  end
  #-----------------------------------------------------------------------------
  # * Message.set_align(align)
  #-----------------------------------------------------------------------------
  def self.set_align(align)
    if align.is_a?(String)
      case align.upcase!
      when 'LEFT'   ; align = 0
      when 'CENTER' ; align = 1
      when 'RIGHT'  ; align = 2
      end
    end
    if align.is_a?(Numeric) && align.between?(0, 2)
      @align = align
    end
  end
  #-----------------------------------------------------------------------------
  # * Message.reset
  #-----------------------------------------------------------------------------
  def self.reset
    @bold       = Font.default_bold
    @italic     = Font.default_italic
    @font_name  = Font.default_name
    @font_size  = Font.default_size
    @font_color = Font.default_color
  end
  #-----------------------------------------------------------------------------
  # * Message.set_mode(boolean)
  #-----------------------------------------------------------------------------
  def self.set_mode_text(boolean = false)
    @mode_text = boolean == false ? 'Normal'  : 'Custom'
  end
  #-----------------------------------------------------------------------------
  # * Message.set_width(-width)
  #-----------------------------------------------------------------------------
  def self.set_width(width = nil)
    @width = width.is_a?(Numeric) ? width     : Default_W
  end
  #-----------------------------------------------------------------------------
  # * Message.set_height(height)
  #-----------------------------------------------------------------------------
  def self.set_height(height = nil)
    @height = height.is_a?(Numeric) ? height  : Default_H
  end
  #-----------------------------------------------------------------------------
  # * Message.mode_text
  #-----------------------------------------------------------------------------
  def self.mode_text
    @mode_text = @mode_text.nil?            ? 'Normal'            : @mode_text
  end
  #-----------------------------------------------------------------------------
  # * Message.bold
  #-----------------------------------------------------------------------------
  def self.bold
    @bold = @bold.nil?                      ? Font.default_bold   : @bold
    return @bold
  end
  #-----------------------------------------------------------------------------
  # * Message.italic
  #-----------------------------------------------------------------------------
  def self.italic
    @italic = @italic.nil?                  ? Font.default_italic : @italic
    return @italic
  end
  #-----------------------------------------------------------------------------
  # * Message.font_name
  #-----------------------------------------------------------------------------
  def self.font_name
    @font_name = @font_name.nil?            ? Font.default_name   : @font_name
    return @font_name
  end
  #-----------------------------------------------------------------------------
  # * Message.font_size
  #-----------------------------------------------------------------------------
  def self.font_size
    @font_size = @font_size.nil?            ? Font.default_size   : @font_size
    return @font_size
  end
  #-----------------------------------------------------------------------------
  # * Message.width
  #-----------------------------------------------------------------------------
  def self.width
    @width = @width.is_a?(Numeric)          ? @width              : Default_W
    return @width
  end
  #-----------------------------------------------------------------------------
  # * Message.height
  #-----------------------------------------------------------------------------
  def self.height
    @height = @height.is_a?(Numeric)        ? @height             : Default_H
  end
  #-----------------------------------------------------------------------------
  # * Message.align
  #-----------------------------------------------------------------------------
  def self.align
    @align = !@align.is_a?(Fixnum)          ? 0                   : @align
    return @align
  end
  #-----------------------------------------------------------------------------
  # * Message.font_color
  #-----------------------------------------------------------------------------
  def self.font_color
    @font_color = !@font_color.is_a?(Color) ? Font.default_color  : @font_color
    return @font_color
  end
end
#===============================================================================
# ** Window_Message
#-------------------------------------------------------------------------------
#   This is defined based on the Window_Message+ listed above this one (which
# was broken down to script with easier, yet maintain normal function.) This
# aliases all the broken down methods and allows you easier access to setting
# your own defined codes without going crosseyed @_@ !
#===============================================================================
class Window_Message < Window_Selectable
  #-----------------------------------------------------------------------------
  # * Customizable Constants
  #-----------------------------------------------------------------------------
  Default_Width  = Message::Default_W
  Default_Height = Message::Default_H
  #-----------------------------------------------------------------------------
  # * Alias Methods
  #-----------------------------------------------------------------------------
  alias_method :xms_win_msg_refresh,               :refresh
  alias_method :xms_win_msg_update_settings_text,  :update_settings_text
  alias_method :xms_win_msg_convert_msg_codes,     :convert_message_codes
  alias_method :xms_win_msg_interpret_msg_codes,   :interpret_message_codes
  alias_method :xms_win_msg_write_message,         :write_message
  #-----------------------------------------------------------------------------
  # * Object Update (*Aliased*)
  #-----------------------------------------------------------------------------
  def refresh
    update_settings_text
    xms_win_msg_refresh
    update_settings_text
  end
  #-----------------------------------------------------------------------------
  # * Update Settings Font (*Aliased*)
  #-----------------------------------------------------------------------------
  def update_settings_text
    self.width  = Message.width   if self.width   != Message.width
    self.height = Message.height  if self.height  != Message.height
    case Message.mode_text.upcase!
    when 'NORMAL' ; xms_win_msg_update_settings_text
    when 'CUSTOM'
      self.contents.font.bold   = Message.bold
      self.contents.font.italic = Message.italic
      self.contents.font.name   = Message.font_name
      self.contents.font.size   = Message.font_size
      self.contents.font.color  = Message.font_color
      if defined?(CMS) && CMS.is_a?(Module)
        self.windowskin           = CMS.apply_windowskin
      end
    end
  end
  #-----------------------------------------------------------------------------
  # * Convert Message Codes (*Aliased*)
  #-----------------------------------------------------------------------------
  def convert_message_codes
    # Convert Party Actor Name
    @text.gsub!(/\\[Pp][Nn]\[([0-9]+)\]/) do
      !$game_party.actors[$1.to_i].nil? ? $game_party.actors[$1.to_i].name : "N/A"
    end
    # Set Bold
    @text.gsub!(/\\[Bb]/)                       { "\003" }
    @text.gsub!(/\\[+][Bb]/)                    { "\004" }
    @text.gsub!(/\\[-][Bb]/)                    { "\005" }
    # Set Italic
    @text.gsub!(/\\[Ii]/)                       { "\006" }
    @text.gsub!(/\\[+][Ii]/)                    { "\007" }
    @text.gsub!(/\\[-][Ii]/)                    { "\010" }
    # Text Justification
    @text.gsub!(/\\[Tt][Jj][Ll]/)               { "\011" }
    @text.gsub!(/\\[Tt][Jj][Cc]/)               { "\012" }
    @text.gsub!(/\\[Tt][Jj][Rr]/)               { "\013" }
    # Window Justification
    @text.gsub!(/\\[Ww][Jj][Ll]/)               { "\014" }
    @text.gsub!(/\\[Ww][Jj][Cc]/)               { "\015" }
    @text.gsub!(/\\[Ww][Jj][Rr]/)               { "\016" }
    # Set Window Width
    @text.gsub!(/\\[Ww]\[([0-9]+)\]/)           { "\017[#{$1}]" }
    # Set Window Height
    @text.gsub!(/\\[Hh]\[([0-9]+)\]/)           { "\020[#{$1}]" }
    # Default Window Width
    @text.gsub!(/\\[-][Ww]/)                    { "\021" }
    # Default Window Height
    @text.gsub!(/\\[-][Hh]/)                    { "\022" }
    # Set Font Name (\fn[""], \-fn
    @text.gsub!(/\\[Ff][Nn]\[(.*?)\]/)          { "\023[#{$1}]" }
    @text.gsub!(/\\[-][Ff][Nn]/)                { "\024" }
    # Set Font Size (\fs[#], \-fs)
    @text.gsub!(/\\[Ff][Ss]\[([0-9]+)\]/)       { "\025[#{$1}]" }
    @text.gsub!(/\\[-][Ff][Ss]/)                { "\026" }
    # Set Message Position (\wp0, \wp1, \wp2)
    @text.gsub!(/\\[Ww][Pp][0]/)                { "\027" }
    @text.gsub!(/\\[Ww][Pp][1]/)                { "\030" }
    @text.gsub!(/\\[Ww][Pp][2]/)                { "\031" }
    # Set Message Transparent (\show)
    @text.gsub!(/\\[Hh][Ii][Dd][Ee]/)           { "\032" }
    # Unset Message Transparent (\hide)
    @text.gsub!(/\\[Ss][Hh][Oo][Ww]/)           { "\033" }
    # Set Name Box
    @text.gsub!(/\\[Nn][Mm]\[(.*?)\]/)          { "\034[#{$1}]" }
    xms_win_msg_convert_msg_codes
  end
  #-----------------------------------------------------------------------------
  # * Interpret Message Codes (*Aliased*)
  #-----------------------------------------------------------------------------
  def interpret_message_codes(c)
    xms_win_msg_interpret_msg_codes(c)
    case c
    # (\B)  : Bold Toggle
    when "\003"
      self.contents.font.bold = !self.contents.font.bold
      return
    # (\+B) : Bold ON
    when "\004"
      self.contents.font.bold = true
      return
    # (\-B)   : Bold OFF
    when "\005"
      self.contents.font.bold = false
      return
    # (\I)    : Toggle Italics
    when "\006"
      self.contents.font.italic = !self.contents.font.italic
      return
    # (\+I)   : Italics ON
    when "\007"
      self.contents.font.italic = true
      return
    # (\-I)   : Italics OFF
    when "\010"
      self.contents.font.italic = false
      return
    # (\TJL)  : Text Justify Left
    when "\011"
      Message.set_align(0)
      return
    # (\TJC)  : Text Justify Center
    when "\012"
      Message.set_align(1)
      return
    # (\TJR)  : Text Justify Right
    when "\013"
      Message.set_align(2)
      return
    # (\WJL)  : Window Justification Left
    when "\014"
      self.x = 8
      return
    # (\WJC)  : Window Justification Center
    when "\015"
      self.x = 320 - (self.width / 2)
      return
    # (\WJR)  : Window Justification Right
    when "\016"
      self.x = 640 - (self.width + 8)
      return
    # (\W[#]) : Default Window Width
    when "\017"
      @text.sub!(/\[([0-9]+)\]/, "")
      Message.set_width($1.to_i)
      return
    # (\H[#]) : Default Window Height
    when "\020"
      @text.sub!(/\[([0-9]+)\]/, "")
      Message.set_height($1.to_i)
      return
    # (\-W)   : Set Default Width
    when "\021"
      self.width  = Default_Width
      return
    # (\-H)   : Set Default Height
    when "\022"
      self.height = Default_Height
      return
    # (\FN[font]) : Set Font Name
    when "\023"
      @text.sub!(/\[(.*?)\]/, "")
      font = $1.to_s
      if font == "" ; self.contents.font.name = Font.default_name
      else          ; self.contents.font.name = font
      end
      return
    # (\-FN)      : Default Font Name
    when "\024"
      self.contents.font.name = Font.default_name
      return
    # (\FS[size]  : Set Font Size
    when "\025"
      @text.sub!(/\[([0-9]+)\]/, "")
      self.contents.font.size = $1.to_i
      return
    # (\-FS)      : Default Font Size
    when "\026"
      self.contents.font.size = Font.default_size
      return
    # (\WP0)  : Window Position Top
    when "\027"
      $game_system.message_position = 0
      return
    # (\WP1)  : Window Position Middle
    when "\030"
      $game_system.message_position = 1
      return
    # (\WP2)  : Window Position Bottom
    when "\031"
      $game_system.message_position = 2
      return
    # (\HIDE) : Set Transparent ON
    when "\032"
      $game_system.message_frame = 1
      return
    # (\SHOW) : Set Transparent OFF
    when "\033"
      $game_system.message_frame = 0
      return
    # (\NM[name]) : Set Name Box
    when "\034"
      @text.sub!(/\[(.*?)\]/, "")
      # ...Coming soon
      return
    end
  end
end
#-------------------------------------------------------------------------------
# * SDK Enabled Test - END
#-------------------------------------------------------------------------------
end
 
From the manual:

\nnn
 character at octal value nnn (n = 0-7)

\007 should work, but \008 & \009 should not.

I assume you are mimicking the replace (gsub) in the OOTB Window_Message to add additional escape sequences to your message system.
The reason the escape sequences are replaced with single characters is just to simplify the subsequent algorithm that cycles through each
individual character.

If you are actually trying to send the octal codes to the message window, characters 0-31 (\000 - \037) are invisible characters, and should not print.
Although \007 is the 'Bell' character, so if you have your sound on you might hear something.

I would suggest just using the octal characters that do work, and skip the ones that don't.

If you're still stymied, post the Window_Message code, and we'll see if we can debug it.

Be Well
 

poccil

Sponsor

In addition, the approach used by the RPGXP message system can only support a limited number of "message codes", as described above.  In my message system, I take a different approach.  In this case, I use a very long regular expression containing the supported message commands.  I store the indexes of their respective position and create the text with the message codes removed.  The commands extracted can influence the text display either before or during the message progression.  Here is an example.
Code:
  # Variable text stores the message text
  textchunks=[]  # Stores all text chunks to be joined
  controls=[]  # Stores all message commands
  # \WF and \FF take parameters, and \G and \WD take no parameters
  while text[/(?:\\([WwFf]|[Ff][Ff])\[([^\]]*)\]|\\([Gg]|[Ww][Dd])())/i]
   textchunks.push($~.pre_match)
   if $~[1]
    # Takes a parameter, either \WF or \FF
    # Store ["wf" or "wd", parameter, index (to be calculated)]
    controls.push([$~[1].downcase,$~[2],-1])
   else
    # Takes no parameter, either \G or \WD
    controls.push([$~[3].downcase,"",-1])
   end
   # Store the new text for the next match
   text=$~.post_match
  end
  # Store the last text chunk when no more commands exist.
  textchunks.push(text)
  # Replace "\\" with "\"
  for chunk in textchunks
   chunk.gsub!(/\\\\/,"\\")
  end
  # Process commands
  for i in 0...controls.length
   control=controls[i][0] # Get the next command (e.g. "g" or "wf")
   param=controls[i][1]  # Get the command's parameter
   # Process this message command
  end
  # Calculate the length of the text
  textlen=0
  for i in 0...controls.length
   # Get the next message command
   control=controls[i][0]
   # Add length in characters to the calculated length
   textlen+=textchunks[i].scan(/./m).length
   # Store the index of this message command
   controls[i][2]=textlen
  end
  # Rebuild the text
  text=textchunks.join("")
  # Later, the controls array can be used to process commands
  # that occur during text display, such as waiting a few frames,
  # depending on the index of the command, that is, how far the
  # message has progressed.
 
Okay, sorry for the bump (and the change in topic, I figured out what was weird with the message code thing.) But I'm stumped on why the message window won't go away when called in battle?

I did a battle test, just to see what the message window would do, and it would display the message, then clear like its supposed to, but then it wouldn't go away. (I think this should be the last question related to the default re-write and everything else should work fine from there.)

Also, if anybody see's anything with this re-write that could make aliasing the system easier for future custom and exotic Message Systems, feel free to post it.
 

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