Fixer90
Member
So here's my wonderful textbox system:
CREATE EVENT:
STEP EVENT:
DRAW EVENT:
Now, as you can see in the Draw event, it plays a nice little text-blip sound effect called "snd_text". What I am seeking is a way to make it not play the sound when it gets to a " " (space). It acts like a typewriter text system, making blips at every character. So how do I make an exceptions for spaces?
CREATE EVENT:
Code:
///Initialize Textbox
if(global.invisible_box == true)
{
textbox_alpha = 0;
}
else
{
textbox_alpha = 1;
}
textbox_width = 504;
textbox_height = 380;
textbox_padding = 12;
textbox_start = ds_list_create();
ds_list_add(textbox_start, 0);
textbox_count = 0;
textbox_last_space = 0;
textbox_line = 0;
textbox_string = "";
Code:
///Destroy Textbox
if(global.textbox_destroy == true)
{
global.textbox_destroy = false;
instance_destroy();
}
Code:
///Draw Textbox
if(global.orientation == "top")
{
draw_sprite_ext(spr_textbox, 0, view_xview[0] + 6, view_yview[0] + 6, 1, 1, 0, c_white, textbox_alpha);
}
else
{
draw_sprite_ext(spr_textbox, 0, view_xview[0] + 6, view_yview[0] + 282, 1, 1, 0, c_white, textbox_alpha);
}
draw_set_alpha(1);
draw_set_color(global.textbox_color);
draw_set_font(fnt_ar_julian);
if(global.centered == true)
{
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
}
else
{
draw_set_halign(fa_left);
draw_set_valign(fa_top);
}
if(string_width(textbox_string) > textbox_width - textbox_padding - textbox_padding)
{
global.textbox_message = string_delete(global.textbox_message, textbox_last_space, 1);
global.textbox_message = string_insert("#", global.textbox_message, textbox_last_space);
ds_list_add(textbox_start, textbox_last_space + 1);
}
if(textbox_count < string_length(global.textbox_message))
{
if(!string_char_at(global.textbox_message, textbox_count) == " ")
{
audio_play_sound(snd_text, 10, false);
}
if(string_char_at(global.textbox_message, textbox_count) == " ")
{
textbox_last_space = textbox_count;
}
if(current_time mod 2 == 0)
{
textbox_count ++;
}
}
if(string_height(textbox_string) > textbox_height - textbox_padding)
{
textbox_line ++;
}
textbox_string = string_copy(global.textbox_message, ds_list_find_value(textbox_start, textbox_line), textbox_count - ds_list_find_value(textbox_start, textbox_line));
if(global.orientation == "top")
{
if(global.centered == true)
{
draw_text(view_xview[0] + 256 + textbox_padding, view_yview[0] + 50 + textbox_padding, textbox_string);
}
else
{
draw_text(view_xview[0] + 4 + textbox_padding, view_yview[0] + 4 + textbox_padding, textbox_string);
}
}
else
{
if(global.centered == true)
{
draw_text(view_xview[0] + 256, view_yview[0] + 384 - 50, textbox_string);
}
else
{
draw_text(view_xview[0] + 4 + textbox_padding, view_yview[0] + 384 - 100 - 4 + textbox_padding, textbox_string);
}
}