Name Generator Problem

Get help using Construct 2

Post » Tue Mar 26, 2013 10:26 am

Hi!
I wanted to create a simple name generator systems for a few RPG books.
The generator would create names based on pre-selected race (elves, dwarves, humans, etc.).
But I'm stuck at the very beginning because I have a problem with the generation of names. I tried to assign names to the numbers and add the script choosing random numbers (tutorial section), but in spite of all the script does not work.
Actually I have no idea how to create such a script. I would be grateful for advice for a beginner
B
3
S
1
Posts: 2
Reputation: 557

Post » Tue Mar 26, 2013 10:44 am

You could type all names in a single string variable, separated by ; or whatever you prefer (one string for each race perhaps). Then when you wish to assign a random name from the string do this:

NameVariable = tokenat(NameString, floor(random(tokencount(NameString, ";"))), ";")

B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Tue Mar 26, 2013 11:14 am

I would build a dictionary of phonemes like:
[code]dictionary['elf_0'] = 'aeg'
dictionary['elf_1'] = 'am'
dictionary['elf_2'] = 'ama'
dictionary['elf_3'] = 'dir'
dictionary['elf_4'] = 'nor'
dictionary['elf_5'] = 'ri'
...
dictionary['dwarf_0'] = 'dah'
dictionary['dwarf_1'] = 'lon'
dictionary['dwarf_2'] = 'mor'
dictionary['dwarf_3'] = 'ren'
dictionary['dwarf_4'] = 'tero'
dictionary['dwarf_5'] = 'war'
...
dictionary['human_0'] = 'rob'
dictionary['human_1'] = 'ali'
dictionary['human_2'] = 'dove'
dictionary['human_3'] = 'fha'
dictionary['human_4'] = 'vyre'
dictionary['human_5'] = 'quo'
...[/code]

etc
and then generating a name by picking 2 or 3 phonem at random like
[code]name = dictionary[race&"_"&floor(random(6))]&dictionary[race&"_"&floor(random(6))]&choose("",dictionary[race&"_"&floor(random(6))])[/code]
Of course you could complexify a bit by having phoneme reserved to be only at the start or end of a name, other that could be in both.
Should also keep track of how much phoneme you have per category. (for the range of the randomness)Yann2013-03-26 11:18:04
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Mar 26, 2013 12:11 pm

@Yann sorry for my ignorance, so how do you set a text with this phonem at random?
B
96
S
25
G
20
Posts: 3,054
Reputation: 22,642

Post » Tue Mar 26, 2013 4:41 pm

@Joannesalfa

[code]name = dictionary[race&"_"&floor(random(6))]&dictionary[race&"_"&floor(random(6))]&choose("",dictionary[race&"_"&floor(random(6))])[/code]
doesn't work?
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Wed Mar 27, 2013 12:07 am

@Yann

I'm using this comparing 2 values as event by picking

I copied the same to action to set text which didn't work
B
96
S
25
G
20
Posts: 3,054
Reputation: 22,642

Post » Wed Mar 27, 2013 3:07 am

works for me
I was too lazy to reproduce exactly what I wrote before.
I used string parsing instead of dictionary look up but the principal is the same.
Instead of a dictionnary.Get('elf_4')
I do a list = dictionnary.Get('elf') and then tokenat(list,4,newline)
same idea
Which made me write a little function to keep things clear.

basicNameGenerator.capx
Last edited by Yann on Sun Sep 14, 2014 7:26 pm, edited 1 time in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Wed Mar 27, 2013 9:22 am

You are fantastic! Thanks for your help friends :)
B
3
S
1
Posts: 2
Reputation: 557

Post » Tue Mar 04, 2014 8:14 pm

thanks! this works great...
B
53
S
13
G
7
Posts: 929
Reputation: 8,455

Post » Sun Mar 09, 2014 4:05 pm

yann you are gem I was looking for something like this but, looking after and playing with grandchildrens I did not have time thank you so much
B
206
S
27
G
13
Posts: 1,841
Reputation: 35,812

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 18 guests