#define text_box
//arg0=y
//arg1=color
//arg2=color2
//arg3=end script
//arg4=text0
//arg5=text1
//arg5=text2
//arg5=text3
//arg5=text4
global.textboxC=argument0
global.textboxcol=argument1
global.textboxcol2=argument2
global.textbox_end=argument3


global.textboxT[0]=argument4
global.textboxT[1]=argument5
global.textboxT[2]=argument6
global.textboxT[3]=argument7
global.textboxT[4]=argument8

i=object_add()
object_event_add(i,ev_create,0,
"
global.textboxTB=''
i=0
a=0
alarm[0]=1
global.text_box_postava=0
"
)

object_event_add(i,ev_draw,0,
"
draw_text(20,global.textboxC+10,global.textboxTB)
draw_set_blend_mode(bm_max)

if global.text_box_postava=0
draw_rectangle_color(0,global.textboxC,room_width,room_height,c_black,c_black,global.textboxcol,global.textboxcol,false)

if global.text_box_postava=1
draw_rectangle_color(0,global.textboxC,room_width,room_height,c_black,c_black,global.textboxcol2,global.textboxcol2,false)

draw_set_blend_mode(bm_normal)

if keyboard_check_pressed(vk_anykey)
{
if string_length(global.textboxT[a])>string_length(global.textboxTB)
{
global.textboxTB=global.textboxT[a]
alarm[0]=0
exit
}

if string_length(global.textboxT[a])=string_length(global.textboxTB)
{
global.textboxTB=''
a+=1
i=0
alarm[0]=2
if global.text_box_postava=0
{
global.text_box_postava=1
exit
}

if global.text_box_postava=1
{
global.text_box_postava=0
exit
}

}
}


if mouse_check_button_pressed(mb_left)
{
if string_length(global.textboxT[a])>string_length(global.textboxTB)
{
global.textboxTB=global.textboxT[a]
alarm[0]=0
exit
}

if string_length(global.textboxT[a])=string_length(global.textboxTB)
{
global.textboxTB=''
a+=1
i=0
alarm[0]=2
}

if global.text_box_postava=0
{
global.text_box_postava=1
exit
}

if global.text_box_postava=1
{
global.text_box_postava=0
exit
}


}

if string_length(global.textboxT[a])=0
execute_string(global.textbox_end)
"
)

object_event_add(i,ev_alarm,0,
"
if i<=string_length(global.textboxT[a])
{
i+=1
global.textboxTB=string(global.textboxTB)+string(string_char_at(global.textboxT[a],i))
alarm[0]=2
}
"
)

instance_create(x,y,i)

