Yoshbert wrote:
I've been figuring out how to get the color value around the open tag ([color=c_red]).
Code:
string_copy("[color=c_red]", string_pos("[color=", "[color=c_red]") + 7, string_pos("]", "[color=c_red]") - string_pos("[color=", "[color=c_red]") - 1 );
No luck with implementing it into the engine, though.
I tried working with this problem for a bit today and came up with something really simple. This is mainly a start and nowhere near as flexible as it should be. I'll just be posting the code because it is quite short.
1.) Create an object
2.) Create two scripts: [message] and [message_get_color]
3.) message ( string )
Code:
// message ( string )
var str, str_tag, str_pos_color, char_width, char_height, char_pos_x, char_pos_y;
str = argument0;
char_width = 8;
char_pos_x = 0;
char_pos_y = 0;
for (i=1; i<=string_length (str); i+=1) {
// obtain the [open color]
if (string_char_at (str, i) == '[') {
index = 0;
while (string_char_at(str, i + index) != ']') index += 1;
str_tag = string_copy (str, i, index + 1);
message_set_color (str_tag);
str = string_delete (str, i, index + 1);
}
draw_text (0 + char_pos_x, 0, string_char_at (str, i));
char_pos_x += char_width;
}
draw_set_color (c_black);
4.) message_get_color ( string )
Code:
// message_set_color ( string )
var str;
str = argument0;
switch (str) {
case "[color=c_black]": draw_set_color (c_black); break;
case "[color=c_red]" : draw_set_color (c_red); break;
case "[color=c_blue]" : draw_set_color (c_blue); break;
default: draw_set_color (c_black); break;
}
5.) Object's Draw Event [two versions to show as example]
Code:
message ("H" + "[color=c_red]" + "el" + "[color=c_blue]" + "lo");
or
Code:
message ("H[color=c_red]el[color=c_blue]lo");
[quote="Yoshbert"]I've been figuring out how to get the color value around the open tag ([color=c_red]).
[code]
string_copy("[color=c_red]", string_pos("[color=", "[color=c_red]") + 7, string_pos("]", "[color=c_red]") - string_pos("[color=", "[color=c_red]") - 1 );
[/code]
No luck with implementing it into the engine, though.[/quote]
I tried working with this problem for a bit today and came up with something really simple. This is mainly a start and nowhere near as flexible as it should be. I'll just be posting the code because it is quite short.
1.) Create an object
2.) Create two scripts: [message] and [message_get_color]
3.) message ( string )
[code]// message ( string )
var str, str_tag, str_pos_color, char_width, char_height, char_pos_x, char_pos_y;
str = argument0;
char_width = 8;
char_pos_x = 0;
char_pos_y = 0;
for (i=1; i<=string_length (str); i+=1) {
// obtain the [open color]
if (string_char_at (str, i) == '[') {
index = 0;
while (string_char_at(str, i + index) != ']') index += 1;
str_tag = string_copy (str, i, index + 1);
message_set_color (str_tag);
str = string_delete (str, i, index + 1);
}
draw_text (0 + char_pos_x, 0, string_char_at (str, i));
char_pos_x += char_width;
}
draw_set_color (c_black);[/code]
4.) message_get_color ( string )
[code]// message_set_color ( string )
var str;
str = argument0;
switch (str) {
case "[color=c_black]": draw_set_color (c_black); break;
case "[color=c_red]" : draw_set_color (c_red); break;
case "[color=c_blue]" : draw_set_color (c_blue); break;
default: draw_set_color (c_black); break;
}[/code]
5.) Object's Draw Event [two versions to show as example]
[code]message ("H" + "[color=c_red]" + "el" + "[color=c_blue]" + "lo");[/code]
or
[code]message ("H[color=c_red]el[color=c_blue]lo");[/code]