累计送礼: 0 个 累计收礼: 1 个 TA的每日心情 开心 2026-7-12 04:10
签到天数: 209 天
连续签到: 2 天
[LV.7]常住居民III
管理员
VIP
7
卡币
27009
OK点
16
推广点
0
同能卷
50
积分 34404
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
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
本贴来自国际rpgmaker官方论坛作者:Trihan处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:
https://forums.rpgmakerweb.com/threads/trilobytes-message-system-xp.145747/
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x