Iterate through lines of text

0 favourites
  • 3 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • I want to set an array with text then iterate through it - all the tutorials and posts I'm seeing about arrays are over my head or off topic. I know I can do this manually with a long slew of events but I'd rather do this with an array and an expression. I just don't know where or how.

    for example - at 5 seconds:

    "good start"

    at ten

    "keep going"

    at fifteen

    "almost there"

    etc - thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can use TokenAt() to retrieve part of a string so long as there is a delimiter.

    For example, if you have a string "M1,M2,M3"

    then tokenat(string,2,",") will give you "M2"

  • Yeah tokenat definitely.

    With array it's a pain 'cause you have to set each lines with one action

    Array: set value at (0) to "good start"
    Array: set value at (1) to "keep going" 
    etc

    With tokenat you just do a

    Global text dialog = ""
    System: Start of layout
      -> Set dialog to [insert your tokenized text]

    And then call each token as Tokensom (hehe) said

    My little advide :

    Build your string with newline as separator

    dialog = "good start
    keep going
    almost there"

    And then you can access each of them with tokenat(dialog,[index],newline)

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