Need help modifying this script I found (RMXP)

I wanted a script that you can use the \c[#] tags in item descriptions to change the color, and I found one. The problem is, it only works with 1 \c[#] tag.

So if I write in the description:

"\c[7] Req Lv.5 \c[0] This sword is a fancy one!"

I will get:

"Req Lv.5 \c[0] This sword is a fancy one!" all in gray, when I just wanted "Req Lv.5" in gray.

Code:
#---------------------------------------------------------------------------## Control Characters work for object descriptions & names.# Actor, Class, Items, Weapons, Armors, Skills, Enemies# Valid Control Characters: \V[n], \N[n], \C[n]## 12Feb09 - Brew  (ref: RRR_supt)#---------------------------------------------------------------------------class Bitmap  alias draw_parsed_text draw_text  def draw_text(*args)     #parse the text    if args[0].is_a?(Rect)      x = args[0].x      y = args[0].y      width = args[0].width      height = args[0].height      str = args[1]      align = args[2] != nil ? args[2] : 0    else      x = args[0]      y = args[1]      width = args[2]      height = args[3]      str = args[4]      align = args[5] != nil ? args[5] : 0    end    # If waiting for a message to be displayed    if str != nil      text = str.clone      # Control text processing      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      # Change "\\C" to "\001" and "\\G" to "\002"      text.sub!(/\\[Cc]\[([0-9]+)\]/, "")      color = $1.to_i      if color >= 0 and color <= 7 and font.color == text_color(0)        font.color = text_color(color)      end    end    draw_parsed_text(x, y, width, height, text, align)  end  #--------------------------------------------------------------------------  # * Get Text Color  #     n : text color number (0-7)  #--------------------------------------------------------------------------  def text_color(n)    case n    when 0      return Color.new(255, 255, 255, 255)    when 1      return Color.new(128, 128, 255, 255)    when 2      return Color.new(255, 128, 128, 255)    when 3      return Color.new(128, 255, 128, 255)    when 4      return Color.new(128, 255, 255, 255)    when 5      return Color.new(255, 128, 255, 255)    when 6      return Color.new(255, 255, 128, 255)    when 7      return Color.new(192, 192, 192, 255)    else      return Color.new(255, 255, 255, 255)    end  endend
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.

That's not the right place to do the color substitution.

If you put this:

Req Lv.5 This \c[7]sword\c[0] is a fancy one!

I think you would still find that all of the text would be grey.

What it's doing is looking for ANY color change in the text and if it finds one, it changes the text to that color BEFORE it starts showing anything.

The substitution line is not doing what the comment says it's going to do:

# Change "\\C" to "\001" and "\\G" to "\002" text.sub!(/\\[Cc]\[([0-9]+)\]/, "")Clearly Brew (or you, if you've attempted to change the script) has tried to implement some of CCOA's UMS (without giving credit), changed it, and not catered for the change properly.That is not the method where the color change should occur - that would actually happen in draw_parsed_text
Sorry for posting in the wrong forum. And I didnt change anything, this was all done by Brew.

So, this script doesn't do what I want?
I would go back to the place you found the script, because if that's just the way he did it, then other people would have the same problem. There might be a fix for it in the comments on the thread/blog.


In fact, I'm surprised you even need that, because XP allows you to change colours by default. Colours, variables and names of actors are already there. I don't see anything in that bit of script above that is any different to XP's default behaviour. And I don't see anything in there about interpreting control characters for Actor, Class, Items, Weapons, Armors, Skills, Enemies, which appears to be why he's written the script. I wonder if he's attempting to do, in the Bitmap class, what Window_Base already does.


It doesn't seem to do what he claims it does, which means either a lot of people would be complaining about it, or it's a script he's started on and shared, and never finished off.


Edit: I was wrong - he's not basing it off CCOA's script - he's just pulling code from Window_Message, but not considering that that class processes text one letter at a time, and has not brought across that letter-at-a-time processing into his script.
The script is for using colors in item descriptions, not just in plain texts in events.

http://www.neoseeker.com/forums/22121/t1315807-item-name-colors/

The person seems to have no problems with it.
Alright - I see what's going on.


The request was "change the color of an item in the inventory screen" which is NOT the same as "make \C[n] work for item names in the inventory screen"


That script fills the request - it lets you change the color of an item in the inventory screen. It does NOT let you change colors back and forth like you can in a text box, which is what you're trying to do.


You will need a different script.
Can this script be easily modified to check all \c[n] tags on an item, or does that require a complete different script? This was the closest script I found 🙁
It could be modified to behave the same way Show Text behaves. Or Window_Base's draw_item_name method could be rewritten to behave like Show Text.
K

Original thread: https://forums.rpgmakerweb.com/threads/need-help-modifying-this-script-i-found-rmxp.37198/