[SOLVED] Color string u'#228B22' must be 3, 4, 6, or 8 hex digits long.

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Victorius
Regular
Posts: 30
Joined: Thu Jan 14, 2021 7:02 pm
Projects: Astral Lust
Github: Victorius-Astral
Contact:

[SOLVED] Color string u'#228B22' must be 3, 4, 6, or 8 hex digits long.

#1 Post by Victorius »

-
Hey, I use use Ren'Py 7.4.1.1213 as 7.4.0 was throwing errors for me. One error started to appear from time to time when executing screen code:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While processing the color property of anonymous style:
  File "game/script.rpy", line 1723, in <module>
  File "game/zz_enemies.rpy", line 628, in action
  File "game/zz_enemies.rpy", line 95, in atk
Exception: Color string u'#228B22' must be 3, 4, 6, or 8 hex digits long.
As you see color string is 6 (hex) digits long, the problem happens like once every 50 times I execute the code. Here is my screen code:

Code: Select all

screen hp_indicator():
    zorder 100
    modal False

    for x in ind_list_e:
        if x >= 0:
            text "-" + str(x) size 30 yoffset -25 color "#F93822" at A_ind_enemy
        else:
            text "+" + str(x * - 1) size 30 yoffset -25 color "#228B22" at A_ind_enemy

    for x in ind_list_p:
        if x > 0:
            text "-" + str(x) size 30 yoffset -25 color "#F93822" at A_ind_player
        elif x < 0:
            text "+" + str(x * -1) size 30 yoffset -25 color "#228B22" at A_ind_player
Transforms are just animated movement. It's possible that it reads '#' as digit and thus it sees 7 digits but I'm not sure. Anyone knows how to fix that? There is new Ren'Py version on nightly branch, but I fear it may break my game so I haven't tried as this error doesn't happen often and rollback helps.
_
Last edited by Victorius on Wed Apr 14, 2021 5:02 pm, edited 1 time in total.

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Color string u'#228B22' must be 3, 4, 6, or 8 hex digits long.

#2 Post by rayminator »

have tried it this way
https://www.renpy.org/doc/html/text.html#text-tag-color

Code: Select all

screen hp_indicator():
    zorder 100
    modal False

    for x in ind_list_e:
        if x >= 0:
            text "{color=#228B22}-{/color}" + str(x) size 30 yoffset -25 at A_ind_enemy
        else:
            text "{color=#228B22}+{/color}" + str(x * - 1) size 30 yoffset -25 at A_ind_enemy

    for x in ind_list_p:
        if x > 0:
            text "{color=#228B22}-{/color}" + str(x) size 30 yoffset -25 at A_ind_player
        elif x < 0:
            text "{color=#228B22}+{/color}" + str(x * -1) size 30 yoffset -25 at A_ind_player

Victorius
Regular
Posts: 30
Joined: Thu Jan 14, 2021 7:02 pm
Projects: Astral Lust
Github: Victorius-Astral
Contact:

Re: Color string u'#228B22' must be 3, 4, 6, or 8 hex digits long.

#3 Post by Victorius »

-
I didn't though off this approach, thanks! I modified it a little to change color of whole string:

Code: Select all

screen hp_indicator():
    zorder 100
    modal False

    for x in ind_list_e:
        if x >= 0:
            text "{color=#F93822}-" + str(x) + "{/color}" size 30 yoffset -25 at A_ind_enemy
        else:
            text "{color=#228B22}+" + str(x * -1) + "{/color}" size 30 yoffset -25 at A_ind_enemy

    for x in ind_list_p:
        if x > 0:
            text "{color=#F93822}-" + str(x) + "{/color}" size 30 yoffset -25 at A_ind_player
        elif x < 0:
            text "{color=#228B22}+" + str(x * -1) + "{/color}" size 30 yoffset -25 at A_ind_player
I ran all 4 indications 1000 times on a loop and didn't get any errors, should be working.
_

Post Reply

Who is online

Users browsing this forum: Ocelot