Character's Textbox
Version 1.0
by Woratana
Release Date: 21/05/2008
Introduction
This script will create the text box for each character (Player and events).
You can set and remove text for each character by call script.
You can also set SE for textbox, and change textbox properties (Position / Opacity / Windowskin).
Features
Version 1.0
- Show Textbox above character (Player and/or Event)
- Change textbox's opacity and position (in script)
- Choose to use sound effect when show textbox (in script)
Screenshots
http://i32.tinypic.com/20igw8y.jpg[/img]
Script
Place it above main
http://i28.tinypic.com/25thhqt.jpg[/img]
[codebox]
[/codebox]
Instruction
- Setup script in the SETUP part
- There is instruction in the script
1. Setup this script in SETUP part below
2. To set text to character's textbox, call script:
* character: What character you want to set this text?
** -1 for 'Player', 0 for 'This Event', and 1 or more for Event ID
* new_text: What is the text you want to show?
** write text in 'text here' or "text here"
For example:
* Script above will show text 'Hello!' over event ID 10.
3. To clear textbox, call script:
Author's Notes
Free for use in your work if credit is included.
Please do not redistribute this script without permission. If you want to post it on any forum, please link to this topic.
Bug Report?
Please give me these informations:
Version 1.0
by Woratana
Release Date: 21/05/2008
Introduction
This script will create the text box for each character (Player and events).
You can set and remove text for each character by call script.
You can also set SE for textbox, and change textbox properties (Position / Opacity / Windowskin).
Features
Version 1.0
- Show Textbox above character (Player and/or Event)
- Change textbox's opacity and position (in script)
- Choose to use sound effect when show textbox (in script)
Screenshots
http://i32.tinypic.com/20igw8y.jpg[/img]
Script
Place it above main
http://i28.tinypic.com/25thhqt.jpg[/img]
[codebox]
Code:
#===============================================================
# ● [VX] ◦ Character's Textbox ◦ □
# * Show textbox above character *
#--------------------------------------------------------------
# ◦ by Woratana [woratana@hotmail.com]
# ◦ Thaiware RPG Maker Community
# ◦ Released on: 21/05/2008
# ◦ Version: 1.0
#--------------------------------------------------------------
#==================================================================
# ** FEATURES **
#-----------------------------------------------------------------
# - Show Textbox above character (Player and/or Event)
# - Change textbox's opacity and position (in script)
# - Choose to use sound effect when show textbox (in script)
#==================================================================
# ** HOW TO USE **
# * use event command 'Script...' for the any script line below~
#-----------------------------------------------------------------
# 1. Setup this script in SETUP part below
# 2. To set text to character's textbox, call script:
# set_text(character, new_text)
#
# * character: What character you want to set this text?
# ** -1 for 'Player', 0 for 'This Event', and 1 or more for Event ID
# * new_text: What is the text you want to show?
# ** write text in 'text here' or "text here"
# For example:
# set_text(10,'Hello!')
# * Script above will show text 'Hello!' over event ID 10.
#
# 3. To clear textbox, call script:
# set_text(character, '')
#==================================================================
module Wora_CTB
#================================================================
# ** [START] Character's Overhead Textbox SETUP
#----------------------------------------------------------------
SAVE_TEXT = true # Save text in textbox~? (true or false)
# If save, old text will show when you teleport back to that map~
TEXTBOX_SKIN = 'Window' # Textbox windowskin file name, from folder 'System'
TEXTBOX_OPACITY = 0 # Textbox Opacity (0 - 255)
TEXTBOX_X_OFFSET = 0 # Move textbox horizontally (+ or -)
TEXTBOX_Y_OFFSET = -1 # Move textbox vertically (+ or -)
TEXTBOX_POPSOUND_MODE = 2 # SE (Sound Effect) to play when the textbox appear,
# or change text~
# 0 for no sound, 1 for use sound when textbox first appear,
# & 2 for use sound when textbox first appear and change text
TEXTBOX_POPSOUND = 'Decision1' # SE file name
TEXTBOX_POPSOUND_VOLUME = 80 # SE volume
TEXTBOX_POPSOUND_PITCH = 100 # SE pitch
#----------------------------------------------------------------
# ** [END] Character's Overhead Textbox SETUP
#================================================================
end
$worale = {} if $worale.nil?
$worale['Chartbox'] = true
class Game_Interpreter
def set_text(evid, new_text)
target = get_character(evid)
target.text = new_text
end
end
class Sprite_Character < Sprite_Base
alias wora_chartbox_sprcha_upd update
alias wora_chartbox_sprcha_dis dispose
def update
wora_chartbox_sprcha_upd
@chartext = '' if @chartext.nil?
if @character.text != @chartext # If there is new text
@chartext = @character.text
$game_system.chartbox = {} if $game_system.chartbox.nil?
case @character.class
when Game_Player; char_id = -1
when Game_Event; char_id = @character.id
end
# Save new text
$game_system.chartbox[[$game_map.map_id, char_id]] = @chartext
if @chartext == '' # If new text is empty? ('')
@textbox.visible = false if !@textbox.nil?
else # If new text is not empty~ change text
if @textbox.nil?
@textbox = Window_CharTBox.new
RPG::SE.new(Wora_CTB::TEXTBOX_POPSOUND, Wora_CTB::TEXTBOX_POPSOUND_VOLUME,
Wora_CTB::TEXTBOX_POPSOUND_PITCH).play if Wora_CTB::TEXTBOX_POPSOUND_MODE > 0
else
RPG::SE.new(Wora_CTB::TEXTBOX_POPSOUND, Wora_CTB::TEXTBOX_POPSOUND_VOLUME,
Wora_CTB::TEXTBOX_POPSOUND_PITCH).play if Wora_CTB::TEXTBOX_POPSOUND_MODE == 2
end
@textbox.set_text(@chartext)
@textbox.visible = true
end
end
if @chartext != ''
@textbox.x = self.x - (@textbox.width / 2) + Wora_CTB::TEXTBOX_X_OFFSET
@textbox.y = self.y - self.oy - @textbox.height + Wora_CTB::TEXTBOX_Y_OFFSET
end
end
def dispose
@textbox.dispose if !@textbox.nil?
wora_chartbox_sprcha_dis
end
end
class Game_Character
attr_accessor :text
alias wora_chartbox_gamcha_ini initialize
def initialize(*args)
wora_chartbox_gamcha_ini(*args)
$game_system.chartbox = {} if $game_system.chartbox.nil?
case self.class
when Game_Player
my_text = $game_system.chartbox[[$game_map.map_id, -1]] if
!$game_system.chartbox[[$game_map.map_id, -1]].nil?
when Game_Event
my_text = $game_system.chartbox[[$game_map.map_id, @id]] if
!$game_system.chartbox[[$game_map.map_id, @id]].nil?
end
@text = my_text.nil? ? '' : my_text
end
end
class Game_System
attr_accessor :chartbox
end
unless Wora_CTB::SAVE_TEXT
class Game_Interpreter
alias wora_chartbox_gamint_com201 command_201 unless $@
def command_201
if $game_map.fog_reset
if @params[0] == 0; id_map = @params[1]
else; id_map = $game_variables[@params[1]]
end
$game_system.chartbox = {} if id_map != @map_id
end
wora_chartbox_gamint_com201
end
end
end
#===============================================================
# Window_CharTBox: Edited version of Window_Help
#===============================================================
class Window_CharTBox < Window_Base
def initialize(x = 0, y = 0, w = 66, h = WLH+32)
super(x,y,w,h)
self.windowskin = Cache.system(Wora_CTB::TEXTBOX_SKIN)
self.opacity = Wora_CTB::TEXTBOX_OPACITY
end
def set_text(text)
if text != @text
text_w = self.contents.text_size(text).width
self.width = text_w + 32
create_contents
self.contents.font.color = normal_color
self.contents.draw_text(0, 0, self.contents.width, WLH, text, 1)
@text = text
end
end
end
#==================================================================
# [END] VX Character Textbox by Woratana [woratana@hotmail.com]
#==================================================================
Instruction
- Setup script in the SETUP part
- There is instruction in the script
1. Setup this script in SETUP part below
2. To set text to character's textbox, call script:
Code:
set_text(character, new_text)
* character: What character you want to set this text?
** -1 for 'Player', 0 for 'This Event', and 1 or more for Event ID
* new_text: What is the text you want to show?
** write text in 'text here' or "text here"
For example:
Code:
set_text(10,'Hello!')
3. To clear textbox, call script:
Code:
set_text(character, '')
Author's Notes
Free for use in your work if credit is included.
Please do not redistribute this script without permission. If you want to post it on any forum, please link to this topic.
Bug Report?
Please give me these informations:
- What is it says in error window?
- When is it get error? (Right after run game, when you choose something, etc.)
- What have you changed in setting part?
- Do you have any other scripts running in your game that may crash with this script?