Multiple lines of text for random name generator

Get help using Construct 2

Post » Tue Mar 05, 2013 12:12 am

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:

http://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?Monokkel2013-03-05 00:17:58
B
5
Posts: 11
Reputation: 622

Post » Tue Mar 05, 2013 12:31 am

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.
B
6
S
1
Posts: 67
Reputation: 986

Post » Tue Mar 05, 2013 4:52 pm

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.
B
5
Posts: 11
Reputation: 622

Post » Tue Mar 05, 2013 4:56 pm

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.
B
25
S
5
G
3
Posts: 446
Reputation: 5,633

Post » Tue Mar 05, 2013 7:09 pm

[QUOTE=Monokkel] 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.[/QUOTE]

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(..))), ";").
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Tue Mar 05, 2013 11:20 pm

[QUOTE=farflamex] 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.[/QUOTE]

Exactly what I was looking for. Thank you!

[QUOTE=vee41]
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(..))), ";"). [/QUOTE]

And that's an even more economical solution. Thanks!Monokkel2013-03-05 23:21:08
B
5
Posts: 11
Reputation: 622


Return to How do I....?

Who is online

Users browsing this forum: Zebbi and 23 guests