Giter Site home page Giter Site logo

lua-namegen's Introduction

MIT

LuaNameGen - Lua Name Generator v1.1.0

LuaNameGen is a tool to quickly generate random names for characters, objects and places. It is useful for both table-top games (run the script, grab the name) or to be used as a library for game development.

Never again face an Ancient Red Dragon named Bob!

Table of contents

Inspiration

Code

This script is shamelessly inspired by the great libtcod's namegen, written by Dominik "Mingos" Marczuk. It even uses its syntax for .cfg files, aiming to provide compatibility with its existing sets.

Names and syllables

Part of the patterns used in this this script were adapted from:

  • libtcod's namegen sets, written by Mingos and Jice;

Inspiration came from sources such as:

Usage

Basic usage

To get a dwarf name and surname, using default sets, just do:

Like-a-boss usage

To get whatever you want, call for a name set with the rule you want:

How does it works?

Basics

When loaded/required, the module "namegen" parses the set files pointed by 'namegen.index' (a plain text file).

Each line of 'namegen.index' indicates the location of a set file to be readed. By default it only contains one: namegen.cfg.

Each set file (also plain text files) follows a simple syntax (libtcod's syntax, so any .cfg file from it can be used), and may contains multiple sets. This is an example of a basic set:

name "dwarf male" {
    syllablesStart  = "Do, Due"
    syllablesEnd = "lin, rin"
    rules = "$s$e"
}

This set with its only rule would generate names such as:

  • Dolin;
  • Dorin;
  • Duelin;
  • Duerin;

Syllable Groups

Every syllable group has a matching symbol (used rules, s and e in the previous example) that matches it, and will, after parsed, be stored under a specific key on the parser data table:

symbol  group name          parser field
------  ----------          ------------
s       syllablesStart      parser_data["start"]
m       syllablesMiddle     parser_data["middle"]
e       syllablesEnd        parser_data["end"]
P       syllablesPre        parser_data["pre"]
p       syllablesPost       parser_data["post"]
v       phonemesVocals      parser_data["vocals"]
c       phonemesConsonants  parser_data["consonants"]
A       customGroupA        parser_data["cga"]
B       customGroupB        parser_data["cgb"]
... (custom groups exist from `A` to `O`)
N       customGroupN        parser_data["cgn"]
O       customGroupO        parser_data["cgo"]
?       phonemesVocals/     parser_data["vocals"]/
        phonemesConsonants  parser_data["consonants"]

Rules

Considering the basic example above, if you replace its rule for "$e$s", that would swap syllables in the generated names.

It is possible to set a chance of adding a syllable. The rule "$s$e$50e" would have fifty percent chance of adding a third syllable from syllablesEnd group (or the matching group of the letter you pass).

If you want to have multiple rules for a same set, simply separate them with a comma:

rules = "$e$s, $s$e"

Each rule would have an equal chance to be used at each generation. If desired, you can give specific chances for each rule (by default they all have the same chance of being used):

rules = "%50$e$s, $s$e"

Instead of each rule having 1/2 chance to be used, the first one would have 1/2*50% chance.

How to help

Help is always appreciated. Those are the main forms to get involved:

  • Test and improve content:
    • test existing name sets;
    • improve them:
      • create a new rule;
      • modify a new rule;
      • change/remove syllables or syllable groups;
      • add some illegal results to avoid weird combinations;
    • create a new set.
  • Make changes to the Lua code, improving performance, fixing bugs, etc;
  • Improve the documentation.

On all cases, the optimal way to proceed is by following github's workflow: fork this repo, change it and then submit a pull request.

You can also report an issue (and add a fix for it on the comments).

Release notes ============

1.2.0

1.1.0

  • Added books, potions and towns name sets:
    • towns.cfg is a copy of Mingos and Jice town name sets for libtcod's namegen;
    • books.cfg and potions.cfg were based on common roguelike names for unidentified items.

1.0.1

  • Fixed a critical error that prevented the data files (.cfg, .index) from being loaded at all while calling the library from outside of its own directory.
  • Made a doc generator to provide sphynx-like basic literalinclude (github don't support it)

Example of generated names

Below are examples of generated names for each of the sets packed with LuaNameGen:

Books

"books"

Creatures

"aasimar female"

"aasimar male"

"catfolk female"

"catfolk male"

"dragon female"

"dragon male"

"drow female"

"drow male"

"dwarf female"

"dwarf female 2"

"dwarf male"

"dwarf male 2"

"dwarf surname"

"elf female"

"elf female 2"

"elf male"

"elf male 2"

"fetchling female"

"fetchling male"

"giant female"

"giant male"

"gnome female"

"gnome male"

"gnome surname"

"goblin female"

"goblin male"

"half-demon female"

"half-demon male"

"halfling female"

"halfling female 2"

"halfling male"

"halfling male 2"

"halfling surname"

"hobgoblin female"

"hobgoblin male"

"human female"

"human male"

"human surname"

"ifrit female"

"ifrit male"

"infernal 1"

"infernal 2"

"infernal 3"

"kobold female"

"kobold male"

"ogre female"

"ogre male"

"orc female"

"orc female 2"

"orc male"

"orc male 2"

"orc surname"

"oread female"

"oread male"

"ratfolk female"

"ratfolk male"

"sprite female 1"

"sprite female 2"

"sprite male 1"

"sprite male 2"

"sylph female"

"sylph male"

"tengu female"

"tengu male"

Potions

"potions"

Towns

"jice towns"

"mingos towns"

Inns

"inns"

lua-namegen's People

Contributors

hikitsune-red avatar lukems avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.