How do I merge texts

0 favourites
  • 7 posts
From the Asset Store
OpenAI TTS
$9 USD
10% off
Text-to-Speech plugin.Allows your Construct 3 project to convert written text into spoken words
  • Hi there,

    I'm a bit lost developing my app.

    What I need is the following: there are two players, each of which in turn add text into a textblock.

    At a certain moment I would like to merge all these texts together in one textfield.

    The question is: how can I store each player's entry and put them all together in the end?

    I've been trying to accomplish this with arrays, webstorage and dictionary but I just don't know how to store things and 'glue' them together...

    Please advice if one of the mentioned plugins can do the work and if so, how?

    On the other hand, there might be a better solution?

    Many thanks in advance,

    Ruud.

  • text1&text2&"Something else"&variable1&array.at(0,1) etc

    & being the glue

  • Thanks Dutoit!

    Should have known that...works the same as in Java...

    However I still have some questions.

    If I want to store the player's entries, which is best to use: arrays, webstorage or dictionary and how to add the entries? With some kind of while loop?

    Or, as I mentioned, maybe there is a much better solution...?

    Thanks again.

  • Would use arrays, it offers more flexibility... but dictionary will also work. Of course whatever you choose, save to webstorage, very easy to do...

    Check tutorial section you can save array to json or dictionary to json and save that json to webstorage, then all you do is load from webstorage "yourspecialdata" into your array or dict on start of app...

    No need for while loop can save directly via text or whatever...

    What you making, might be easier knowing what you trying to do, to offer best solution.

    For instance I use functions and param, very effective, each param is a set of data...

  • I'm trying to create a simple word-game.

    Player 1 gets three random words and has to make some sentences, using all three words.

    Then it's player's 2 turn: player 2 can't see the text that player 1 has written. He also gets 3 random words from the sentences player 1 has made.

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

    Ultimately there's one button that 'glues' the complete story together.

    Nothing fancy, but I only started with C2 a couple of weeks ago so still learning and still reading...

    I managed to put all the players entries into a global variable, but when player 1 has entered his sentences, I can't get C2 to pick three random words out of the global variable...

    Hope this makes any sense?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I don't really like to write code for people, I rather people try it out for themselves and learn, especially new users...but there are so many examples doing things one way, I thought I would try another way and use more advanced techniques. I know you are new, and this is a little over your head, but if you can grasp this, then you are on your way.

    You didn't exactly choose the easiest app to start with - lol.

    This was done quickly. It as raw, and needs some TLC etc etc etc. It is an example, done quickly - okay - lol

    This to steer you in a direction - to get you to focus your learning on certain things. Check the manual and tutorials to find out more about what I tried to do, what I used.

    It works, it just isn't completed in any way or form... Its just to nudge you in the right direction.

    Okay... I...

    Created 2 functions, save and retrieve.

    Functions pass on params and return values

    I and you will use tokenat( it is the easier, but regex is also an option) I counted the spaces (" ") to determine number of words, I created a temp array to store 3 random numbers based on number words. So you don't randomly select same word, of course if player1 has written a word 2 or more times, player2 might get it twice or more.

    I used tokenat to find the 3 random words using the temp random numbers.

    Anyways, all the time I have.

    You can find tutorials on all that I have used, obviously in separate tutorials, I just combined them.

  • Damn Dutoit, you ROCK!

    You rock big time!

    You're right, what you made is not excactly my level (yet), but I would like to thank you anyway!

    I'll dive into it and see how far I will come

    Thanks again for your time!

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