Page 1 of 1

Assigning hex values from array to character.

Posted: Thu Aug 05, 2021 9:12 pm
by jpalmer999
So I am trying to make an rpg with an alignment bar (blue good, white neutral, red bad) and I have all the values I want set to a string array of 101 values. I then changed the character name color to be equal to the alignment index of the color variable.

However, ren'py brings up an error

Error Information
While processing the color property of anonymous style: line 7, in script player "zzz"
Exception: Color string u'[alignColors[iPlayer_Alignment]]' must be 3, 4, 6, or 8 hex digits long.



I'm rather confused about what is going wrong. As far as I can tell it should work as the value in a character define for the color is a string value anyway.

Thanks for any help in advance,
Jonathan

Initializing the variable

Code: Select all

label start:
    call Levels
    call Player_Init
    call Init_Alignment_Colors
    call Init_Audio
    call Init_Images
    call Init_Variables
    call Init_Video
    call Inventory

    jump Game_Select
Character Defining

Code: Select all

define player = Character ("[sName]", who_color = "[alignColors[iPlayer_Alignment]]")

Array

Code: Select all

label Init_Alignment_Colors:
    python:
        alignColors = [
            "#ff0100", # 0
            "#ff0500", # 1
            "#ff0a00", # 2
            "#ff0f00", # 3
            "#ff1400", # 4
            "#ff1800", # 5
            "#ff1d00", # 6
            "#ff2200", # 7
            "#ff2700", # 8
            "#ff2b00", # 9
            "#ff3000", # 10
            "#ff3500", # 11
            "#ff3a00", # 12
            "#ff3e00", # 13
            "#ff4300", # 14
            "#ff4800", # 15
            "#ff4d00", # 16
            "#ff5100", # 17
            "#ff5600", # 18
            "#ff5b00", # 19
            "#ff6000", # 20
            "#ff6400", # 21
            "#ff6900", # 22
            "#ff6e00", # 23
            "#ff7300", # 24
            "#ff7801", # 25
            "#ff7d0b", # 26
            "#ff8215", # 27
            "#ff881f", # 28
            "#ff8d29", # 29
            "#ff9334", # 30
            "#ff983e", # 31
            "#ff9e48", # 32
            "#ffa352", # 33
            "#ffa95c", # 34
            "#ffae67", # 35
            "#ffb371", # 36
            "#ffb97b", # 37
            "#ffbe85", # 38
            "#ffc48f", # 39
            "#ffc99a", # 40
            "#ffcfa4", # 41
            "#ffd4ae", # 42
            "#ffd9b8", # 43
            "#ffdfc2", # 44
            "#ffe4cd", # 45
            "#ffead7", # 46
            "#ffefe1", # 47
            "#fff5eb", # 48
            "#fffaf5", # 49
            "#ffffff", # 50
            "#f5faff", # 51
            "#ebf4ff", # 52
            "#e0efff", # 53
            "#d6e9ff", # 54
            "#cce4ff", # 55
            "#c2dfff", # 56
            "#b8d9ff", # 57
            "#add4ff", # 58
            "#a3ceff", # 59
            "#99c9ff", # 60
            "#8fc3ff", # 61
            "#85beff", # 62
            "#7ab8ff", # 63
            "#70b3ff", # 64
            "#66aeff", # 65
            "#5ca8ff", # 66
            "#52a3ff", # 67
            "#479dff", # 68
            "#3d98ff", # 69
            "#3392ff", # 70
            "#298dff", # 71
            "#if88ff", # 72
            "#1482ff", # 73
            "#0a7dff", # 74
            "#0077ff", # 75
            "#0072ff", # 76
            "#006eff", # 77
            "#0069ff", # 78
            "#0064ff", # 79
            "#005fff", # 80
            "#005bff", # 81
            "#0056ff", # 82
            "#0051ff", # 83
            "#004cff", # 84
            "#0048ff", # 85
            "#0043ff", # 86
            "#003eff", # 87
            "#0039ff", # 88
            "#0035ff", # 89
            "#0030ff", # 90
            "#002bff", # 91
            "#0026ff", # 92
            "#0022ff", # 93
            "#001dff", # 94
            "#0018ff", # 95
            "#0013ff", # 96
            "#000fff", # 97
            "#000aff", # 98
            "#0005ff", # 99
            "#0000ff"] # 100

Re: Assigning hex values from array to character.

Posted: Thu Aug 05, 2021 11:38 pm
by hell_oh_world
What you want is to make the character object dynamic...
I would suggest defaulting the character object and passing the static properties.

Code: Select all

default player = Character ("[sName]") # plain definition, dont define the dynamic properties yet.
then in your labels, once the the alignment variable is defined you need to reassign this character object again.

Code: Select all

label start:
  $ align = 0
  $ player = player.copy(who_color=alignColors[align]) # no need to interpolate your alignColors is already a list of string

Re: Assigning hex values from array to character.

Posted: Fri Aug 06, 2021 6:29 am
by jpalmer999
Thanks this worked perfectly. Also where's your avatar from? Looks pretty cool.

Re: Assigning hex values from array to character.

Posted: Fri Aug 06, 2021 10:45 am
by hell_oh_world
jpalmer999 wrote: Fri Aug 06, 2021 6:29 am Thanks this worked perfectly. Also where's your avatar from? Looks pretty cool.
It's from Dota 2's Wraith King's Arcana actually...