Multiple lines of text for random name generator

0 favourites
  • 6 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • I'm currently working on a basic random name generator for a game. I did a quick search to find if it had been done before, and found this example for Construct Classic by R0j0Hound:

    dl.dropbox.com/u/5426011/examples4/randomname.cap

    This name generator is based on simply picking a random line in a text object. However, I can't seem to be able to create multiple lines of text in Construct 2. Has this functionality been removed, replaced by multiline formatting? I feel like a complete fool having used quite some time trying to figure out how to create multiple lines of text.

    I have found my way around it by creating a list object, and using events to select a random item in the list, and change a text object to the text of the selected item in the list. It works, but it is hardly elegant. Could someone help me out with what should probably be an exceedingly simple request to solve?

  • An Array seems like it should work well. Just save the various texts as strings inside it, then you can choose a coordinate in the array at random and pull the text from it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That is certainly another possibility, but it's still more complicated than just storing it in a string. If it is impossible to have multiple lines in a string I'll certainly use some such workaround, but I'm quite perplexed if this is an impossibility.

  • By multiple lines of text, do you just mean a line of text, then another line underneath, stored in the same object? If you are, then you can just build your text object with 'Line 1'&newline&'Line 2'&newline&'Line 3' etc.

    Not sure if that's what you meant. Actually that saved me a lot of objects because I had 10 text objects ontop of each other and realised I could just stick them all in the same object with a newline between each line.

  • That is certainly another possibility, but it's still more complicated than just storing it in a string. If it is impossible to have multiple lines in a string I'll certainly use some such workaround, but I'm quite perplexed if this is an impossibility.

    Like said before 'newline' works, for randomization you could use single string with something like ;name1;name2;name3;name4.. and then randomize it with tokenat(ceil(random(tokencount(..))), ";").

  • By multiple lines of text, do you just mean a line of text, then another line underneath, stored in the same object? If you are, then you can just build your text object with 'Line 1'&newline&'Line 2'&newline&'Line 3' etc.

    Exactly what I was looking for. Thank you!

    Like said before 'newline' works, for randomization you could use single string with something like ;name1;name2;name3;name4.. and then randomize it with tokenat(ceil(random(tokencount(..))), ";").

    And that's an even more economical solution. Thanks!

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