Skip to content

A town name generator, derived from OpenTTD, for JavaScript or command line, written in Haxe.

License

Notifications You must be signed in to change notification settings

laurence-myers/townnamegen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TownNameGen

Generates fictional town names for different locales.

Derived from OpenTTD's town name generator.

This can be used in a web page (via JavaScript), or from the command line (using Neko, but potentially other targets would work).

Demo

Click here to open the demo site.

Differences to OpenTTD

  • Any name algorithms that just randomly picked from a list of real names were omitted.
  • Any name algorithms that used a real name, and could potentially produce the real name without embelishment, were modified so that the "real" component was omitted.
  • The random number generator uses the Mersenne Twister algorithm.

Command Line Tool

The command line tool has been tested using Neko, however, other Haxe targets should work.

Usage

First, build the command line tool.

haxe cli.hxml

Run the tool like so (assuming you are in the "bin" directory):

neko townnamegen.n

or

neko townnamegen.n --locale Silly --num 200 --seed 1234567

Options

  • --help
    • Shows the help text
  • --list-locales
    • Lists all the available options for the "locale" setting.
  • --locale <locale-key>
    • (Optional) The town name locale. Defaults to "AdditionalEnglish".
  • --num <in-num>
    • (Optional) The number of names to generate. Must be between 1 and 10,000. Defaults to 1.
  • --seed <seed>
    • (Optional) The seed for the random number generator. Defaults to the current timestamp.

HTML/JS Demo

First, build the demo HTML and JS.

haxe demo.hxml

Then open bin/index.html in a web browser.

As a Library

The name generator function is called like so:

var locale = 'AdditionalEnglish';
var num = 10;
var seed = 1234567; // or null
var results : Array<String> = townnamegen.TownNameGen.generate(locale, num, seed);

Adding Locales

Locales can be added dynamically at compile-time. Merely implement the ILocale interface, optionally extending the BaseLocale class, and recompile, making sure to include your locale's package in your HXML. For example:

--macro include('mypackage.locales')

TODO

  • Port the remaining locales from OpenTTD
    • Polish
    • Czech
    • Norwegian
    • Hungarian
    • Danish
    • Turkish
    • Italian
    • Catalan

License

TownNameGen is license under GPLv2, the same as OpenTTD.

About

A town name generator, derived from OpenTTD, for JavaScript or command line, written in Haxe.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages