MV Plug-in: Colors not reverting to 'white' after using \c

Hey there,

TLDR: I am using SumRndmDde's plug-in: Custom colors. In order to use a bunch more colors than just the 31. However, in my project I format coloring in text boxes as follows: "This is a random sentence, \c[10]RED\c and back to white again." However, with this plug-in, the \c doesn't seem to work anymore and revert to a non-existent color instead (black).

Does anyone know if there is a fix for this? (Or perhaps a different MV plug-in to increase the number of colors?)

Details:

I used this in a clean project, there are no other plug-ins at play (except for trying SRD_GameUpgrade in case it was a required plug-in, but it didn't change anything).

Here's the issue shown in a single text box:

Problem Im1.png


As you can see in the third line, the text reverts to this 'black' color (same as what you would get if you call for a /c that doesn't exist, like \c[120]). Meaning, I cannot use a different color for just 1 word and then use \c to clear it and use the 'regular' font for the rest of the text box. Problem being: That is how ALL my text is formatted (which I think is normal?).

I considered that maybe it was calling to a different color than the default, so within this plug-in I changed ALL the other collors to white. As such:
Problem Im2.png


However, the same problem occured.
Here is also a view of how I made that first chatbox, in case you suspect there is a mistake there:
Problem Im3.png

The weirdest thing: In the preview it DOES show up correctly, and even that third line is white. But in the game itself it doesn not do that.

Furthermore! If I go to the Dev's Youtube tutorial, they never actually use \c themselves. They just call for a new color over and over. I contacted them on their website but did not get a reply yet.


Is this a known issue that I stumbled upon, a design-choice or perhaps an oversight? Furthermore, do you have any suggestions on how to fix this?
Try \c[0] instead.

\c[x] is designed to be used with the [x] part, to specify a colour index. The core scripts have a safety check that uses colour 0 if no index is provided; I guess SRD's plugin skips that check.
Try \c[0] instead.

\c[x] is designed to be used with the [x] part, to specify a colour index. The core scripts have a safety check that uses colour 0 if no index is provided; I guess SRD's plugin skips that check.

Thanks for your reply.

Well, in the 4th line of the example I used \c[0]. But that would only work if I call back to \c[0] after EVERY color change that I make. Which would mean I have to change that in every single line of text so far.
Which would mean I have to change that in every single line of text so far.
If you have a text editor with regex text replacing, you can just find-and-replace \\c(?!\[) with \c[0] in all your map files to do all of them at once. Assuming you don't have any other text codes that start with \c. Ofc do back up those first just in case.
I think it may be worth using \\\\c(?!\[) (or \\\\c[^[]) instead? Because backslashes are escaped in JSON, then escaped again in regex.

Alternatively, I checked the plugin code and I think I see the problem. After this line:
JavaScript:
  Window_Base.prototype.textColor = function(n) {
...try adding this as a new line (untested):
JavaScript:
    if (typeof n !== "number") return _.default;
I would also not recommend using the plugin command, because it doesn't seem to include the changes in save data or revert them on new game.
I think you may need to use \\\\c(?!\[) or \\\\c[^[] instead? Because backslashes are escaped in JSON, then escaped again in regex.
Ah, that's true, they are indeed stores as strings, so we'd need four backslashes in total (as a side note, I didn't do \\\\c[^[] because that might remove other characters if they are placed immediately after \c).

Though if the plugin's code can be changed this easily it's probably the better approach anyway, since it won't cause any changes to existing workflow.
I think it may be worth using \\\\c(?!\[) (or \\\\c[^[]) instead? Because backslashes are escaped in JSON, then escaped again in regex.

Alternatively, I checked the plugin code and I think I see the problem. After this line:
JavaScript:
  Window_Base.prototype.textColor = function(n) {
...try adding this as a new line (untested):
JavaScript:
    if (typeof n !== "number") return _.default;
I would also not recommend using the plugin command, because it doesn't seem to include the changes in save data or revert them on new game.


Looks like this worked like a charm! Thank you so much!
That line seemed to be the problem indeed.

Ah, that's true, they are indeed stores as strings, so we'd need four backslashes in total (as a side note, I didn't do \\\\c[^[] because that might remove other characters if they are placed immediately after \c).

Though if the plugin's code can be changed this easily it's probably the better approach anyway, since it won't cause any changes to existing workflow.

Thanks for your replies as well! The suggested adjustment to the code worked.
.

Original thread: https://forums.rpgmakerweb.com/threads/plug-in-colors-not-reverting-to-white-after-using-c.165652/