Well, OK. I try to explain what I want to achieve. Sorry for my English by the way
1. Why?
Because I want to create something, what may be useable for some Stonehearth fans.
2.How it will work?
For the moment, current name generator gives us 198 male and 216 female names (all firstname+lastname combinations included). If you have luck, you may have 2 villagers with the same name already in this starting group. When ways to add another villagers will be aded to the game, some players may end for example with tons of villagers called āBrom Burlyhandsā.
One of the ways to expand the list is adding more names into the list. The most brute-forcing way though, which in latter parts may expand namefile drastically.
Other idea (that one I want to achieve) will modify this a little ā just changing actual system
FirstName LastName
to
FirstAFirstB LastALastB
may both expand the available list of names and give us the more interesting one.
You want examples? OK - There are some names, which may be get by splitting (almost all) default Ascendancy male names into 2 parts and randomly getting each part: āBromtor Beressaā, āGarwyn Keerā, āIrtor Northwellā, āCamplad Jonlochā, āNolving Wintooseā, āIlloff Carriderā ā¦ Sometimes we may get some funny/punny names by the way
3. Actual problems
My lack of LUA scripting ability. I am normally working in PHP and sometimes in Delphi.
Problem to check idea in action (after applying the modification, villagers are not spawningā¦) 4. Where it may be useable? 4.1. Nihonjin mod
Source no. 1: Japanese name - Wikipedia
According to Wiki, there are over 200ā000 surnames in Japan. If you want to add them in actual systemā¦ prepare for large files.
Also, this type of generator may be useable in any fantasy-like mod
There are multiple ways to achieve what you want. For a very simple firstfirst lastlast, Iāve written a mod that does just that using my RP framework. Of course, this breaks the GUI with the normal names (as example, āSennalaina Baubbrightwellā, āElenaleah Northpointhuntertonā, āGarethdaff Berallkelochāā¦).
If you were to introduce a new faction for your mod (which I guess you would do), you could define your own naming generator (basically, Iāve overwritten the default generator - feel free to unzip it and check the lua) just for your faction. That means each faction could have completely different naming. It does not need to follow any rule that the default one is following - get as creative as you can be! Itās not very hard either. A bit hacky perhaps but I think itās still very well within what we should be doing.
Donāt worry, I have already prepared files for each of the default civs .
My idea is to have generator like [firststart][firstend] [laststart][lastend]. Simple, 2 parts for the first name and for the last name
Very interesting concept. I know a little about Japanese names but Iām not a master at how they are formed. Iāll have to do some more in depth research. The wiki page you linked to is a nice start.
Just curious: Would there be a way of making it so the mod can also choose from a list of pre made names? Just for example say you want the name Tim in the game but donāt want an ending tacked onto it but still want the name generator to create names such as Bromtor Beressa?
It would require very little adaption in the code to make that work (for things like āSumimasen Octocatā as example). You would simply need to rewrite the same function, but this time like this:
local faction = api.population:get_faction("civ", "stonehearth:factions:ascendancy")
local function getRandom(names)
return names[math.random(#names)]
end
function faction:generate_random_name(gender)
local names = self._data[gender]
local surnames = self._data.surnames
return getRandom(names.first_name_1) .. getRandom(names.first_name_2) .. ' ' .. getRandom(surnames.first_part) .. getRandom(surnames.last_part)
end
Itās not that big of a deal; of course you could also do this with multiple files instead of one. But then youād have to load them yourself (which is not that much of a big deal, but less comfy than letting Stonehearth do it for you).
@Avairian: Yepp. My approach here would use one json file, but technically you could use whatever you want (which does not need to be json - for a pure list, a simple text file might be easier, but I havenāt looked into other resources.* functions yet.)
indeed! @RepeatPan has gone into much more helpful detail, but effectively the same logic that can randomly generate a name, concatenating āfirstā and ālastā pieces together, can also (randomly) simply grab (only) either orā¦
meaning, each time you generate a unitās name in game, there could be a % chance that the name will be created via the more intricate method of piecing together first and last namesā¦ while there will also be a % chance of having a unit with only a first name (Tim), or perhaps only a last name (Jones)ā¦
If you take a look at the current mergename.lua from my repos, youāll see that Iāve added (commented out) code for exactly this occasion ;). Itās using a simple list with pre-defined names, but the getRandom(names) could easily be replaced with getRandomName(names).
It is already possible. The things you would need to do are quite simple-ish, assuming youāre really going for a new faction:
Manage the game so that your faction instead of the normal one is loaded. The easiest way to do that would be to proxy Population:get_faction. Have it ignore the second argument (usually āstonehearth:faction:ascendancyā) and instead call the original function with your faction name (i.e. āyour_mod_here:faction:your_faction_name_hereā).
Add the faction name above ("ā¦:faction:ā¦ thing") to the manifest, pointing to a json that is either similar to the existing one or fits your requirements.
Youāre done. Stonehearth should now load your factionās file instead of the original one. If you have overloaded your factionās generate_name, it should properly load.
I can make an example mod for you (using RP of course) that takes care of that. I just need you to provide me a json in this format (should be fairly obvious). The format has following advantages:
Multipart names are optional, i.e. surnames could be a simple, static list.
Multipart names can have more than two parts, with optional chances (for example, you could add an ending that only appears in about 10% of the populace)
Surnames can be gender-related too, in case they arenāt thereās a _default fallback.
So, with a fitting json I could probably give you something like that.
Like this? Iāve made one for Ascendancy faction at the moment (exams have started on my uni, so I donāt have much time to do rest atm). But I will create that file for rest available factions ( + Nihonjin and any other interested) ASAP.
Sounds good! Iām really liking the progress being made on the name generator systems. The conversation about the code is extreamly interesting. I donāt know exactly whatās going on in the code but its giving me a clue at how lua works.
Have a list of thousand generated names. I took the liberty of adding a few rare pre- and postfixes (such as Duke, Count and Dark Lord of All). You can find the repository with the current source here and the smod ready for download here.
Heh, I see some punny names, I see some punny names!
Lena Nohands Broman Bolloch
Garlad Nowine
In current version (v1?) Mario, Daren, Len are female names. Len is functioning in both genders in Japan (for example), but I am now thinking about improving the *.json file.
But now when we have interesting names of villagers, we may start letās playing
Good there is on GitHub. Iāve got account here, so looks like i could editā¦ or couldnāt?
EDIT:
I am making first, basic version of Nihonjin namelist and I find one problemā¦ and possible solution to it
Problem: Better to write an example: Ku + tou = Kudou, Shin + hachi = Shinpachi,
Shin + tou = Shindou (do not mistake with ShintÅ [Shintoism] )
etc. There are some rules in japanese (and in others languages too propably), which are changing the āreadingā a little to make the word easier to speak.
Solution: maybe there will be needed also a table with āchangesā written like, which will be applied if some strings will be found. It may be useable also in other civs.
Yepp, you can (and you did)! Iāve merged your pull request into the main branch. Thanks for participating!
The current data format is a bit of a mess. Iāll have to think about a better way to organize the json in order to allow this. But the idea is good - Iāll certainly add it, along with an option to choose which json file you wish to load (since youāve now provided the nihonjin parts as well, I might as well turn them into something useful ;))
I made an experimental form based off raw consonants and vowels but it had issues, It has a tendency to produce names like Pbouchchm Nkrioj, technically pronounceable with a bit of thought but seriously stupid. Would either of you have any ideas on how to enforce structure in the names? Currently itās just a pretty random thing designed to enforce pronounceable names. If there was a working version and it could be made to work for varying things then we could get very varied names, all weād need to do is make them fit a theme.