///draw_text_multicolor(x,y,string)
//
// argument0 (x): The initial X position of the text
// argument1 (y): The initial Y position of the text
// argument2 (string): The formatted string to draw
//
// Written by GlitchDetector
// Initialize the string variables
var full_string,current_string;
full_string = argument[2]
current_string = ""
// Initialize the positional variables
var pos_x,pos_y,pos_x_start,pos_y_start;
pos_x = argument[0]
pos_y = argument[1]
pos_x_start = pos_x
pos_y_start = pos_y
// Initialize the string length variables
var string_len,full_len;
string_len = string_length(full_string)
full_len = string_len
// Store the original color so we can reset it after the drawing is complete
var default_color;
default_color = draw_get_color()
while( string_len >= 1 ) {
// Get the first letter in the string
current_string = string_copy(full_string,1,1)
// Delete the first letter in the full string
full_string = string_delete(full_string,1,1)
string_len = string_length(full_string)
// Check the content of the current letter
switch( current_string ){
// If it matches the symbol, set the color
// ^ turns the color black
case "^":
draw_set_color(c_black)
break;
// | turns the color red
case "|":
draw_set_color(c_red)
break;
// \ turns the color green
case "\":
draw_set_color(c_green)
break;
//Here is a template for you to use
case "":
draw_set_color(c_white)
break;
// Newline symbol
case "#":
pos_y += string_height("o")
pos_x = pos_x_start
break;
// If the letter is not listed above, draw it
default:
draw_text(pos_x,pos_y,current_string)
pos_x += string_width(current_string)
break;
}
}
// Reset the color to the original one
draw_set_color(default_color)
Comments