Hi,
basically i have for example this array:
["name", 0, "(0.4706, 0.3804, 0.1098, 1)", "(0.8745, 0.7137, 0.5725, 1)", "(0.1373, 0.3765, 0.4118, 1)", "(0.4784, 0.349, 0.1961, 1)"]
so array[2] give me (0.4706, 0.3804, 0.1098, 1)

then i instantiate my player node and want to change the color of the animatedsprite2D
a_player = boy_player.instantiate()

a_player.get_node("b/anim").modulate(Color(array[2]))
don't work at all

a_player.get_node("b/anim").set_modulate(Color(array[2]))
return the default color so it's just black

a_player.get_node("b/anim").set_modulate(Color.from_string(array[2],Color.AQUA))
return the set default color so aqua but not my color

could you tell me why it doesn't show the color from the array?

thx

  • Toxe replied to this.

    thx for your answers.

    is there a method that convert the color template to HTML color?

    the thing is i get the color from the colorpickerbutton signal "color", and i send it to my database as a string through a similar array.
    then of course, i get the color back as it is from the database.

    the solution i had in mind was to get the members separately like color.r, color.b, color.g from the colorpickerbutton signal, so when i get it back from the database, i can reconstruct the color from the 3 floats

    do you know a more simple way?

    thx

    edit: it seems there is "to_html" function, i will try that with the colorpickerbutton signal

    • xyz replied to this.

      noals Remove parenthesis using String::substr(), tokenize the string using String::split() and then convert each token into float using String:to_float(). Look at the String class reference for details on those functions.

        it's working fine, thanks.
        i send it to my database this way color_1 = color.to_html(false)

        xyz i won't use it now since it works with html color but i was wondering. ^^ thx