Code for generating randomized lines of text
Quite a few times I’ve found myself writing code to mash together a few strings randomly for games. Inspired by some sweet generated text stuff @eigenbom‘s been doing for his game Moon Man, I thought I’d write a tool to make this easy to do.
- Quick and simple way of generating a randomized lines of text for a variety of purposes.
- Chuck some simple rules in a text file and use PowerText to generate random lines.
- Lightweight, easy to use code. Just 2 function calls really.
- Automatically handles some simple language things like capitalizing first letter of sentence, and converting “a” to “an” where necessary.
- Simple handling of plurals– mark numbers in your text with [#], and then plurals of words like so: “cat[s], leech[es], goose[/geese]”.
- Add weighting for certain options by adding [weight] at the start of a line (eg: “common housefly”, “[0.1] rare dodo”).
- Insert variables from code eg “You have [numLives] life[/lives] remaining.”
There’s fancier things out there that do the same thing and more, but if you want something really quick, lightweight and easy to use this might do the trick!
- The unity c# code’s all in a single file, you can copy-paste it from here: http://pastebin.com/4GrVyJUf
- Or you can download the zip with the above, and a proper manual pdf and examples here: http://powerhoof.com/public/tools/PowerText.zip
- Or download the standalone tool here: http://powerhoof.com/public/tools/PowerText-Standalone.zip. Drag the input text over PowerText.exe and it spits out 1000 lines to Output.txt. I included more example inputs too.