Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

> Rolpege's Auto Colored Words
Rolpege
post Aug 25 2010, 10:01 AM
Post #1


Level 1
Group Icon

Group: Member
Posts: 8
Type: Scripter
RM Skill: Undisclosed




Rolpege's Auto Colored Words

Version: 1.00
Author: Rolpege
Release Date: 25/08/2010 (DD/MM/YYYY)

Introduction
This 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.


Script
CODE
#====================================================================
==========
# ** 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


Customization
Configure DEFAULT_ROLPEGE_ACW as you like.

Compatibility
It 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.

Screenshots
Screenshots





DEMO
Attached File  AutoColored_Words.zip ( 191.2K ) Number of downloads: 30


Installation
Paste above main.

FAQ
Anything 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.


Credits
Rolpege for the script.
Thanks to Slipknot's tutorial for the idea.

This post has been edited by Rolpege: Aug 25 2010, 10:11 AM


__________________________
Go to the top of the page
 
+Quote Post
   

Posts in this topic
- Rolpege   Rolpege's Auto Colored Words   Aug 25 2010, 10:01 AM


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 18th May 2013 - 04:04 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker