Rolpege's Auto Colored Words
Version: 1.00
Author: Rolpege
Release Date: 25/08/2010 (DD/MM/YYYY)
IntroductionThis script will autocolor every word in every message in your game following a list of the words you want to color and they color.
Features- Customizable list of words.
- Colors every message.
- Includes two modes:
- Basic usage: for pasting script, changing the list of words and make it work.
- Advanced usage: for people that knows what they do.
ScriptCODE
#====================================================================
==========
# ** Rolpege's AutoColored Words
#------------------------------------------------------------------------------
# RMXP
# by Rolpege
# Version 1.00
# Last updated: 25/08/2010 (DD/MM/YYYY)
# Thanks to: Slipknot's AutoColored Words tutorial for the idea
#------------------------------------------------------------------------------
# License:
#
# * You DON'T HAVE to credit me, but you CAN.
# * You MUST ask me to publish this script in other forums.
# * You MUST tell me if you publish an 'open' game with this script. (but not
# ask permission)
# * You CAN publish 'closed' commercial games using it.
# * You MUST ask to publish 'open' commercial games using it.
# * You CAN'T sell this script.
#------------------------------------------------------------------------------
# Usage:
#
# Basic usage:
# * Configure DEFAULT_ROLPEGE_ACW as you like.
# * If you have problems with a custom message system, ask me.
#
# Advanced usage:
# Functions:
# * Rolpege::AutoColoredWords.parse!([options]):
# Will parse $game_temp.message_text.
# Options is an optional hash of options. DEFAULT_ROLPEGE_ACW
# will be used if no hash is given.
#
# * Rolpege::AutoColoredWords.parse_text(text[, options]):
# Will parse and return text.
# Options is an optional hash of options. DEFAULT_ROLPEGE_ACW
# will be used if no hash is given.
#
# Options:
# {
# # A hash of autocolored words. This format: 'word' => color number
# :words => {'word1' => 2, 'word2' => 3},
# # A hash of autocolored regular expersions. Using this format:
# /regexp/ => color number
# :regexps => {/(regexp1)/ => 2, /(regexp2)/ => 4},
# # Pluralizes the words in :words (for example, if we put sword,
# swords will match too.)
# :pluralize_words => true,
# # Makes :words case insensitive (for example, if we put sword,
# Sword will match too.)
# :case_insensitive => true,
# }
#
# Constants:
# DEFAULT_ROLPEGE_ACW: Default options.
# ROLPEGE_ACW_ALIAS: Alias Window_Message to call parse! automatically.
#
#==============================================================================
DEFAULT_ROLPEGE_ACW = {
#Usage: 'word' => color_number. Word SHOULD be downcased and not pluralized.
:words => {
'rolpege' => 2,
'sacred' => 3,
'crystal' => 1
}
}
ROLPEGE_ACW_ALIAS = true
module Rolpege
module AutoColoredWords
module_function
def parse!(options=DEFAULT_ROLPEGE_ACW)
text = $game_temp.message_text
begin
last_text = text.clone
text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
end until text == last_text
text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
$game_temp.message_text = parse_text(text, options)
end
def parse_text(text, options=DEFAULT_ROLPEGE_ACW)
options = {
:pluralize_words => true,
:case_insensitive => true
}.merge(options)
regexps = {}
options[:words].each do |word, color|
word = '(' + word
word << 's?' if options[:pluralize_words]
word << ')'
if options[:case_insensitive]
word = Regexp.new(word, true)
else
word = Regexp.new(word)
end
regexps[word] = color
end
regexps.merge!(options[:regexps]) if options[:regexps]
regexps.each do |regexp, color|
text.gsub!(regexp) { "\\c[#{color}]#{$1}\\c[0]" }
end
return text
end
end
end
if ROLPEGE_ACW_ALIAS
class Window_Message
alias rolpege_acw_window_message_refresh refresh
def refresh
Rolpege::AutoColoredWords.parse!
rolpege_acw_window_message_refresh
end
end
end
CustomizationConfigure DEFAULT_ROLPEGE_ACW as you like.
CompatibilityIt shouldn't give problems with any script
EXCEPT for custom message system.
If the script doesn't work with your custom message system, tell me here and I'll help you to integrate with it.
ScreenshotsDEMO
AutoColored_Words.zip ( 191.2K )
Number of downloads: 30InstallationPaste above main.
FAQAnything at the moment.
Terms and Conditions- You DON'T HAVE to credit me, but you CAN.
- You MUST ask me to publish this script in other forums.
- You MUST tell me if you publish an 'open' game with this script. (but not necessary to ask permission).
- You CAN publish 'closed' commercial games using it.
- You MUST ask to publish 'open' commercial games using it.
- You CAN'T sell this script.
CreditsRolpege for the script.
Thanks to
Slipknot's tutorial for the idea.
This post has been edited by Rolpege: Aug 25 2010, 10:11 AM