The base:
#===============================================================================
#
# Special Text
# Pacman, 19/8/2011
# Scripter's tool; converts special characters and returns the altered text.
# This is a simple script that provides methods for converting special
# characters in any text. It returns the variable ID for \v[ID], the actor with
# ID's name for \n[ID], changes the colour to ID for \c[ID], returns the party's
# gold for \g, returns \ for \\, returns the state with ID's name for \s[ID],
# returns the element with ID's name for \e[ID], and returns the class with ID's
# name for \cl[ID].
#
#===============================================================================
$imported = {} if $imported == nil; $imported["Pacman's Special Text"] = true
#==============================================================================
# ** Bitmap
#------------------------------------------------------------------------------
# The bitmap class. Bitmaps are expressions of so-called graphics. Sprites
# (Sprite) and other objects must be used to display bitmaps on the screen.
#==============================================================================
class Bitmap
#--------------------------------------------------------------------------
# * Create dummy window
#--------------------------------------------------------------------------
@@_dummy_window = Window_Base.new(-64, -64, 64, 64) # Class variable.
@@_dummy_window.visible = false # Invisible.
#--------------------------------------------------------------------------
# ? Format specification character drawing
#--------------------------------------------------------------------------
def draw_special_text(x, y, width, height, text, align = 0)
string = convert_special_characters(text)
dx = 0
buf = Bitmap.new(Graphics.width * 2, Window_Base::WLH)
buf.font = self.font.clone
loop {
c = string.slice!(/./m)
case c
when nil
break
when "\x01"
string.sub!(/\[([0-9]+)\]/, "")
buf.font.color = @@_dummy_window.text_color($1.to_i)
next
else
buf.draw_text(dx, 0, 40, Window_Base::WLH, c)
c_width = buf.text_size(c).width
dx += c_width
end
}
self.font = buf.font.clone
dest = Rect.new(x, y, [width, dx].min, height)
src = Rect.new(0, 0, dx, Window_Base::WLH)
offset = width - dx
case align
when 1 # Center justification
dest.x += offset / 2
when 2 # Right justification
dest.x += offset
end
stretch_blt(dest, buf, src)
buf.dispose
end
#--------------------------------------------------------------------------
# * Conversion of Special Characters to their Expected Expression
#--------------------------------------------------------------------------
def convert_special_characters(string)
x = string.dup
x.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
x.gsub!(/\\N\[([0-9]+)\]/i) { $game_actors[$1.to_i].name }
x.gsub!(/\\C\[([0-9]+)\]/i) { "\x01[#{$1}]" }
x.gsub!(/\\G/) { $game_party.gold }
x.gsub!(/\\\\/) { "\\" }
x.gsub!(/\\s\[(\d+)\]/i) { $data_states[$1.to_i].name
x.gsub!(/\\e\[(\d+)\]/i) { $data_elements[$1.to_i].name }
x.gsub!(/\\cl\[(\d+)\]/i) { $data_classes[$1.to_i].name }
return x
end
end
The actual script:
#===============================================================================
#
# Advanced Description
# Pacman, 19/8/2011
# Allows for more rows in the description boxes. Use the | key (above backslash)
# to add a row, and configure the script below.
# Also provides for normal message box codes to be used in description boxes.
# REQUIRES AND MUST BE INSERTED BELOW SPECIAL TEXT
#
#===============================================================================
# Begin Editing
#===============================================================================
module AdvDesc
# Maximum number of rows the help window displays.
MAXIMUM_ROWS = 2
# Button used to scroll the status window of the shop scene.
SCROLL_BUTTON = Input::X
end
#===============================================================================
# End Editing
#===============================================================================
$imported = {} if $imported == nil
$imported["Advanced Description"] = true
#==============================================================================
# ** Window_Help
#------------------------------------------------------------------------------
# This window shows skill and item explanations along with actor status.
#==============================================================================
class Window_Help < Window_Base
#--------------------------------------------------------------------------
# Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :max_rows
#--------------------------------------------------------------------------
# Alias listing
#--------------------------------------------------------------------------
alias advdesc_initialize initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@max_rows = 1
advdesc_initialize
end
#--------------------------------------------------------------------------
# * Change number of rows
#--------------------------------------------------------------------------
def max_rows=(n)
@max_rows = [n, 1].max
h = (WLH * @max_rows) + 32; self.height = h
create_contents
text, align = @text, @align
@text = @align = nil
set_text(text, align)
end
#--------------------------------------------------------------------------
# * Set Text
# text : character string displayed in window
# align : alignment (0..flush left, 1..center, 2..flush right)
#--------------------------------------------------------------------------
def set_text(text, align = 0)
if text != @text or align != @align
self.contents.clear
self.contents.font.color = normal_color
font_temp = self.contents.font.clone
temp = text.gsub(/\\N(\[\d+\])/i) { "\\__#{$1}" }
lines = temp.split(/(?:[|]|\\n)/i)
lines.each_with_index { |l, i|
l.gsub!(/\\__(\[\d+\])/i) { "\\N#{$1}" }
self.contents.draw_special_text(4, i * WLH, self.width - 40, WLH, l,
align)
}
self.contents.font = font_temp
@text, @align = text, align
end
end
end
#==============================================================================
# ** Scene_Item
#------------------------------------------------------------------------------
# This class performs the item screen processing.
#==============================================================================
class Scene_Item < Scene_Base
#--------------------------------------------------------------------------
# Alias listing
#--------------------------------------------------------------------------
alias advdesc_start start
#--------------------------------------------------------------------------
# * Start Processing
#--------------------------------------------------------------------------
def start
advdesc_start
change_windows_size
end
#--------------------------------------------------------------------------
# * Change Size of Windows
#--------------------------------------------------------------------------
def change_windows_size
@help_window.max_rows = AdvDesc::MAXIMUM_ROWS
@item_window.y = @help_window.height
@item_window.height = Graphics.height - @help_window.height
@item_window.refresh
end
end
#==============================================================================
# ** Scene_Skill
#------------------------------------------------------------------------------
# This class performs the skill screen processing.
#==============================================================================
class Scene_Skill < Scene_Base
#--------------------------------------------------------------------------
# Alias listing
#--------------------------------------------------------------------------
alias advdesc_start start
#--------------------------------------------------------------------------
# * Start Processing
#--------------------------------------------------------------------------
def start
advdesc_start
change_windows_size
end
#--------------------------------------------------------------------------
# * Change Size of Windows
#--------------------------------------------------------------------------
def change_windows_size
@help_window.max_rows = AdvDesc::MAXIMUM_ROWS
@status_window.y = @help_window.height
dy = @help_window.height + @status_window.height
@skill_window.y = dy
@skill_window.height = Graphics.height - dy
@skill_window.refresh
end
end
#==============================================================================
# ** Scene_Equip
#------------------------------------------------------------------------------
# This class performs the equipment screen processing.
#==============================================================================
class Scene_Equip < Scene_Base
#--------------------------------------------------------------------------
# Alias listing
#--------------------------------------------------------------------------
alias advdesc_start start
#--------------------------------------------------------------------------
# * Start Processing
#--------------------------------------------------------------------------
def start
advdesc_start
change_windows_size
end
#--------------------------------------------------------------------------
# * Change Size of Windows
#--------------------------------------------------------------------------
def change_windows_size
@help_window.max_rows = AdvDesc::MAXIMUM_ROWS
@equip_window.y = @help_window.height
@status_window.y = @help_window.height
change_item_windows_size
end
#--------------------------------------------------------------------------
# * Change Size of Item Windows
#--------------------------------------------------------------------------
def change_item_windows_size
@item_windows.each { |w|
dy = @help_window.height + @equip_window.height
w.y = dy
w.height = Graphics.height - dy
w.refresh
}
end
end
#==============================================================================
# ** Scene_Shop
#------------------------------------------------------------------------------
# This class performs shop screen processing.
#==============================================================================
class Scene_Shop < Scene_Base
#--------------------------------------------------------------------------
# Alias listing
#--------------------------------------------------------------------------
alias advdesc_start start
alias advdesc_update update
#--------------------------------------------------------------------------
# * Start Processing
#--------------------------------------------------------------------------
def start
advdesc_start
change_windows_size
end
#--------------------------------------------------------------------------
# * Change Size of Windows
#--------------------------------------------------------------------------
def change_windows_size
@help_window.max_rows = AdvDesc::MAXIMUM_ROWS
@command_window.y = @help_window.height
@gold_window.y = @help_window.height
dy = @help_window.height + @command_window.height
@dummy_window.y = @buy_window.y = @sell_window.y =
@number_window.y = @status_window.y = dy
@dummy_window.height = @buy_window.height =
@sell_window.height = @number_window.height =
@status_window.height = Graphics.height - dy
@dummy_window.create_contents
@number_window.create_contents
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
if !@command_window.active &&
Input.press?(AdvDesc::SCROLL_BUTTON)
super
update_menu_background
update_scroll_status
return
else
@status_window.cursor_rect.empty
end
advdesc_update
end
#--------------------------------------------------------------------------
# * Update Status of Scrolling
#--------------------------------------------------------------------------
def update_scroll_status
@status_window.cursor_rect.width = @status_window.contents.width
@status_window.cursor_rect.height = @status_window.height - 32
@status_window.update
if Input.press?(Input::UP)
@status_window.oy = [@status_window.oy - 4, 0].max
elsif Input.press?(Input::DOWN)
max_pos = [@status_window.contents.height -
(@status_window.height - 32), 0].max
@status_window.oy = [@status_window.oy + 4, max_pos].min
end
end
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# Alias listing
#--------------------------------------------------------------------------
alias advdesc_start_skill_selection start_skill_selection
alias advdesc_start_item_selection start_item_selection
#--------------------------------------------------------------------------
# * Start Skill Selection
#--------------------------------------------------------------------------
def start_skill_selection
advdesc_start_skill_selection
change_skill_window_size
end
#--------------------------------------------------------------------------
# * Change Size of Skill Window
#--------------------------------------------------------------------------
def change_skill_window_size
@help_window.row_max = AdvDesc::MAXIMUM_ROWS
@skill_window.y = @help_window.height
@skill_window.height = Graphics.height - (@help_window.height +
@status_window.height)
@skill_window.refresh
end
#--------------------------------------------------------------------------
# * Start Item Selection
#--------------------------------------------------------------------------
def start_item_selection
advdesc_start_item_selection
change_item_window_size
end
#--------------------------------------------------------------------------
# * Change Size of Item Window
#--------------------------------------------------------------------------
def change_item_window_size
@help_window.max_rows = AdvDesc::MAXIMUM_ROWS
@item_window.y = @help_window.height
@item_window.height = Graphics.height - (@help_window.height +
@status_window.height)
@item_window.refresh
end
end
Give some credit to KGC, I based this off of his scripts.