In my game I can import a color correctly when it is in the "engine format".
Example ("color.ini"):
[color]
color1="c_black"
color2="c_green"
color3="c_navy"
These colors were seen in this link:
https://docs2.yoyogames.com/source/_build/3_scripting/4_gml_reference/drawing/colour/index.html
It turns out that I can't import the color when I use its hexadecimal code (only the colors from the previous link don't supply me).
Example ("color.ini"):
[color]
color1="#FA8072"
color2="#FAEBD7"
color3="#E0FFFF"
Codes taken from this link:
https://celke.com.br/artigo/tabela-de-cores-html-nome-hexadecimal-rgb
I tried lowercase variations, with $ instead of # and nothing worked.
It is not even a case of seeing the wrong color, but of changing nothing (it always turns white).
I am using the function (asset_get_index) to apply the color.
Link where I looked for a solution before coming here:
https://www.reddit.com/r/gamemaker/comments/cc0dk6/saving_a_colour_to_an_ini_file/?ref=readnext
Code in my game (works in all colors that don't come as hexadecimal):
color[i]=ini_read_string("color","color"+string(i),"");
Draw:
draw_sprite_ext(spr_Barra,0,290,97+25*(i-1),1,1,0,asset_get_index(color[i]),1);
Code I tried, based on one of the comments, from the question:
result=0;
zero=ord("0");
nine=ord("9");
a=ord("A");
f=ord("F");
for(var i=1;i<=string_length(color1);i++){
c=ord(string_char_at(string_upper(color1),i));
result=result<<4;
if (c>=zero && c<=nine){
result=result+(c-zero);
}else if(c>=A && c<=f){
result=result+(c-a+10);
}
}
I used the function (show_debug_message) to see the result of the code and got nonsense results:
- 1024, 2048
Link to see the code base I tried:
https://www.reddit.com/r/gamemaker/comments/9nyjbu/hexstringtonumber_script/