Colour Coded Items/Weapons/Armors
Version: 2.0
Author: modern algebra
Date: September 17, 2011
Version History
- <Version 2.0> 2011.09.17 - More efficient, support for hex, and built-in capacity for some YEM scripts
- <Version 1.0> 2009.01.27 - Original Release
Description
This script allows you to set a special colour to any item, weapon or armor in the party's possession (also works for skills). SO, in scenes like Item, Equip, or Skill, these items/weapons/armors/skills would be drawn in whatever colour you specify.
Features
- Can set an individual colour for any item, weapon, or armor in the database
- Can set it either by windowskin palette, through RGB, or by hex code
- Easy configuration.
ScreenshotsInstructions See header of the script
Script
#==============================================================================
# Colour Coded Items/Weapons/Armors/Skills
# Version: 2.0
# Author: modern algebra (rmrk.net)
# Date: September 17, 2011
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
# This script allows you to set a special colour to any item, weapon or
# armor in the party's possession. SO, in scenes like Item or Equip, these
# items/weapons/armors would be drawn in whatever colour you specify
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Instructions:
# Place this above Main and below Materials in the Script Editor (F11)
#
# To set a colour to an item, put any of the following codes into the notes
# box of the item, weapon or armour:
#
# \color[x]
# \colour[x]
#
# where x is an integer from 0-31 : this will set it to the colour
# that corresponds to the square in the Windowskin palette. Or you can use
# the code:
#
# \color[r, g, b]
# \colour[r, g, b]
#
# where r is red, g is green, and b is blue. All of them must be between
# 0 and 255. Any colour you want can be made out of a combination of these
# colours. [0, 0, 0] is BLACK, and [255, 255, 255] is WHITE, [255, 0, 0] is
# RED, and etc... If you use this, the best way is to find the exact shade
# you want in a picture editor program like MS Paint, and then check the
# RGB of that colour.
#
# You can also use hex, like so:
#
# \color[#RRGGBB]
# \colour[#RRGGBB]
#
# RR is red, GG is the green, and BB is the blue. It accepts values from
# 0 (00) to 255 (FF) for each element. For a guide to hex and a converter,
# you can go to:
# http://www.statman.info/conversions/hexadecimal.html
#==============================================================================
$imported = {} unless $imported
$imported["MAColourCodedItems2"] = true
#==============================================================================
# ** RPG::BaseItem
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new method - ma_colour
#==============================================================================
class RPG::BaseItem
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * MA Colour
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def ma_colour
if !@ma_colour
if self.note[/\\(MA)?COLOU?R\s*\[\s*\#?([\dA-F]{6,6})\s*\]/i] != nil # HEX
# Convert hex code to 3 element array
@ma_colour = []
$2.scan (/../) { |hex| @ma_colour << hex.to_i (16) }
elsif self.note[/\\(MA)?COLOU?R\s*\[([,\d\s]*)\]/i] != nil
note, args = $2, []
# Compose array of colours
while args.size < 3 && note.sub! (/(\d+)/) { "" } do args << $1.to_i end
@ma_colour = case args.size
when 0, 2 then -1 # Use normal_color
when 1 then args[0] # Use text_color
when 3 then args # Make colour out of the array
end
else
@ma_colour = -1
end
end
return (@ma_colour != -1) ? @ma_colour : nil
end
end
#==============================================================================
# ** Window Base
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - normal_color, draw_item_name
#==============================================================================
class Window_Base
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Normal Color
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias ma_cci_normcol_5tc1 normal_color
def normal_color (*args)
# If drawing an item name from Draw Item Name
if @ma_drawing_item != nil
case @ma_drawing_item.ma_colour
when Fixnum
colour = text_color (@ma_drawing_item.ma_colour)
return colour if colour.alpha > 0 # Only use if color is visible
when Array
return Color.new (*@ma_drawing_item.ma_colour)
end
end
return ma_cci_normcol_5tc1 (*args)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Draw Item Name
# item : Item (skill, weapon, armor are also possible)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias malb_coloritm_drwnam_5tx1 draw_item_name
def draw_item_name(item, *args)
@ma_drawing_item = item
malb_coloritm_drwnam_5tx1 (item, *args) # Run Original Method
@ma_drawing_item = nil
end
end
#==============================================================================
# YEM Item Overhaul Compatibility Patch
#==============================================================================
if $imported["ItemOverhaul"]
class Window_ItemData
alias mayan_ioccipatch_drwname_7th1 draw_item_name
def draw_item_name(*args)
@ma_drawing_item = @item
result = mayan_ioccipatch_drwname_7th1 (*args) # Run Original Method
@ma_drawing_item = nil
return result
end
end
class Window_ItemList
alias yflyma_ioccicomp_objnm_8yh2 draw_obj_name
def draw_obj_name(obj, *args)
@ma_drawing_item = obj
yflyma_ioccicomp_objnm_8yh2 (obj, *args) # Run Original Method
@ma_drawing_item = nil
end
end
end
#==============================================================================
# YEM Battle Engine Melody Compatibility Patch
#==============================================================================
if $imported["BattleEngineMelody"]
class Window_Item
alias modyf_ioccocmpch_drwone_6gx4 draw_obj_name
def draw_obj_name(obj, *args)
@ma_drawing_item = obj
modyf_ioccocmpch_drwone_6gx4 (obj, *args) # Run Original Method
@ma_drawing_item = nil
end
end
end
#==============================================================================
# YEM Skill Overhaul Compatibility Patch
#==============================================================================
if $imported["SkillOverhaul"]
class Window_LearnSkill
alias malb_cciyso_drwobjname_3fg1 draw_obj_name
def draw_obj_name (obj, *args)
@ma_drawing_item = obj
malb_cciyso_drwobjname_3fg1 (obj, *args) # Run Original Method
@ma_drawing_item = nil
end
end
class Window_LearnData
alias mayfly_colcodeitm_drwobjct_5th1 draw_obj_name
def draw_obj_name (*args)
@ma_drawing_item = @skill
malb_cciyso_drwobjname_3fg1 (*args) # Run Original Method
@ma_drawing_item = nil
end
end
class Window_PassiveData
alias yflma_socci_drwnm_6cx3 draw_obj_name
def draw_obj_name (*args)
@ma_drawing_item = @passive
yflma_socci_drwnm_6cx3 (*args) # Run Original Method
@ma_drawing_item = nil
end
end
end
Credit
Thanks
- sasofrass, for the request
- Pacman, for making me ashamed of my past
Support
Please post here for the swiftest support
Known Compatibility Issues
Will not work with scripts that customize drawing item or skill names. It should work with YEM BEM, YEM Item Overhaul, and YEM Skill Overhaul however.