How do I send a sentence to an array as separate values?

0 favourites
  • 8 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Hi there,

    Is it possible to send a sentence of words to an array and add each word of this sentence to a separate value on the x-axis?

    Example sentence: 'What is that?'

    In this case I would like to send the word 'what' to X0, the word 'is' to X1 and the word 'that' to X2.

    Thanks for your help!

    Ruud.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Condition: Repeat tokencount("What is that?"," ")

    Action: Set array.at(loopindex, 0) to tokenat("What is that?",loopindex, " ")

  • Hi DuckfaceNinja,

    thanks for your fast reply!

    I can't get it to work the way I would like to though...

    Would you mind if I posted my project so you can take a look at it?

    Thanks again!

    Ruud.

  • Hi DuckfaceNinja,

    thanks for your fast reply!

    I can't get it to work the way I would like to though...

    Would you mind if I posted my project so you can take a look at it?

    Thanks again!

    Ruud.

    I don't have C2 in front of me now, but it is always better to post one anyway, others can take a look at it. The best capx will be a minimal and specific to your issue, don't post one with valuable assets though, or a complete game. (if the game has been coded significantly)

  • It's no fancy project. Not yet, anyway...

    It's my first one, so don't be to harsh on me, haha.

    On start of the game, the first player gets three random words. He has to use these words to make some sentences. (still have to find a way to check if the three words are actually used...).

    Then player two has to make a part of the story, using three random words from the text that player one wrote.

    Then it's player's one turn again, and so forth.

    When done, you click 'Done! Create story' and all the text's are 'glued' together...

    Thanx again!

  • Event 6 is wrong, you're setting the value at the index "Array.At(loopindex, 0)" when you should simply be setting the value at "loopindex". The kind of error I tend to make and NOT see it until I restart my events completely...

  • I'm afraid that doesn't work either...

    In the first value of my array I still get all three words instead of having the words being split up into tree different values in the array...

  • Fixed

    [attachment=2:dm9nzlur][/attachment:dm9nzlur]

    Event should look like this as Magistross said

    [attachment=1:dm9nzlur][/attachment:dm9nzlur]

    Not like you had it here

    [attachment=0:dm9nzlur][/attachment:dm9nzlur]

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