RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Colour Coded Items

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
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.

Screenshots



Instructions

See header of the script

Script


Code: [Select]
#==============================================================================
#  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


  • modern algebra

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.
« Last Edit: September 17, 2011, 02:37:08 PM by modern algebra »

*****
Rep:
Level 88
Wait a minute... I'm a bit confused. Where exactly do you put the
Code: [Select]
\macolor[x]
My apologies if this sounds stupid. Do you put it directly into the item's name..?

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
No, in the notes box - I should've specificied that - thanks for letting me know I haven't.

*****
Rep:
Level 88
Ah, okay. Thanks. This is a pretty nice little add-on. Good job.

**
Rep:
Level 86
Nice :D

I like the way you wrote this script.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Hey wora, good to see you again! :)

And thanks for the compliment. It's always fun to try and find ways to modify graphical elements of the game without either redrawing or replacement drawing them :)

**
Rep:
Level 86
There are a lot of good scripts from you (and other scripters) here. I can't leave this place. >_>"


**
Rep:
Level 84
Quis custodiet ipsos custodes?
Great work, Modern. I've been here for maybe a week and I've come to recognize you for the scripting wizard you are. Mhmm. Very cool stuff. 

**
Rep: +0/-0Level 65
RMRK Junior
Hello, I'd like to first say this is a great script and thank you for sharing it with us.

But do you know how to make it so it works with the shop scene too?

So when I Sell to a shop I see the different colored weapons/items etc...
It seems to show the colored name when I buy from shop but not when I sell.

I really need this for my game, thanks!
« Last Edit: September 17, 2011, 12:51:00 AM by rpgmakerman »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Ermm, it should - in the default shop scene, the buy window uses the draw_item_name method and the sell window is a subclass of Window_Item and uses the same method as that.

Did you input the code correctly in the notebox for the items in question?

Otherwise, are you using another script which either modifies the shop scene or else affects the way items are drawn in any way?
« Last Edit: September 17, 2011, 01:23:17 AM by modern algebra »

**
Rep: +0/-0Level 65
RMRK Junior
Thanks for your response.

I did enter the code correctly... This is a bit strange.

I set the color to green...
The weapon color  is white when I see it in the "Sell Window" of a shop but when I  press the button to sell it, where you choose the quantity,  the color of the weapon changes back to green, so it only happens on that one window.

I'm using Yanfly's scripts, Item/Equipment overhaul, maybe this has something to do with it?

Thanks!


*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Yes. It definitely does, as would Battle Engine Melody. Add the following code into its own slot below the Item Overhaul script (and BEM, if you have it) but still somewhere above Main:

Code: [Select]
class Window_ItemData
  alias mayan_ioccipatch_drwname_7th1 draw_item_name
  def draw_item_name(*args)
    @ma_drawing_item = @item
    # Run Original Method
    result = mayan_ioccipatch_drwname_7th1 (*args)
    @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
    # Run Original Method
    yflyma_ioccicomp_objnm_8yh2 (obj, *args)
    @ma_drawing_item = nil
  end
end

if Window_Item.method_defined? (:draw_obj_name)
 
class Window_Item
  alias modyf_ioccocmpch_drwone_6gx4 draw_obj_name
  def draw_obj_name(obj, *args)
    @ma_drawing_item = obj
    # Run Original Method
    modyf_ioccocmpch_drwone_6gx4 (obj, *args)
    @ma_drawing_item = nil
  end
end

end

**
Rep: +0/-0Level 65
RMRK Junior
@modern algebra, you're a genius!!!
It all works great now, Thank you so much!! :)

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Most Missed Member2014 Zero to Hero2014 Best IRC Quote2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
Took a look at your code and noticed something odd in the REGEXP. Keeping in mind that I'm by far nowhere as experienced as you, at a glance I thought that this:
Code: [Select]
@ma_drawing_item.note[/\\MACOLOU*R\[([,\d\s]*?)\]/i]
should be this:
Code: [Select]
@ma_drawing_item.note[/\\MACOLOU?R\[([,\d\s]*?)\]/i]
And I figure that because I assume you put the asterisk there to suit both color and colour, whereas, to my knowledge, an asterisk denotes a character appearing once or more and a question mark denotes the character to appear either once or not at all.
"abc*" matches "abc", "abcc", "abccc", etc.
"abc?" matches "ab" or "abc".
But why am I telling you that, I'm sure it was either something missed by me or a simple overlooked mistake by you. I'm hoping for the former, and a lesson from you.
Alternatively, couldn't you also use
Code: [Select]
[/\\(MACOLOUR|MACOLOR)\[([,\d\s]*?)\]/i]
[/\\MACOL(OU|O)R\[([,\d\s]*?)\]/i]
Or am I being silly?
it's like a metaphor or something i don't know

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
No, you're right that the ? is better than the *. I wrote the script a long time ago. However, you're wrong that the * means >= 1. It matches for zero or more. So /abc*/ matches ab, abc, abcc, abccc, etc. It's the + that would match only one or more. /abc+/ would only match abc, abcc, abccc, etc.

The question mark would have been better though.

And yes, both of the alternative formations you mention would work, though I generally wouldn't use them where it's just a case of a wildcard letter. Personally, I think some scripters overuse alternations, though I suppose it doesn't make much of a difference. There would be more ways to accomplish it as well. For instance: /abc{0, 1}/ would match ab or abc as well. But the ? would definitely have been the best to use in this case. I just didn't know much about RegExp when I wrote this script.

It was also bad practice to force it to redo the calculations every time. It would be far better just to have a lazy instantiation inside the item class itself.
« Last Edit: September 17, 2011, 12:54:36 PM by modern algebra »

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Most Missed Member2014 Zero to Hero2014 Best IRC Quote2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
It's amazing that mistake hadn't been found yet. And I'll put that + and * ruling in my notes. I've taken up serious REGEXP, you see.
I'll return to my box now.
it's like a metaphor or something i don't know

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Alright, rewrote the script to support hex and be more efficient.

**
Rep: +0/-0Level 65
RMRK Junior
oh nice, :) do i still need that other little fix script you made, if i use this new rewritten one? Thanks!
« Last Edit: September 18, 2011, 01:24:36 AM by rpgmakerman »

**
Rep: +0/-0Level 67
RPGVX Advanced (I Do Not Script Tough)
Cool But..Isnt That Already Possible by Doing This

EX: /c(10)LongSword/c(0)

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Well, that code is actually \c[10]Long Sword\c[0] and yes, but it would only work in a message (unless you are using a script like my Global Text Codes, in which case it would work everywhere).

This script applies to other scenes also, however, so it would colour code the items or skills wherever they are drawn in the Menu scenes too.

**
Rep: +0/-0Level 67
RPGVX Advanced (I Do Not Script Tough)
Oh..
Ok then