[Solved, Nevermind] How to pause inside loops?

0 favourites
  • 3 posts
From the Asset Store
94 Inside buildings views - Isometric view - PNG transparent - 2048x2048
  • Hello everybody.

    So I have a dialogue system like this:

    The event on the map calls a function called SetDialog. Dialog is parsed as a single text with many "@"s where it is going to be split because the box have text limit.

    Like this:

    Text: "Hello, I like your cupcake.gqp@Can I have it?gqp@Oh... C'mon..."

    Will be shown as:

    (Starts Dialogue)

    "Hello, I like your cupcake." (Letter per letter)

    (Stops until user presses B)


    "Can I have it?" (Letter per letter)

    (Waits B Press)


    "Oh... C'mon..." (Lpl)

    (Waits B Press)


    (Ends Dialogue)

    I use a repeat loop, will a tokenat() to go trough all the speeches.

    "repeat tokencount(NextText,"@")"

    Inside of it, to detect when a key is pressed, I used a Wait for Signal, and on "when key b pressed, and all the current text is on the dialog box"; a corresponding Signal action.

    However, the loop doesn't seem to care about my Wait for Signal.. How do I pause a loop?

    That is my code, if you want to take a look.

    Global Text NextText

    Global Text CurrentText

    Global Number TextSpeed


    (Inverted) CurrentText = ""

    Repeat len(CurrentText) times

    Every TextSpeed seconds

    (Inverted) Textbox.Text = CurrentText

    ACTIONS: Textbox Append Text mid(CurrentText,loopindex,1) CONDITIONS: On Function "SetDialog" ACTIONS: Set NextText to function.param(0) Set CurrentText to "" Clear Textbox Stop Character from moving SUB-EVENTS: ---CONDITIONS_1: ---Repeat tokencount(NextText,"@") ---ACTIONS_1: ---Set CurrentText to tokenat(NextText,loopingIndex,"@") ---Wait for signal "B_Pressed" ---CONDITIONS_2: ---*empty* ---ACTIONS_2: ---Make character be able to move again CONDITIONS: On Keybord B Pressed Textbox.Text = CurrentText ACTIONS: Signal "B_Pressed"
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • So yeah, here is a screenshot:

  • I fixed it! It always happens... I somehow did it.. just when I posted the question.

    So yeah what I did, was to place a static variable carrying the loopindex, and another called "trigger". So the loop content was tested every tick, but if would only trigger when this variable is set to 1.. Again there is a screenshot below.

    There were bugs at the CurrentText part (that would set letter by letter) but it's aaall fixed right now... (Later, I think I'll do an tutorial on how to do this.)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)