Alright, let's make some stuff!

First : a few things

What's a random generator?

A random generator is a simple application that produces random text at the click of a button. There are generators that output random names, others that write descriptions of strange imaginary monsters, but you could imagine a generator for just about anything - such as a generator that returns a random story, or a random cooking recipe!

So how do I make a generator?

Well, it's fairly easy. All generators in RandomGen are simply text files that our website converts into generators.

To make your own generator, you will have to write that text file using the syntax described below (you'll see, you can do all kinds of neat stuff). Here's what a finished generator source file looks like : http://pastebin.com/raw.php?i=cKeB4v4J. Pretty readable, huh?

You will then have to find a place online to store your text file (pastebin.com is a good one; your text files are hosted for free and, if you register, you can edit them as much as you want. Here are some other text-hosting sites).

Once you're happy with your new generator, all that remains to do is to share it with the world!

How do I use my generator once it's written?

To use a generator, take its source file's URL and append it to https://orteil.dashnet.org/randomgen/?gen=.

A generator stored at www.example.com/mygenerator.txt would be usable at https://orteil.dashnet.org/randomgen/?gen=www.example.com/mygenerator.txt.

If your generator is hosted on pastebin.com, you only have to refer to its identifier (the letters at the end of its url). For example, http://pastebin.com/cKeB4v4J becomes https://orteil.dashnet.org/randomgen/?gen=cKeB4v4J.

Note : when hosting your file on pastebin.com, make sure you're registered - or you won't be able to edit your generator later! Also make sure to set the file to never expire, and to make it either public or unlisted.

when hosting your file on pastebin.com, make sure you're registered - or you won't be able to edit your generator later! Also make sure to set the file to never expire, and to make it either public or unlisted. If you're not hosted on pastebin.com, make sure your file is a .txt file! Your generator won't work with any other file type.

General tips about writing generators

You can make a generator for practically anything .

. Spend some time examining the source files of other generators, you'll probably learn some cool tricks.

Remember to test your generator. A lot.

Keep backups of your generator's source - you never know!

Adding a description, picture, and some nice formatting can really help your generator stick out.

Beware of spelling mistakes, they can quickly make a generator appear very unprofessional. Use spell-check!

This page doesn't include all the tricks and subtleties of RandomGen - again, check out the source of existing generators, and see what's happening on the RandomGen subreddit!

Writing source files

Quick overview

To create a random generator, you simply have to define lists of things that reference each other. For example :



$animal cat dog fish $phrase My pet is a [animal]. I am feeding my [animal].

&amount=10

&seed=element

Global settings

$name : My Generator

$author : Author

$description : Description of my generator

$picture : http://.../pic.png

$amount : 3

$button : Another!

Inclusions

$include http://url.com

Creating lists of elements

$animal

$+animal

$>animal

fish

fish {20%}

Nesting elements

I own a [animal].

I need a quick random [word|term|thing to say].

I am eating a [[fruit]|[vegetable]|[candy]].

Identifiers

My pet is a [animal,#pet]. I've always wanted a [#pet].

My [#pet]'s name is [name,#name,written]. Would you like to see [#name]?

Attributes

$animal cat {action:meows} dog {action:barks} fish {action:swims} $phrase I have a [animal,#pet]. My [#pet] is [#pet,as action].

This will generate sentences such as "My pet is a cat", or "I am feeding my fish".The last list declared will be used as the base generator (in this case : $phrase).You can change how many items are generated by adding "" to the url; you can also change the base generator by adding "".(should be 128x128px)sets the default amount of results the generator should yieldsets the text for the "Generate" buttonThis adds to your generator everything defined in the generator at the specified URL.Inclusions should always be declared at the top of the file, before any other data.Try to use as few inclusions as possible, as they make the loading time for your generator much longer.You are encouraged to create "utility generators" full of lists (such as names or colors) that other people can include in their own generators to expand them easily.Starts a new list with the identifier "animal".Starts adding elements to the list with this identifier. This is good for expanding on included lists.Adds this element as a base generator that can be selected from the "Root" dropdown menu. (You can also apply this setting globally by having "$all roots" somewhere in your file.)Adds a new element named "fish" to the current list.Adds a new element to the current list, but this element will only have a 20% chance of being added to the random selection table.[animal] will be replaced by a random element from the $animal list.This returns one of the elements between brackets at random, without needing to create a separate list.Can even be nested with regular lists, as such :This can quickly get complicated - make sure to keep track of your brackets!Remembers the animal by its identifier (#pet) and returns the same animal in both instances.Adding "written" will record the element as its literal representation, instead of its generator. This is necessary in some cases.Check this out :

This is a bit trickier. The syntax {attribute:value} will add custom properties to elements which can be referred to later. You could use this for things such as gender, verb tenses, alternate descriptions, and so on.

My [#pet] is [#pet,as action,or sleeping]

This defines what to fall back to ("sleeping") if the specified attribute doesn't exist for an element.

Templating

$phrase Look at my %1. I love my %1 and my %2. $out "[phrase,%[cat|dog],%[wife|husband|kids]]"

Here's another way of constructing complex outputs.

This will give a phrase where %1 is replaced with [cat|dog] (which itself will be parsed into "cat" or "dog") and, if present, %2 with "wife"/"husband"/"kids".

Utilities and other fun things

There are [100-10000] leaves here.

Returns a random number between two bounds.

My name is [random syllable,x2-6].

The "x2-6" will return between two and 6 of the specified element.

There is [an] [word].

[an] will be replaced by "a" or "an", depending on the next letter.

Look at all the [animal][s]!

[s] will replace the previous word to its proper plural (this is not fool-proof and can sometimes return silly results).

The book's cover reads "[book name,title]".

The "book name" will have title-like capitalization ("my cat has asthma" will be converted to "My Cat Has Asthma").

Look at my [animal]. Look At My [Animal]. LOOK AT MY [ANIMAL]!!!

The engine will detect the proper letter case and will respectively return : "Look at my cat. Look At My Cat. LOOK AT MY CAT!!!"

This might not always work; if you need to capitalize something like [#pet], you can write [#1,Abc].

hey let's go see [movie name,lower]

"movie name" will be rendered in all lower case.

(talking fast) [phrase,compress]!

"phrase" will render with no spaces at all, so "I love horses" will become "Ilovehorses".

[word,first part]...[word,middle part]...[word,last part]

Returns a third of "word" as specified; "first part" of "abcdefghi" would display as "abc".

This is a [animal,mundane], and this is a [animal,mundane].

Normally, RandomGen tries not to repeat the same thing twice in the same output. Specifying "mundane" means that the randomly-chosen animals are allowed to be duplicates.

$allow duplicates

Adding this anywhere in your file negates the default behavior where RandomGen tries not to repeat things when picking from random selections.

[animal,#pet,hidden]My pet is [#pet,as action].

Adding "hidden" means this element won't be displayed, which lets you set identifiers without having to have them in the output text.

Shindan

$seed text : Enter your name here!

This turns your generator into a shindan. What this means is the user is prompted to enter text as a seed (usually their name), and your generator will generate the same result every time for that seed. "Shindan" is japanese for "diagnosis"; this system is often used as a fun way to determine someone's love-bound celebrity or what animal they are or to read their fortune.

You are [seed], a proud [warrior|wizard|ranger].

The keyword "seed" will be replaced by whatever seed the user inputs.

Formatting with html

Finally, you can use some html tags to add a bit of formatting.

Tags allowed are <b>, <i>, <u>, <q>, <p>, <small>, <big>, <h1>, <h2>, <h3> and <br>.

On whitespace

RandomGen trims the spaces at the start and end of lines. If you want a space there, you'll have to type it between brackets, as [ ].

Conclusion

Closing words

Ready to show off your new generator? Take its url and share it with anyone you want. Send it to your family, your friends, your dog!

People on the unofficial RandomGen subreddit or on our Discord server will be more than happy to try your generator and give you feedback. And who knows, if your generator makes enough noise, we might even end up adding it to the list!

Credits

RandomGen is an app by Orteil and Opti, 2014-2020. All rights reserved.

We hope you have as much fun using it as we had making it!

Need to contact us? See our homepage.