Trilobytes Message System XP

Message System XP Version 1.00
Trilobytes by Trihan
​

Introduction
This script gives RMXP most of the same additional message codes as are available in Yanfly's Ace Message System for VX Ace.

Features
- Ability to display more than 4 lines of text at a time, controlled by a configurable variable
- Text codes for changing font name, size, colour, outlining and shadow
- Text codes for displaying a name window to the left, centre or right
- Text codes to show pictures and icons
- Text codes to display actor/party names and attributes
- Text codes to display names of database entries for classes, skills, items, weapons, armours and states

Screenshots
Spoiler: Screenshots
1647227473296.png
1647227496896.png
1647227527397.png
1647227544484.png
1647227629723.png
1647227746389.png
1647227958644.png
1647228221804.png
1647228675559.png

How to Use
In XP's Script Editor, insert a new line above Main, give it a descriptive name, and paste this script into the large window on the right. Then click Apply to save the changes.

Script

Code:
#==============================================================================
# Trilobytes - Message System XP v1.00
#
# - Updated: 14/03/22
#==============================================================================

module TLB_MSG
  ROW_VAR = 21
 
  def self.rows_for_text
    return 4 if ROW_VAR <= 0 || $game_variables[ROW_VAR] <= 0
    return $game_variables[ROW_VAR]
  end
end # TLB_MSG

#==============================================================================
# Version history
#
# 14/03/22 - Finished script
#==============================================================================
# Introduction
# ------------
# This script introduces to RPG Maker XP most of the text codes added to VX
# Ace by Yanfly's Ace Message System. Some of them aren't applicable to XP,
# such as those related to waiting (since XP shows all text at once) and faces
# (since XP doesn't use them).
#==============================================================================
# Instructions
# ------------
# In XP's Script Editor, insert a new line above Main, give it a descriptive
# name, and paste this script into the large window on the right. Then click
# Apply to save the changes.
#
# Text Codes
# ----------
#   Code:           Result:
#     \p[x]         - The name of the party member in slot x.
#     \g            - The name of the currency unit.
#     \c[x]         - Changes text colour to x.
#     \i[x]         - Draws the icon with the filename x.
#     \{            - Increases text size by 8.
#     \}            - Decreases text size by 8.
#     \$            - Opens the gold display window (was previously \g)
#
#   Name Window:    Result:
#     \n<x>         - Opens a name window with the string x on the left side.
#     \nc<x>        - Opens a name window with the string x in the centre.
#     \nr<x>        - Opens a name window with the string x on the right side.
#
#   Position:       Result:
#     \px[x]        - Places the following text at X position x.
#     \py[x]        - Places the following text at Y position x.
#
#   Picture:        Result:
#     \pic[x]       - Draws picture x from the Graphics/Pictures folder.
#
#   Outline:        Result:
#     \oc[x]        - Sets the outline colour to x (as defined in windowskin)
#     \oo[x]        - Sets outline opacity to x (0-255)
#
#   Font:           Result:
#     \fn[x]        - Sets the font name to x.
#     \fz[x]        - Sets the font size to x.
#     \fb           - Toggles font's bold setting.
#     \fi           - Toggles font's italic setting.
#     \fo           - Toggles font's outline.
#     \fs           - Toggles font's shadow.
#     \fr           - Resets all font changes.
#
#   Actor:          Result:
#     \ac[x]        - The name of actor x's class.
#
#     Note: Using 0 or a negative number for x  will use party index instead
#           of actor ID.
#
#   Names:          Result:
#     \nc[x]        - The name of class x.
#     \ni[x]        - The name of item x.
#     \nw[x]        - The name of weapon x.
#     \na[x]        - The name of armour x.
#     \nt[x]        - The name of state x.
#
#   Icon Names:     Result:
#     \ii[x]        - The name of item x, with icon.
#     \iw[x]        - The name of weapon x, with icon.
#     \ia[x]        - The name of armour x, with icon.
#     \is[x]        - The name of skill x, with icon.
#==============================================================================
#
#  Special thanks to Yanfly for the codes used in the VX Ace message system.
#
#==============================================================================

class Interpreter
  #--------------------------------------------------------------------------
  # * Show Text (overwrite)
  #--------------------------------------------------------------------------
  def command_101
    # If other text has been set to message_text
    if $game_temp.message_text != nil
      # End
      return false
    end
    # Set message end waiting flag and callback
    @message_waiting = true
    $game_temp.message_proc = Proc.new { @message_waiting = false }
    # Set message text on first line
    $game_temp.message_text = @list[@index].parameters[0] + "\n"
    line_count = 1
    # Loop
    loop do
      # Workaround for lines in a box that don't fit in the limit
      if @list[@index+1].code == 401 && line_count >= TLB_MSG.rows_for_text
          @list.insert(@index+2, RPG::EventCommand.new(101, @list[@index+1].indent, @list[@index+1].parameters))
          @list.delete_at(@index+1)
          return true
      # If next event command text is on the second line or after
      elsif @list[@index+1].code == 401 || (@list[@index+1].code == 101 && TLB_MSG.rows_for_text >= 4)
        # Add the second line or after to message_text
        #if @list[@index+1].code == 401
          $game_temp.message_text += @list[@index+1].parameters[0] + "\n"
          line_count += 1
        #end
      # If event command is not on the second line or after
      else
        # If next event command is show choices
        if @list[@index+1].code == 102
          # If choices fit on screen
          if @list[@index+1].parameters[0].size <= 4 - line_count
            # Advance index
            @index += 1
            # Choices setup
            $game_temp.choice_start = line_count
            setup_choices(@list[@index].parameters)
          end
        # If next event command is input number
        elsif @list[@index+1].code == 103
          # If number input window fits on screen
          if line_count < 4
            # Advance index
            @index += 1
            # Number input setup
            $game_temp.num_input_start = line_count
            $game_temp.num_input_variable_id = @list[@index].parameters[0]
            $game_temp.num_input_digits_max = @list[@index].parameters[1]
          end
        end
        # Continue
        return true
      end
      # Advance index
      return true if line_count > TLB_MSG.rows_for_text
      @index += 1
    end
  end
end

class Bitmap
  def draw_outline_text(*args)
    if args[0].is_a?(Rect)
      x, y, width, height = args[0].x, args[0].y, args[0].width, args[0].height
      text = args[1]
      alignment = args[2] ? args[2] : 0
    else
      x, y, width, height, text = args
      alignment = args[5] ? args[5] : 0
    end
    draw_text(x+1, y, width, height, text, alignment)
    draw_text(x-1, y, width, height, text, alignment)
    draw_text(x, y+1, width, height, text, alignment)
    draw_text(x, y-1, width, height, text, alignment)
    draw_text(x, y, width, height, text, alignment)
  end
end

class Window_Name < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(message_window, text, position)
    @message_window = message_window
    width = @message_window.contents.text_size(text).width + 40
    x = @message_window.x
    case position
    when 1:
      x = @message_window.x + @message_window.width - @message_window.width / 2 - width / 2
    when 2;
      x = @message_window.x + @message_window.width - width
    end
    super(x, @message_window.y - 64, width, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.back_opacity = 160
    @text = text.clone
    @position = position
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 0, 120, 32, @text.to_s)
  end
end

class Window_Message < Window_Selectable
  def create_name_window(text, position)
    if @name_window == nil
      @name_window = Window_Name.new(self, text, position)
    end
  end
 
  def reset_font_settings
    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
 
  def strip_string(text)
    return text.sub!(/\[(.*)\]/, "")
  end
 
  def refresh
    self.height = TLB_MSG.rows_for_text * 32 + 32
    self.y = 480 - self.height - 16
    if @name_window != nil
      @name_window.y = self.y - 64
    end
    self.contents = Bitmap.new(self.width - 32, self.height - 32)
    self.contents.clear
    self.contents.font.color = normal_color
    x = y = 0
    y_override = nil
    outline = false
    shadow = false
    out_color = Color.new(0, 0, 0, 255)
    @cursor_width = 0
    # Indent if choice
    if $game_temp.choice_start == 0
      x = 8
    end
    # If waiting for a message to be displayed
    if $game_temp.message_text != nil
      text = $game_temp.message_text
      # Control text processing
      begin
        last_text = text.clone
        text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
      end until text == last_text
      # Change "\\\\" to "\000" for convenience
      text.gsub!(/\\\\/) { "\000" }
      text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
        $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
      end
      text.gsub!(/\\[Pp]\[([0-9]+)\]/) do
        $game_party.actors[$1.to_i] != nil ? $game_party.actors[$1.to_i].name : ""
      end
      text.gsub!(/\\[Gg]/) do
        $data_system.words.gold
      end
      text.gsub!(/\\ac\[(-?[0-9]+)\]/) do
        id = $1.to_i
        if id > 0 && $game_actors[id] != nil
          $data_classes[$game_actors[id].class_id].name
        elsif id <= 0 && $game_party.actors[-id] != nil
          $data_classes[$game_party.actors[-id].class_id].name
        else
          ""
        end
      end
      text.gsub!(/\\nc\[([0-9]+)\]/) do
        id = $1.to_i
        $data_classes[id] != nil ? $data_classes[id].name : ""
      end
      text.gsub!(/\\ni\[([0-9]+)\]/) do
        id = $1.to_i
        $data_items[id] != nil ? $data_items[id].name : ""
      end
      text.gsub!(/\\nw\[([0-9]+)\]/) do
        id = $1.to_i
        $data_weapons[id] != nil ? $data_weapons[id].name : ""
      end
      text.gsub!(/\\na\[([0-9]+)\]/) do
        id = $1.to_i
        $data_armors[id] != nil ? $data_armors[id].name : ""
      end
      text.gsub!(/\\ns\[([0-9]+)\]/) do
        id = $1.to_i
        $data_skills[id] != nil ? $data_skills[id].name : ""
      end
      text.gsub!(/\\nt\[([0-9]+)\]/) do
        id = $1.to_i
        $data_states[id] != nil ? $data_states[id].name : ""
      end
      # Change "\\C" to "\001" and "\\G" to "\002"
      text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
      text.gsub!(/\\\$/) { "\002" }
      text.gsub!(/\\[Ii]\[(.*)\]/) { "\003[#{$1}]" }
      text.gsub!(/\\\{/) { "\004" }
      text.gsub!(/\\\}/) { "\005" }
      text.gsub!(/\\n\<(.*)\>/) { "\006[#{$1}]" }
      text.gsub!(/\\nc\<(.*)\>/) { "\007[#{$1}]" }
      text.gsub!(/\\nr\<(.*)\>/) { "\010[#{$1}]" }
      text.gsub!(/\\px\[([0-9]+)\]/) { "\013[#{$1}]" }
      text.gsub!(/\\py\[([0-9]+)\]/) { "\014[#{$1}]" }
      text.gsub!(/\\pic\[(.*)\]/) { "\015[#{$1}]" }
      text.gsub!(/\\oc\[([0-9]+)\]/) { "\016[#{$1}]" }
      text.gsub!(/\\oo\[([0-9]+)\]/) { "\017[#{$1}]" }
      text.gsub!(/\\fr/) { "\020" }
      text.gsub!(/\\fz\[([0-9]+)\]/) { "\021[#{$1}]" }
      text.gsub!(/\\fn\[(.*)\]/) { "\022[#{$1}]" }
      text.gsub!(/\\fb/) { "\023" }
      text.gsub!(/\\fi/) { "\024" }
      text.gsub!(/\\fo/) { "\025" }
      text.gsub!(/\\fs/) { "\026" }
      text.gsub!(/\\ii\[([0-9]+)\]/) { "\027[#{$1}]" }
      text.gsub!(/\\iw\[([0-9]+)\]/) { "\030[#{$1}]" }
      text.gsub!(/\\ia\[([0-9]+)\]/) { "\031[#{$1}]" }
      text.gsub!(/\\is\[([0-9]+)\]/) { "\032[#{$1}]" }
      # Get 1 text character in c (loop until unable to get text)
      while ((c = text.slice!(/./m)) != nil)
        # If \\
        if c == "\000"
          # Return to original text
          c = "\\"
        end
        # If \C[n]
        if c == "\001"
          # 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
          # go to next text
          next
        end
        # If \G
        if c == "\002"
          # Make gold window
          if @gold_window == nil
            @gold_window = Window_Gold.new
            @gold_window.x = 560 - @gold_window.width
            if $game_temp.in_battle
              @gold_window.y = 192
            else
              @gold_window.y = self.y >= 128 ? 32 : 384
            end
            @gold_window.opacity = self.opacity
            @gold_window.back_opacity = self.back_opacity
          end
          # go to next text
          next
        end
        if c == "\003"
          text.sub!(/\[(.*)\]/, "")
          icon_name = $1.to_s
          bitmap = RPG::Cache.icon(icon_name)
          self.contents.blt(x, 32 * y + 4, bitmap, Rect.new(0, 0, 24, 24))
          x += 12
          next
        end
        if c == "\004"
          self.contents.font.size += 8 if self.contents.font.size <= 64
          next
        end
        if c == "\005"
          self.contents.font.size -= 8 if self.contents.font.size >= 16
          next
        end
        if c == "\006"
          text.sub!(/\[(.*)\]/, "")
          name_text = $1.to_s
          create_name_window(name_text, 0)
          next
        end
        if c == "\007"
          text.sub!(/\[(.*)\]/, "")
          name_text = $1.to_s
          create_name_window(name_text, 1)
          next
        end
        if c == "\010"
          text.sub!(/\[(.*)\]/, "")
          name_text = $1.to_s
          create_name_window(name_text, 2)
          next
        end
        if c == "\013"
          text.sub!(/\[([0-9]+)\]/, "")
          x = $1.to_i
          next
        end
        if c == "\014"
          text.sub!(/\[([0-9]+)\]/, "")
          y_override = $1.to_i
          next
        end
        if c == "\015"
          text.sub!(/\[(.*)\]/, "")
          bitmap = RPG::Cache.picture($1.to_s)
          cw = bitmap.width
          ch = bitmap.height
          src_rect = Rect.new(0, 0, cw, ch)
          self.contents.blt(x, y, bitmap, src_rect)
          next
        end
        if c == "\016"
          text.sub!(/\[([0-9]+)\]/, "")
          outline = true
          out_color = text_color($1.to_i)
          next
        end
        if c == "\017"
          text.sub!(/\[([0-9]+)\]/, "")
          outline = true
          out_color.alpha = $1.to_i
          next
        end
        if c == "\020"
          reset_font_settings
          outline = false
          shadow = false
          out_color = Color.new(0, 0, 0, 255)
          next
        end
        if c == "\021"
          text.sub!(/\[([0-9]+)\]/, "")
          self.contents.font.size = $1.to_i
          next
        end
        if c == "\022"
          text.sub!(/\[(.*)\]/, "")
          self.contents.font.name = $1.to_s
          next
        end
        if c == "\023"
          self.contents.font.bold = !self.contents.font.bold
          next
        end
        if c == "\024"
          self.contents.font.italic = !self.contents.font.italic
          next
        end
        if c == "\025"
          outline = !outline
          next
        end
        if c == "\026"
          shadow = !shadow
          next
        end
        if c == "\027"
          text.sub!(/\[([0-9]+)\]/, "")
          item = $data_items[$1.to_i]
          if item != nil
            bitmap = RPG::Cache.icon(item.icon_name)
            self.contents.blt(x, (y_override || (32 * y)) + 4, bitmap, Rect.new(0, 0, 24, 24))
            text = item.name + text
            x += 24
          end
          next
        end
        if c == "\030"
          text.sub!(/\[([0-9]+)\]/, "")
          item = $data_weapons[$1.to_i]
          if item != nil
            bitmap = RPG::Cache.icon(item.icon_name)
            self.contents.blt(x, (y_override || (32 * y)) + 4, bitmap, Rect.new(0, 0, 24, 24))
            text = item.name + text
            x += 24
          end
          next
        end
        if c == "\031"
          text.sub!(/\[([0-9]+)\]/, "")
          item = $data_armors[$1.to_i]
          if item != nil
            bitmap = RPG::Cache.icon(item.icon_name)
            self.contents.blt(x, (y_override || (32 * y)) + 4, bitmap, Rect.new(0, 0, 24, 24))
            text = item.name + text
            x += 24
          end
          next
        end
        if c == "\032"
          text.sub!(/\[([0-9]+)\]/, "")
          item = $data_skills[$1.to_i]
          if item != nil
            bitmap = RPG::Cache.icon(item.icon_name)
            self.contents.blt(x, (y_override || (32 * y)) + 4, bitmap, Rect.new(0, 0, 24, 24))
            text = item.name + text
            x += 24
          end
          next
        end
        # If new line text
        if c == "\n"
          # Update cursor width if choice
          if y >= $game_temp.choice_start
            @cursor_width = [@cursor_width, x].max
          end
          # Add 1 to y
          y += 1
          x = 0
          # Indent if choice
          if y >= $game_temp.choice_start
            x = 8
          end
          y_override += 32 if y_override
          # go to next text
          next
        end
        # Draw text
        if shadow
          color = self.contents.font.color.dup
          self.contents.font.color = Color.new(0, 0, 0)
          self.contents.draw_text(4 + x, (y_override || (32 * y)) + 1, 40, 32, c)
          self.contents.font.color = color
        end
        if outline
          color = self.contents.font.color.dup
          self.contents.font.color = out_color
          self.contents.draw_outline_text(4 + x, y_override || (32 * y), 40, 32, c)
          self.contents.font.color = color
        else
          self.contents.draw_text(4 + x, y_override || 32 * y, 40, 32, c)
        end
        # Add x to drawn text width
        x += self.contents.text_size(c).width
      end
    end
    # If choice
    if $game_temp.choice_max > 0
      @item_max = $game_temp.choice_max
      self.active = true
      self.index = 0
    end
    # If number input
    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
 
  alias :tlb_msg_update :update unless $@
  def update
    tlb_msg_update
    if !self.visible && @name_window != nil
      @name_window.dispose
      @name_window = nil
    end
  end
end

FAQ
None yet

Credit and Thanks
- Trihan
- Yanfly, for the message codes provided in the Ace Message System
This looks absolutely fantastic, and I can't wait to give it a try!

is it all right to use this script in commercial projects, credited as above? I'd like to use it in my IGMC project!
Glad you like it, Tei! Do let me know if there are any additional features you're looking for from it.
I responded to your PM as well, but yes it's absolutely fine for you to use this in your IGMC project. Good luck!
Thank you very much!

It works like a dream! The only thing I could possibly think to add would be the ability to center text in the textbox, for things like signs. But I don't know how much easier said than done that is XD
Thank you very much!

It works like a dream! The only thing I could possibly think to add would be the ability to center text in the textbox, for things like signs. But I don't know how much easier said than done that is XD
I don't think that would be an enormous hardship to do.
Hey there! I have finally bumped into something that I have a question about: changing the message box position!

I had set my various narrator-type messages to have the message box in the middle of the screen, instead of at the bottom. I just realized that they've all fallen to the bottom, in spite of the "change message options" commands that say otherwise.

Is there something in the script that I'm overlooking that overrides that Change Message Options event command?
Hey there! I have finally bumped into something that I have a question about: changing the message box position!

I had set my various narrator-type messages to have the message box in the middle of the screen, instead of at the bottom. I just realized that they've all fallen to the bottom, in spite of the "change message options" commands that say otherwise.

Is there something in the script that I'm overlooking that overrides that Change Message Options event command?
There shouldn't be. Can you show me some screenshots?
In-game, this text box looks like this:
TeIRaven Text Box In Game.png


But the event says this:

TeiRaven Text Box Event.png


I also made a duplicate of my project without the message script, to be sure it wasn't one of my other scripts, and it moved the text box up as expected:
TeiRaven Text Box No Script.png


So I am not sure what's going on! I haven't changed anything in your script except for the variable for the number of lines per box. Thanks for looking at it!
Hello, when importing the script using MKXP, an error occurs that I haven't been able to figure out so far. Could you help me? The other scripts work perfectly, but for some reason, yours keeps triggering this error. I really loved your script when I used the original player, but as we know, the player is quite outdated, and it doesn't provide a smooth gameplay experience.

Error.PNG


I would be very grateful if you could take a look. :3
Whenever you see some when number: replace it with when number;
Message System XP Version 1.00
Trilobytes by Trihan
​

Introduction
This script gives RMXP most of the same additional message codes as are available in Yanfly's Ace Message System for VX Ace.

Features
- Ability to display more than 4 lines of text at a time, controlled by a configurable variable
- Text codes for changing font name, size, colour, outlining and shadow
- Text codes for displaying a name window to the left, centre or right
- Text codes to show pictures and icons
- Text codes to display actor/party names and attributes
- Text codes to display names of database entries for classes, skills, items, weapons, armours and states

Screenshots

How to Use
In XP's Script Editor, insert a new line above Main, give it a descriptive name, and paste this script into the large window on the right. Then click Apply to save the changes.

Script

Code:
#==============================================================================
# Trilobytes - Message System XP v1.00
#
# - Updated: 14/03/22
#==============================================================================

module TLB_MSG
  ROW_VAR = 21
 
  def self.rows_for_text
    return 4 if ROW_VAR <= 0 || $game_variables[ROW_VAR] <= 0
    return $game_variables[ROW_VAR]
  end
end # TLB_MSG

#==============================================================================
# Version history
#
# 14/03/22 - Finished script
#==============================================================================
# Introduction
# ------------
# This script introduces to RPG Maker XP most of the text codes added to VX
# Ace by Yanfly's Ace Message System. Some of them aren't applicable to XP,
# such as those related to waiting (since XP shows all text at once) and faces
# (since XP doesn't use them).
#==============================================================================
# Instructions
# ------------
# In XP's Script Editor, insert a new line above Main, give it a descriptive
# name, and paste this script into the large window on the right. Then click
# Apply to save the changes.
#
# Text Codes
# ----------
#   Code:           Result:
#     \p[x]         - The name of the party member in slot x.
#     \g            - The name of the currency unit.
#     \c[x]         - Changes text colour to x.
#     \i[x]         - Draws the icon with the filename x.
#     \{            - Increases text size by 8.
#     \}            - Decreases text size by 8.
#     \$            - Opens the gold display window (was previously \g)
#
#   Name Window:    Result:
#     \n<x>         - Opens a name window with the string x on the left side.
#     \nc<x>        - Opens a name window with the string x in the centre.
#     \nr<x>        - Opens a name window with the string x on the right side.
#
#   Position:       Result:
#     \px[x]        - Places the following text at X position x.
#     \py[x]        - Places the following text at Y position x.
#
#   Picture:        Result:
#     \pic[x]       - Draws picture x from the Graphics/Pictures folder.
#
#   Outline:        Result:
#     \oc[x]        - Sets the outline colour to x (as defined in windowskin)
#     \oo[x]        - Sets outline opacity to x (0-255)
#
#   Font:           Result:
#     \fn[x]        - Sets the font name to x.
#     \fz[x]        - Sets the font size to x.
#     \fb           - Toggles font's bold setting.
#     \fi           - Toggles font's italic setting.
#     \fo           - Toggles font's outline.
#     \fs           - Toggles font's shadow.
#     \fr           - Resets all font changes.
#
#   Actor:          Result:
#     \ac[x]        - The name of actor x's class.
#
#     Note: Using 0 or a negative number for x  will use party index instead
#           of actor ID.
#
#   Names:          Result:
#     \nc[x]        - The name of class x.
#     \ni[x]        - The name of item x.
#     \nw[x]        - The name of weapon x.
#     \na[x]        - The name of armour x.
#     \nt[x]        - The name of state x.
#
#   Icon Names:     Result:
#     \ii[x]        - The name of item x, with icon.
#     \iw[x]        - The name of weapon x, with icon.
#     \ia[x]        - The name of armour x, with icon.
#     \is[x]        - The name of skill x, with icon.
#==============================================================================
#
#  Special thanks to Yanfly for the codes used in the VX Ace message system.
#
#==============================================================================

class Interpreter
  #--------------------------------------------------------------------------
  # * Show Text (overwrite)
  #--------------------------------------------------------------------------
  def command_101
    # If other text has been set to message_text
    if $game_temp.message_text != nil
      # End
      return false
    end
    # Set message end waiting flag and callback
    @message_waiting = true
    $game_temp.message_proc = Proc.new { @message_waiting = false }
    # Set message text on first line
    $game_temp.message_text = @list[@index].parameters[0] + "\n"
    line_count = 1
    # Loop
    loop do
      # Workaround for lines in a box that don't fit in the limit
      if @list[@index+1].code == 401 && line_count >= TLB_MSG.rows_for_text
          @list.insert(@index+2, RPG::EventCommand.new(101, @list[@index+1].indent, @list[@index+1].parameters))
          @list.delete_at(@index+1)
          return true
      # If next event command text is on the second line or after
      elsif @list[@index+1].code == 401 || (@list[@index+1].code == 101 && TLB_MSG.rows_for_text >= 4)
        # Add the second line or after to message_text
        #if @list[@index+1].code == 401
          $game_temp.message_text += @list[@index+1].parameters[0] + "\n"
          line_count += 1
        #end
      # If event command is not on the second line or after
      else
        # If next event command is show choices
        if @list[@index+1].code == 102
          # If choices fit on screen
          if @list[@index+1].parameters[0].size <= 4 - line_count
            # Advance index
            @index += 1
            # Choices setup
            $game_temp.choice_start = line_count
            setup_choices(@list[@index].parameters)
          end
        # If next event command is input number
        elsif @list[@index+1].code == 103
          # If number input window fits on screen
          if line_count < 4
            # Advance index
            @index += 1
            # Number input setup
            $game_temp.num_input_start = line_count
            $game_temp.num_input_variable_id = @list[@index].parameters[0]
            $game_temp.num_input_digits_max = @list[@index].parameters[1]
          end
        end
        # Continue
        return true
      end
      # Advance index
      return true if line_count > TLB_MSG.rows_for_text
      @index += 1
    end
  end
end

class Bitmap
  def draw_outline_text(*args)
    if args[0].is_a?(Rect)
      x, y, width, height = args[0].x, args[0].y, args[0].width, args[0].height
      text = args[1]
      alignment = args[2] ? args[2] : 0
    else
      x, y, width, height, text = args
      alignment = args[5] ? args[5] : 0
    end
    draw_text(x+1, y, width, height, text, alignment)
    draw_text(x-1, y, width, height, text, alignment)
    draw_text(x, y+1, width, height, text, alignment)
    draw_text(x, y-1, width, height, text, alignment)
    draw_text(x, y, width, height, text, alignment)
  end
end

class Window_Name < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(message_window, text, position)
    @message_window = message_window
    width = @message_window.contents.text_size(text).width + 40
    x = @message_window.x
    case position
    when 1:
      x = @message_window.x + @message_window.width - @message_window.width / 2 - width / 2
    when 2;
      x = @message_window.x + @message_window.width - width
    end
    super(x, @message_window.y - 64, width, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.back_opacity = 160
    @text = text.clone
    @position = position
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 0, 120, 32, @text.to_s)
  end
end

class Window_Message < Window_Selectable
  def create_name_window(text, position)
    if @name_window == nil
      @name_window = Window_Name.new(self, text, position)
    end
  end
 
  def reset_font_settings
    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
 
  def strip_string(text)
    return text.sub!(/\[(.*)\]/, "")
  end
 
  def refresh
    self.height = TLB_MSG.rows_for_text * 32 + 32
    self.y = 480 - self.height - 16
    if @name_window != nil
      @name_window.y = self.y - 64
    end
    self.contents = Bitmap.new(self.width - 32, self.height - 32)
    self.contents.clear
    self.contents.font.color = normal_color
    x = y = 0
    y_override = nil
    outline = false
    shadow = false
    out_color = Color.new(0, 0, 0, 255)
    @cursor_width = 0
    # Indent if choice
    if $game_temp.choice_start == 0
      x = 8
    end
    # If waiting for a message to be displayed
    if $game_temp.message_text != nil
      text = $game_temp.message_text
      # Control text processing
      begin
        last_text = text.clone
        text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
      end until text == last_text
      # Change "\\\\" to "\000" for convenience
      text.gsub!(/\\\\/) { "\000" }
      text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
        $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
      end
      text.gsub!(/\\[Pp]\[([0-9]+)\]/) do
        $game_party.actors[$1.to_i] != nil ? $game_party.actors[$1.to_i].name : ""
      end
      text.gsub!(/\\[Gg]/) do
        $data_system.words.gold
      end
      text.gsub!(/\\ac\[(-?[0-9]+)\]/) do
        id = $1.to_i
        if id > 0 && $game_actors[id] != nil
          $data_classes[$game_actors[id].class_id].name
        elsif id <= 0 && $game_party.actors[-id] != nil
          $data_classes[$game_party.actors[-id].class_id].name
        else
          ""
        end
      end
      text.gsub!(/\\nc\[([0-9]+)\]/) do
        id = $1.to_i
        $data_classes[id] != nil ? $data_classes[id].name : ""
      end
      text.gsub!(/\\ni\[([0-9]+)\]/) do
        id = $1.to_i
        $data_items[id] != nil ? $data_items[id].name : ""
      end
      text.gsub!(/\\nw\[([0-9]+)\]/) do
        id = $1.to_i
        $data_weapons[id] != nil ? $data_weapons[id].name : ""
      end
      text.gsub!(/\\na\[([0-9]+)\]/) do
        id = $1.to_i
        $data_armors[id] != nil ? $data_armors[id].name : ""
      end
      text.gsub!(/\\ns\[([0-9]+)\]/) do
        id = $1.to_i
        $data_skills[id] != nil ? $data_skills[id].name : ""
      end
      text.gsub!(/\\nt\[([0-9]+)\]/) do
        id = $1.to_i
        $data_states[id] != nil ? $data_states[id].name : ""
      end
      # Change "\\C" to "\001" and "\\G" to "\002"
      text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
      text.gsub!(/\\\$/) { "\002" }
      text.gsub!(/\\[Ii]\[(.*)\]/) { "\003[#{$1}]" }
      text.gsub!(/\\\{/) { "\004" }
      text.gsub!(/\\\}/) { "\005" }
      text.gsub!(/\\n\<(.*)\>/) { "\006[#{$1}]" }
      text.gsub!(/\\nc\<(.*)\>/) { "\007[#{$1}]" }
      text.gsub!(/\\nr\<(.*)\>/) { "\010[#{$1}]" }
      text.gsub!(/\\px\[([0-9]+)\]/) { "\013[#{$1}]" }
      text.gsub!(/\\py\[([0-9]+)\]/) { "\014[#{$1}]" }
      text.gsub!(/\\pic\[(.*)\]/) { "\015[#{$1}]" }
      text.gsub!(/\\oc\[([0-9]+)\]/) { "\016[#{$1}]" }
      text.gsub!(/\\oo\[([0-9]+)\]/) { "\017[#{$1}]" }
      text.gsub!(/\\fr/) { "\020" }
      text.gsub!(/\\fz\[([0-9]+)\]/) { "\021[#{$1}]" }
      text.gsub!(/\\fn\[(.*)\]/) { "\022[#{$1}]" }
      text.gsub!(/\\fb/) { "\023" }
      text.gsub!(/\\fi/) { "\024" }
      text.gsub!(/\\fo/) { "\025" }
      text.gsub!(/\\fs/) { "\026" }
      text.gsub!(/\\ii\[([0-9]+)\]/) { "\027[#{$1}]" }
      text.gsub!(/\\iw\[([0-9]+)\]/) { "\030[#{$1}]" }
      text.gsub!(/\\ia\[([0-9]+)\]/) { "\031[#{$1}]" }
      text.gsub!(/\\is\[([0-9]+)\]/) { "\032[#{$1}]" }
      # Get 1 text character in c (loop until unable to get text)
      while ((c = text.slice!(/./m)) != nil)
        # If \\
        if c == "\000"
          # Return to original text
          c = "\\"
        end
        # If \C[n]
        if c == "\001"
          # 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
          # go to next text
          next
        end
        # If \G
        if c == "\002"
          # Make gold window
          if @gold_window == nil
            @gold_window = Window_Gold.new
            @gold_window.x = 560 - @gold_window.width
            if $game_temp.in_battle
              @gold_window.y = 192
            else
              @gold_window.y = self.y >= 128 ? 32 : 384
            end
            @gold_window.opacity = self.opacity
            @gold_window.back_opacity = self.back_opacity
          end
          # go to next text
          next
        end
        if c == "\003"
          text.sub!(/\[(.*)\]/, "")
          icon_name = $1.to_s
          bitmap = RPG::Cache.icon(icon_name)
          self.contents.blt(x, 32 * y + 4, bitmap, Rect.new(0, 0, 24, 24))
          x += 12
          next
        end
        if c == "\004"
          self.contents.font.size += 8 if self.contents.font.size <= 64
          next
        end
        if c == "\005"
          self.contents.font.size -= 8 if self.contents.font.size >= 16
          next
        end
        if c == "\006"
          text.sub!(/\[(.*)\]/, "")
          name_text = $1.to_s
          create_name_window(name_text, 0)
          next
        end
        if c == "\007"
          text.sub!(/\[(.*)\]/, "")
          name_text = $1.to_s
          create_name_window(name_text, 1)
          next
        end
        if c == "\010"
          text.sub!(/\[(.*)\]/, "")
          name_text = $1.to_s
          create_name_window(name_text, 2)
          next
        end
        if c == "\013"
          text.sub!(/\[([0-9]+)\]/, "")
          x = $1.to_i
          next
        end
        if c == "\014"
          text.sub!(/\[([0-9]+)\]/, "")
          y_override = $1.to_i
          next
        end
        if c == "\015"
          text.sub!(/\[(.*)\]/, "")
          bitmap = RPG::Cache.picture($1.to_s)
          cw = bitmap.width
          ch = bitmap.height
          src_rect = Rect.new(0, 0, cw, ch)
          self.contents.blt(x, y, bitmap, src_rect)
          next
        end
        if c == "\016"
          text.sub!(/\[([0-9]+)\]/, "")
          outline = true
          out_color = text_color($1.to_i)
          next
        end
        if c == "\017"
          text.sub!(/\[([0-9]+)\]/, "")
          outline = true
          out_color.alpha = $1.to_i
          next
        end
        if c == "\020"
          reset_font_settings
          outline = false
          shadow = false
          out_color = Color.new(0, 0, 0, 255)
          next
        end
        if c == "\021"
          text.sub!(/\[([0-9]+)\]/, "")
          self.contents.font.size = $1.to_i
          next
        end
        if c == "\022"
          text.sub!(/\[(.*)\]/, "")
          self.contents.font.name = $1.to_s
          next
        end
        if c == "\023"
          self.contents.font.bold = !self.contents.font.bold
          next
        end
        if c == "\024"
          self.contents.font.italic = !self.contents.font.italic
          next
        end
        if c == "\025"
          outline = !outline
          next
        end
        if c == "\026"
          shadow = !shadow
          next
        end
        if c == "\027"
          text.sub!(/\[([0-9]+)\]/, "")
          item = $data_items[$1.to_i]
          if item != nil
            bitmap = RPG::Cache.icon(item.icon_name)
            self.contents.blt(x, (y_override || (32 * y)) + 4, bitmap, Rect.new(0, 0, 24, 24))
            text = item.name + text
            x += 24
          end
          next
        end
        if c == "\030"
          text.sub!(/\[([0-9]+)\]/, "")
          item = $data_weapons[$1.to_i]
          if item != nil
            bitmap = RPG::Cache.icon(item.icon_name)
            self.contents.blt(x, (y_override || (32 * y)) + 4, bitmap, Rect.new(0, 0, 24, 24))
            text = item.name + text
            x += 24
          end
          next
        end
        if c == "\031"
          text.sub!(/\[([0-9]+)\]/, "")
          item = $data_armors[$1.to_i]
          if item != nil
            bitmap = RPG::Cache.icon(item.icon_name)
            self.contents.blt(x, (y_override || (32 * y)) + 4, bitmap, Rect.new(0, 0, 24, 24))
            text = item.name + text
            x += 24
          end
          next
        end
        if c == "\032"
          text.sub!(/\[([0-9]+)\]/, "")
          item = $data_skills[$1.to_i]
          if item != nil
            bitmap = RPG::Cache.icon(item.icon_name)
            self.contents.blt(x, (y_override || (32 * y)) + 4, bitmap, Rect.new(0, 0, 24, 24))
            text = item.name + text
            x += 24
          end
          next
        end
        # If new line text
        if c == "\n"
          # Update cursor width if choice
          if y >= $game_temp.choice_start
            @cursor_width = [@cursor_width, x].max
          end
          # Add 1 to y
          y += 1
          x = 0
          # Indent if choice
          if y >= $game_temp.choice_start
            x = 8
          end
          y_override += 32 if y_override
          # go to next text
          next
        end
        # Draw text
        if shadow
          color = self.contents.font.color.dup
          self.contents.font.color = Color.new(0, 0, 0)
          self.contents.draw_text(4 + x, (y_override || (32 * y)) + 1, 40, 32, c)
          self.contents.font.color = color
        end
        if outline
          color = self.contents.font.color.dup
          self.contents.font.color = out_color
          self.contents.draw_outline_text(4 + x, y_override || (32 * y), 40, 32, c)
          self.contents.font.color = color
        else
          self.contents.draw_text(4 + x, y_override || 32 * y, 40, 32, c)
        end
        # Add x to drawn text width
        x += self.contents.text_size(c).width
      end
    end
    # If choice
    if $game_temp.choice_max > 0
      @item_max = $game_temp.choice_max
      self.active = true
      self.index = 0
    end
    # If number input
    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
 
  alias :tlb_msg_update :update unless $@
  def update
    tlb_msg_update
    if !self.visible && @name_window != nil
      @name_window.dispose
      @name_window = nil
    end
  end
end

FAQ
None yet

Credit and Thanks
- Trihan
- Yanfly, for the message codes provided in the Ace Message System
How do I make it so its not showing dialog that isn't supposed to be ther when I put the script in it works but my dialog is displaying diolog from the next text
Hi everyone, I am new on RMXP I have been using 2K3 for 15 years now.
I am new on the scripts, I just paste this script on the scrit manager of RMXP on a new line above main, and name it speach. I create an event that when the player trigger it with an action button it sends a message.
The message is done with the Show Text Command button an it says:

"/nc<NPC1> Hello world!"
In game it prints out exactly that, the code is not interpreted.
Does anybody know what i am doing wrong?? thanks in advance!
Hi everyone, I am new on RMXP I have been using 2K3 for 15 years now.
I am new on the scripts, I just paste this script on the scrit manager of RMXP on a new line above main, and name it speach. I create an event that when the player trigger it with an action button it sends a message.
The message is done with the Show Text Command button an it says:

"/nc<NPC1> Hello world!"
In game it prints out exactly that, the code is not interpreted.
Does anybody know what i am doing wrong?? thanks in advance!
It’s because you use the wrong slash, it should be backslash.
\nc<text> instead of /nc<text>
It’s because you use the wrong slash, it should be backslash.
\nc<text> instead of /nc<text>
Thanks!, I feel so dumb right now.

It’s because you use the wrong slash, it should be backslash.
\nc<text> instead of /nc<text>
I have another issue. I can make it work right now, but in a conversation I can't change the name on the name window.
For example:
two npc are "talking" to each other. everything is on the same event.
\n<npc1> Hello world! (it shows ok)
\n<npc2> Hello world2! (it keeps saying NPC1 on the name window)
\nr< \p[0] > Hello world3! (it keeps saying NPC1 on the name window)
end of event
Message System XP Version 1.00
Trilobytes by Trihan
​

Introduction
This script gives RMXP most of the same additional message codes as are available in Yanfly's Ace Message System for VX Ace.

Features
- Ability to display more than 4 lines of text at a time, controlled by a configurable variable
- Text codes for changing font name, size, colour, outlining and shadow
- Text codes for displaying a name window to the left, centre or right
- Text codes to show pictures and icons
- Text codes to display actor/party names and attributes
- Text codes to display names of database entries for classes, skills, items, weapons, armours and states

Screenshots

How to Use
In XP's Script Editor, insert a new line above Main, give it a descriptive name, and paste this script into the large window on the right. Then click Apply to save the changes.

Script

Code:
#==============================================================================
# Trilobytes - Message System XP v1.00
#
# - Updated: 14/03/22
#==============================================================================

module TLB_MSG
  ROW_VAR = 21
 
  def self.rows_for_text
    return 4 if ROW_VAR <= 0 || $game_variables[ROW_VAR] <= 0
    return $game_variables[ROW_VAR]
  end
end # TLB_MSG

#==============================================================================
# Version history
#
# 14/03/22 - Finished script
#==============================================================================
# Introduction
# ------------
# This script introduces to RPG Maker XP most of the text codes added to VX
# Ace by Yanfly's Ace Message System. Some of them aren't applicable to XP,
# such as those related to waiting (since XP shows all text at once) and faces
# (since XP doesn't use them).
#==============================================================================
# Instructions
# ------------
# In XP's Script Editor, insert a new line above Main, give it a descriptive
# name, and paste this script into the large window on the right. Then click
# Apply to save the changes.
#
# Text Codes
# ----------
#   Code:           Result:
#     \p[x]         - The name of the party member in slot x.
#     \g            - The name of the currency unit.
#     \c[x]         - Changes text colour to x.
#     \i[x]         - Draws the icon with the filename x.
#     \{            - Increases text size by 8.
#     \}            - Decreases text size by 8.
#     \$            - Opens the gold display window (was previously \g)
#
#   Name Window:    Result:
#     \n<x>         - Opens a name window with the string x on the left side.
#     \nc<x>        - Opens a name window with the string x in the centre.
#     \nr<x>        - Opens a name window with the string x on the right side.
#
#   Position:       Result:
#     \px[x]        - Places the following text at X position x.
#     \py[x]        - Places the following text at Y position x.
#
#   Picture:        Result:
#     \pic[x]       - Draws picture x from the Graphics/Pictures folder.
#
#   Outline:        Result:
#     \oc[x]        - Sets the outline colour to x (as defined in windowskin)
#     \oo[x]        - Sets outline opacity to x (0-255)
#
#   Font:           Result:
#     \fn[x]        - Sets the font name to x.
#     \fz[x]        - Sets the font size to x.
#     \fb           - Toggles font's bold setting.
#     \fi           - Toggles font's italic setting.
#     \fo           - Toggles font's outline.
#     \fs           - Toggles font's shadow.
#     \fr           - Resets all font changes.
#
#   Actor:          Result:
#     \ac[x]        - The name of actor x's class.
#
#     Note: Using 0 or a negative number for x  will use party index instead
#           of actor ID.
#
#   Names:          Result:
#     \nc[x]        - The name of class x.
#     \ni[x]        - The name of item x.
#     \nw[x]        - The name of weapon x.
#     \na[x]        - The name of armour x.
#     \nt[x]        - The name of state x.
#
#   Icon Names:     Result:
#     \ii[x]        - The name of item x, with icon.
#     \iw[x]        - The name of weapon x, with icon.
#     \ia[x]        - The name of armour x, with icon.
#     \is[x]        - The name of skill x, with icon.
#==============================================================================
#
#  Special thanks to Yanfly for the codes used in the VX Ace message system.
#
#==============================================================================

class Interpreter
  #--------------------------------------------------------------------------
  # * Show Text (overwrite)
  #--------------------------------------------------------------------------
  def command_101
    # If other text has been set to message_text
    if $game_temp.message_text != nil
      # End
      return false
    end
    # Set message end waiting flag and callback
    @message_waiting = true
    $game_temp.message_proc = Proc.new { @message_waiting = false }
    # Set message text on first line
    $game_temp.message_text = @list[@index].parameters[0] + "\n"
    line_count = 1
    # Loop
    loop do
      # Workaround for lines in a box that don't fit in the limit
      if @list[@index+1].code == 401 && line_count >= TLB_MSG.rows_for_text
          @list.insert(@index+2, RPG::EventCommand.new(101, @list[@index+1].indent, @list[@index+1].parameters))
          @list.delete_at(@index+1)
          return true
      # If next event command text is on the second line or after
      elsif @list[@index+1].code == 401 || (@list[@index+1].code == 101 && TLB_MSG.rows_for_text >= 4)
        # Add the second line or after to message_text
        #if @list[@index+1].code == 401
          $game_temp.message_text += @list[@index+1].parameters[0] + "\n"
          line_count += 1
        #end
      # If event command is not on the second line or after
      else
        # If next event command is show choices
        if @list[@index+1].code == 102
          # If choices fit on screen
          if @list[@index+1].parameters[0].size <= 4 - line_count
            # Advance index
            @index += 1
            # Choices setup
            $game_temp.choice_start = line_count
            setup_choices(@list[@index].parameters)
          end
        # If next event command is input number
        elsif @list[@index+1].code == 103
          # If number input window fits on screen
          if line_count < 4
            # Advance index
            @index += 1
            # Number input setup
            $game_temp.num_input_start = line_count
            $game_temp.num_input_variable_id = @list[@index].parameters[0]
            $game_temp.num_input_digits_max = @list[@index].parameters[1]
          end
        end
        # Continue
        return true
      end
      # Advance index
      return true if line_count > TLB_MSG.rows_for_text
      @index += 1
    end
  end
end

class Bitmap
  def draw_outline_text(*args)
    if args[0].is_a?(Rect)
      x, y, width, height = args[0].x, args[0].y, args[0].width, args[0].height
      text = args[1]
      alignment = args[2] ? args[2] : 0
    else
      x, y, width, height, text = args
      alignment = args[5] ? args[5] : 0
    end
    draw_text(x+1, y, width, height, text, alignment)
    draw_text(x-1, y, width, height, text, alignment)
    draw_text(x, y+1, width, height, text, alignment)
    draw_text(x, y-1, width, height, text, alignment)
    draw_text(x, y, width, height, text, alignment)
  end
end

class Window_Name < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(message_window, text, position)
    @message_window = message_window
    width = @message_window.contents.text_size(text).width + 40
    x = @message_window.x
    case position
    when 1:
      x = @message_window.x + @message_window.width - @message_window.width / 2 - width / 2
    when 2;
      x = @message_window.x + @message_window.width - width
    end
    super(x, @message_window.y - 64, width, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.back_opacity = 160
    @text = text.clone
    @position = position
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 0, 120, 32, @text.to_s)
  end
end

class Window_Message < Window_Selectable
  def create_name_window(text, position)
    if @name_window == nil
      @name_window = Window_Name.new(self, text, position)
    end
  end
 
  def reset_font_settings
    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
 
  def strip_string(text)
    return text.sub!(/\[(.*)\]/, "")
  end
 
  def refresh
    self.height = TLB_MSG.rows_for_text * 32 + 32
    self.y = 480 - self.height - 16
    if @name_window != nil
      @name_window.y = self.y - 64
    end
    self.contents = Bitmap.new(self.width - 32, self.height - 32)
    self.contents.clear
    self.contents.font.color = normal_color
    x = y = 0
    y_override = nil
    outline = false
    shadow = false
    out_color = Color.new(0, 0, 0, 255)
    @cursor_width = 0
    # Indent if choice
    if $game_temp.choice_start == 0
      x = 8
    end
    # If waiting for a message to be displayed
    if $game_temp.message_text != nil
      text = $game_temp.message_text
      # Control text processing
      begin
        last_text = text.clone
        text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
      end until text == last_text
      # Change "\\\\" to "\000" for convenience
      text.gsub!(/\\\\/) { "\000" }
      text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
        $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
      end
      text.gsub!(/\\[Pp]\[([0-9]+)\]/) do
        $game_party.actors[$1.to_i] != nil ? $game_party.actors[$1.to_i].name : ""
      end
      text.gsub!(/\\[Gg]/) do
        $data_system.words.gold
      end
      text.gsub!(/\\ac\[(-?[0-9]+)\]/) do
        id = $1.to_i
        if id > 0 && $game_actors[id] != nil
          $data_classes[$game_actors[id].class_id].name
        elsif id <= 0 && $game_party.actors[-id] != nil
          $data_classes[$game_party.actors[-id].class_id].name
        else
          ""
        end
      end
      text.gsub!(/\\nc\[([0-9]+)\]/) do
        id = $1.to_i
        $data_classes[id] != nil ? $data_classes[id].name : ""
      end
      text.gsub!(/\\ni\[([0-9]+)\]/) do
        id = $1.to_i
        $data_items[id] != nil ? $data_items[id].name : ""
      end
      text.gsub!(/\\nw\[([0-9]+)\]/) do
        id = $1.to_i
        $data_weapons[id] != nil ? $data_weapons[id].name : ""
      end
      text.gsub!(/\\na\[([0-9]+)\]/) do
        id = $1.to_i
        $data_armors[id] != nil ? $data_armors[id].name : ""
      end
      text.gsub!(/\\ns\[([0-9]+)\]/) do
        id = $1.to_i
        $data_skills[id] != nil ? $data_skills[id].name : ""
      end
      text.gsub!(/\\nt\[([0-9]+)\]/) do
        id = $1.to_i
        $data_states[id] != nil ? $data_states[id].name : ""
      end
      # Change "\\C" to "\001" and "\\G" to "\002"
      text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
      text.gsub!(/\\\$/) { "\002" }
      text.gsub!(/\\[Ii]\[(.*)\]/) { "\003[#{$1}]" }
      text.gsub!(/\\\{/) { "\004" }
      text.gsub!(/\\\}/) { "\005" }
      text.gsub!(/\\n\<(.*)\>/) { "\006[#{$1}]" }
      text.gsub!(/\\nc\<(.*)\>/) { "\007[#{$1}]" }
      text.gsub!(/\\nr\<(.*)\>/) { "\010[#{$1}]" }
      text.gsub!(/\\px\[([0-9]+)\]/) { "\013[#{$1}]" }
      text.gsub!(/\\py\[([0-9]+)\]/) { "\014[#{$1}]" }
      text.gsub!(/\\pic\[(.*)\]/) { "\015[#{$1}]" }
      text.gsub!(/\\oc\[([0-9]+)\]/) { "\016[#{$1}]" }
      text.gsub!(/\\oo\[([0-9]+)\]/) { "\017[#{$1}]" }
      text.gsub!(/\\fr/) { "\020" }
      text.gsub!(/\\fz\[([0-9]+)\]/) { "\021[#{$1}]" }
      text.gsub!(/\\fn\[(.*)\]/) { "\022[#{$1}]" }
      text.gsub!(/\\fb/) { "\023" }
      text.gsub!(/\\fi/) { "\024" }
      text.gsub!(/\\fo/) { "\025" }
      text.gsub!(/\\fs/) { "\026" }
      text.gsub!(/\\ii\[([0-9]+)\]/) { "\027[#{$1}]" }
      text.gsub!(/\\iw\[([0-9]+)\]/) { "\030[#{$1}]" }
      text.gsub!(/\\ia\[([0-9]+)\]/) { "\031[#{$1}]" }
      text.gsub!(/\\is\[([0-9]+)\]/) { "\032[#{$1}]" }
      # Get 1 text character in c (loop until unable to get text)
      while ((c = text.slice!(/./m)) != nil)
        # If \\
        if c == "\000"
          # Return to original text
          c = "\\"
        end
        # If \C[n]
        if c == "\001"
          # 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
          # go to next text
          next
        end
        # If \G
        if c == "\002"
          # Make gold window
          if @gold_window == nil
            @gold_window = Window_Gold.new
            @gold_window.x = 560 - @gold_window.width
            if $game_temp.in_battle
              @gold_window.y = 192
            else
              @gold_window.y = self.y >= 128 ? 32 : 384
            end
            @gold_window.opacity = self.opacity
            @gold_window.back_opacity = self.back_opacity
          end
          # go to next text
          next
        end
        if c == "\003"
          text.sub!(/\[(.*)\]/, "")
          icon_name = $1.to_s
          bitmap = RPG::Cache.icon(icon_name)
          self.contents.blt(x, 32 * y + 4, bitmap, Rect.new(0, 0, 24, 24))
          x += 12
          next
        end
        if c == "\004"
          self.contents.font.size += 8 if self.contents.font.size <= 64
          next
        end
        if c == "\005"
          self.contents.font.size -= 8 if self.contents.font.size >= 16
          next
        end
        if c == "\006"
          text.sub!(/\[(.*)\]/, "")
          name_text = $1.to_s
          create_name_window(name_text, 0)
          next
        end
        if c == "\007"
          text.sub!(/\[(.*)\]/, "")
          name_text = $1.to_s
          create_name_window(name_text, 1)
          next
        end
        if c == "\010"
          text.sub!(/\[(.*)\]/, "")
          name_text = $1.to_s
          create_name_window(name_text, 2)
          next
        end
        if c == "\013"
          text.sub!(/\[([0-9]+)\]/, "")
          x = $1.to_i
          next
        end
        if c == "\014"
          text.sub!(/\[([0-9]+)\]/, "")
          y_override = $1.to_i
          next
        end
        if c == "\015"
          text.sub!(/\[(.*)\]/, "")
          bitmap = RPG::Cache.picture($1.to_s)
          cw = bitmap.width
          ch = bitmap.height
          src_rect = Rect.new(0, 0, cw, ch)
          self.contents.blt(x, y, bitmap, src_rect)
          next
        end
        if c == "\016"
          text.sub!(/\[([0-9]+)\]/, "")
          outline = true
          out_color = text_color($1.to_i)
          next
        end
        if c == "\017"
          text.sub!(/\[([0-9]+)\]/, "")
          outline = true
          out_color.alpha = $1.to_i
          next
        end
        if c == "\020"
          reset_font_settings
          outline = false
          shadow = false
          out_color = Color.new(0, 0, 0, 255)
          next
        end
        if c == "\021"
          text.sub!(/\[([0-9]+)\]/, "")
          self.contents.font.size = $1.to_i
          next
        end
        if c == "\022"
          text.sub!(/\[(.*)\]/, "")
          self.contents.font.name = $1.to_s
          next
        end
        if c == "\023"
          self.contents.font.bold = !self.contents.font.bold
          next
        end
        if c == "\024"
          self.contents.font.italic = !self.contents.font.italic
          next
        end
        if c == "\025"
          outline = !outline
          next
        end
        if c == "\026"
          shadow = !shadow
          next
        end
        if c == "\027"
          text.sub!(/\[([0-9]+)\]/, "")
          item = $data_items[$1.to_i]
          if item != nil
            bitmap = RPG::Cache.icon(item.icon_name)
            self.contents.blt(x, (y_override || (32 * y)) + 4, bitmap, Rect.new(0, 0, 24, 24))
            text = item.name + text
            x += 24
          end
          next
        end
        if c == "\030"
          text.sub!(/\[([0-9]+)\]/, "")
          item = $data_weapons[$1.to_i]
          if item != nil
            bitmap = RPG::Cache.icon(item.icon_name)
            self.contents.blt(x, (y_override || (32 * y)) + 4, bitmap, Rect.new(0, 0, 24, 24))
            text = item.name + text
            x += 24
          end
          next
        end
        if c == "\031"
          text.sub!(/\[([0-9]+)\]/, "")
          item = $data_armors[$1.to_i]
          if item != nil
            bitmap = RPG::Cache.icon(item.icon_name)
            self.contents.blt(x, (y_override || (32 * y)) + 4, bitmap, Rect.new(0, 0, 24, 24))
            text = item.name + text
            x += 24
          end
          next
        end
        if c == "\032"
          text.sub!(/\[([0-9]+)\]/, "")
          item = $data_skills[$1.to_i]
          if item != nil
            bitmap = RPG::Cache.icon(item.icon_name)
            self.contents.blt(x, (y_override || (32 * y)) + 4, bitmap, Rect.new(0, 0, 24, 24))
            text = item.name + text
            x += 24
          end
          next
        end
        # If new line text
        if c == "\n"
          # Update cursor width if choice
          if y >= $game_temp.choice_start
            @cursor_width = [@cursor_width, x].max
          end
          # Add 1 to y
          y += 1
          x = 0
          # Indent if choice
          if y >= $game_temp.choice_start
            x = 8
          end
          y_override += 32 if y_override
          # go to next text
          next
        end
        # Draw text
        if shadow
          color = self.contents.font.color.dup
          self.contents.font.color = Color.new(0, 0, 0)
          self.contents.draw_text(4 + x, (y_override || (32 * y)) + 1, 40, 32, c)
          self.contents.font.color = color
        end
        if outline
          color = self.contents.font.color.dup
          self.contents.font.color = out_color
          self.contents.draw_outline_text(4 + x, y_override || (32 * y), 40, 32, c)
          self.contents.font.color = color
        else
          self.contents.draw_text(4 + x, y_override || 32 * y, 40, 32, c)
        end
        # Add x to drawn text width
        x += self.contents.text_size(c).width
      end
    end
    # If choice
    if $game_temp.choice_max > 0
      @item_max = $game_temp.choice_max
      self.active = true
      self.index = 0
    end
    # If number input
    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
 
  alias :tlb_msg_update :update unless $@
  def update
    tlb_msg_update
    if !self.visible && @name_window != nil
      @name_window.dispose
      @name_window = nil
    end
  end
end

FAQ
None yet

Credit and Thanks
- Trihan
- Yanfly, for the message codes provided in the Ace Message System
Sorry for this necropost, but this is a great script. What are your terms of use for free/commercial projects?
Sorry for this necropost, but this is a great script. What are your terms of use for free/commercial projects?
You can freely use it in any kind of project. Attribution is appreciated, but not strictly necessary.
I was just wondering if there is a list or something of the basic commands, I'm more new to custom scripts in RMXP so i really don't know what I'm doing

nvm i found it

Original thread: https://forums.rpgmakerweb.com/threads/trilobytes-message-system-xp.145747/