1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice
  2. NOTICE: We will be applying a Xenforo update on Tuesday 25th of February. This means that from approximately 10:00 to 14:00 BST the forums will be offline (or possibly longer). Sorry for the inconvenience! Official Announcement here.

GML Typewriter style text not drawing correctly via Timeline

Discussion in 'Programming' started by Agletsio, Jun 27, 2017.

  1. Agletsio

    Agletsio Guest

    All that follows is executed via a timeline

    So I have a cutscene type thing, that flips between two rooms, seven times (then flips to new room the eighth time).

    On the 1, 3, 5, 7th time, I want text to write (in typewriter style). Now I've mostly achieved this but the text only writes on 1 and 3 and doesn't write anything afterwards.

    I've also noticed that they don't draw at the same coordinates, even though draw text is set to the x and y position of the same persistent object (obj_talk).

    I hope this makes sense, not sure how else to explain it. Any help, insight or guidance would seriously be appreciated! I've been stuck with this for quite some time but can't get it to fully work.

    This is the relevant code (in obj_talk):
    Code:
    //CREATE EVENT
    
    mesg[0] = false;
    mesg[1] = false;
    mesg[2] = false;
    mesg[3] = false;
    
    
    message[0] = "'This isn't happening...'"
    message[1] = "'Where could he be?'"
    message[2] = "'It's been days...'"
    message[3] = "'I can't give up!'"
    
    
    message_current = 0;
    message_draw = "";
    increase = 0.37;
    characters = 0;
    
    
    message_length = string_length(message[message_current]);
    
    //STEP EVENT
    
    // Message 0
    
    if mesg[0] = true  {
    message_current = 0;
    
    if characters < message_length {
    characters += increase;
    message_draw = string_copy(message[0], 0, characters);
    }
    
    else
    
    if characters >= message_length {
    characters = message_length;
    }
    }
    
    // Message 1
    
    else
    
    if mesg[1] = true  {
    message_current = 1;
    
    if characters < message_length {
    characters += increase;
    message_draw = string_copy(message[1], 0, characters);
    }
    
    else
    
    if characters >= message_length {
    characters = message_length;
    }
    }
    
    //Message 2
    
    else
    
    if mesg[2] = true  {
    message_current = 2;
    
    if characters < message_length {
    characters += increase;
    message_draw = string_copy(message[2], 0, characters);
    }
    
    else
    
    if characters >= message_length {
    characters = message_length;
    }
    }
    
    // Message 3
    
    if mesg[3] = true  {
    message_current = 3;
    
    if characters < message_length {
    characters += increase;
    message_draw = string_copy(message[3], 0, characters);
    }
    
    if characters >= message_length {
    characters = message_length;
    }
    }
    
    //DRAW EVENT
    
    if mesg[0] = true {
    draw_set_font(fnt_talk);
    draw_set_halign(fa_left);
    draw_set_valign(fa_center);
    draw_set_colour(c_white);
    draw_text(x,y,message_draw);
    }
    
    if mesg[1] = true {
    draw_set_font(fnt_talk);
    draw_set_halign(fa_left);
    draw_set_valign(fa_center);
    draw_set_colour(c_white);
    draw_text(x,y,message_draw);
    }
    
    if mesg[2] = true {
    draw_set_font(fnt_talk);
    draw_set_halign(fa_left);
    draw_set_valign(fa_center);
    draw_set_colour(c_white);
    draw_text(x,y,message_draw);
    }
    
    if mesg[3] = true {
    draw_set_font(fnt_talk);
    draw_set_halign(fa_left);
    draw_set_valign(fa_center);
    draw_set_colour(c_white);
    draw_text(x,y,message_draw);
    }

    Like mentioned before, the variables are executed via a timeline. Here's an example of a step:

    Code:
    room_goto(rain_test);
    
    obj_talk.mesg[1] = true;
    
    in[1] = false; // Setting variable from previous step to false
    
    
     
  2. Agletsio

    Agletsio Guest

    Is there anybody that can help me with this, pretty please?
     
  3. Yal

    Yal GMC Memer GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    4,214
    So you change rooms? Timelines are run by one instance, so unless that instance is persistent, nothing will actually be running the timeline in the next room (and set those variables to true etc).
     
  4. Agletsio

    Agletsio Guest


    Yes, the object "obj_talk" (wherein the above mentioned code is placed) is a persistent object. So changing rooms and triggering variables are working fine, it's just the result isn't what I'd like it to be.
     

Share This Page