#Textbox system still wont work

15 messages · Page 1 of 1 (latest)

sly heath
#

the text will be stuck on one dialogue and wont go to the next one.

#

create event:

#


// speechbox parameters
textbox_width = 320
textbox_height = 64
border = 8
line_sep = 12
line_width = textbox_width-border*2
textb_spr = Sspeechbox
textb_image = 0
textb_image_spd = 0


//the text
page = 0
page_number = 0
text[0] = "hey lowis do you like fortnite?"
text[1] = "i don like fortnite petah"
text[2] = "im leaving you lowis"
text_lenght[0] = string_length(text[0])
draw_char = 0
text_speed = 1
setup = false

draw event:

textbox_x = camera_get_view_x(view_camera[0])
textbox_y = camera_get_view_y(view_camera[0]) + 192

//setup
if setup == false
{
setup = true
draw_set_font(global.font_name)
draw_set_valign(fa_top)
draw_set_halign(fa_left)

//loop pages
page_number = array_length(text)
for(var p = 0; p < page_number; p++)
{
    //find how many characters page has and store and store that number in text_leght array
    text_lenght[p] = string_length(text[p])
    
    //get the x position for text  box
    //no character
    text_x_offset[p] = 80
}

}
//typing the text
if draw_char < text_lenght[page]
{
    draw_char += text_speed
    draw_char = clamp(draw_char,0,text_lenght[page])
}


//flip trough pages
if accept_key
{
    //if typing is done
    if draw_char = text_lenght
    {
    //next page
    if page < page_number - 1
    {
    page++
    draw_char = 0
    }
    else 
    {
        instance_destroy()
    }
    
    }
    //if not done typing
    else
    {
    draw_char = text_lenght[page]
    }
}

//draw the texbox
textb_image += textb_image_spd
textb_spr_w= sprite_get_width(textb_spr)
textb_spr_h= sprite_get_height(textb_spr)
//back of the texbox
draw_sprite_ext(textb_spr, textb_image, textbox_x + text_x_offset[page], textbox_y, textbox_width/textb_spr_w, textbox_height/textb_spr_h,0,c_white,1)

//draw the text
var _drawtext = string_copy(text[page],1,draw_char)
draw_text_ext(textbox_x +text_x_offset[page]+ border, textbox_y + border, _drawtext, line_sep, line_width )
hallow grail
#

Shouldn't you be checking if draw_char == text_lenght - 1 for when you check if typing is done?

#

Also you spelt length wrong but it shouldn't matter too much it looks consistent

hallow grail
# sly heath where:

Everywhere you have it consistently wrong but its OK. I'm just letting you know.

#

Is text_lenght an array?

sly heath
hallow grail
#

Should be i guess text_lenght[page] - 1

sly heath