ddonche/goblin-lang
0.46.24
1
0
docs tutorial
[[goblin-ipsum-generator]]

Goblin Ipsum Generator


This recipe shows how to generate randomized "Goblin Lorem Ipsum" — nonsense placeholder text written in a fantasy goblin dialect. It's a great way to learn Goblin's pick, shuffle, join, collect, and pack features all in one script.

Ingredients

  • A word list of goblin-flavored nouns, names, and adjectives
  • A list of common connective words (prepositions, articles, etc.)
  • A dash of randomization for shuffling and capitalization

Step 1: Build Your Word Lists

First, define two arrays — one for goblin flavor words, one for common connective words:

gbln_words | [
    "grak", "snortum", "shinies", "grotto", "cave",
    "stash", "fang", "hoard", "bones", "gold",
    "goblin", "witch", "wizard", "troll", "ogre",
    "elf", "dwarf", "orc", "beast", "monster",
]

commons | [
    "the", "and", "in", "under", "over",
    "of", "a", "this", "that", "little",
    "quiet", "strange", "broken", "big", "tiny",
]
gbln_words | [
    "grak", "snortum", "shinies", "grotto", "cave",
    "stash", "fang", "hoard", "bones", "gold",
    "goblin", "witch", "wizard", "troll", "ogre",
    "elf", "dwarf", "orc", "beast", "monster",
]

commons | [
    "the", "and", "in", "under", "over",
    "of", "a", "this", "that", "little",
    "quiet", "strange", "broken", "big", "tiny",
]

Keep gbln_words big and flavorful. Keep commons short — these are just the glue words that make sentences feel natural.

Step 2: Build a Sentence

Create an action that generates one sentence:

act goblin_ipsum_sentence
    wc, wc2 | [ pick 1 from 2...18, pick 1 from 2...6 ]
    rest_words   | pick {wc} from gbln_words with dups
    common_words | pick {wc2} from commons with dups
    all | shuffle(rest_words + common_words)
    all[0] |! :title(all[0])
    final | :join(all, " ")
    final + ". "
xx
act goblin_ipsum_sentence
    wc, wc2 | [ pick 1 from 2...18, pick 1 from 2...6 ]
    rest_words   | pick {wc} from gbln_words with dups
    common_words | pick {wc2} from commons with dups
    all | shuffle(rest_words + common_words)
    all[0] |! :title(all[0])
    final | :join(all, " ")
    final + ". "
xx

Let's break this down:

  • wc and wc2 use tuple assignment to get two random counts on one line — wc is how many goblin words to use, wc2 is how many common words
  • pick {wc} from gbln_words with dups picks that many words, allowing repeats
  • shuffle mixes the goblin and common words together randomly
  • all[0] |! :title(all[0]) capitalizes the first word in place using the mutate-assign operator |!
  • :join(all, " ") combines the array into a single space-separated string
  • The sentence ends with ". " so paragraphs flow naturally

Step 3: Build a Paragraph

Use collect to run the sentence generator multiple times and gather the results:

act goblin_ipsum_paragraph
    sc | pick 1 from 3...7
    sentences | collect sc of goblin_ipsum_sentence()
    :pack(sentences)
xx
act goblin_ipsum_paragraph
    sc | pick 1 from 3...7
    sentences | collect sc of goblin_ipsum_sentence()
    :pack(sentences)
xx

  • sc is a random sentence count between 3 and 6
  • collect sc of goblin_ipsum_sentence() runs the sentence action sc times and returns all results as an array — no manual loop needed
  • :pack(sentences) compresses the array of sentences into one string
Note
collect is shorthand for the loop pattern below. Both produce the same result:

/// longhand
sentences | []
repeat sc
    s | goblin_ipsum_sentence()
    put_last!(sentences, s)
xx

/// shorthand
sentences | collect sc of goblin_ipsum_sentence()
/// longhand
sentences | []
repeat sc
    s | goblin_ipsum_sentence()
    put_last!(sentences, s)
xx

/// shorthand
sentences | collect sc of goblin_ipsum_sentence()

Step 4: The Main Loop

Wrap everything in an interactive loop that asks how many paragraphs to generate:

act goblin_ipsum
    repeat
        para_count | :ask("How many paragraphs? (1-5)").int
        if (para_count >= 1) and (para_count <= 5)
            repeat para_count
                say goblin_ipsum_paragraph() + "\n"
            xx
        else
            say "Please enter a number between 1 and 5."
        xx
    xx
xx
act goblin_ipsum
    repeat
        para_count | :ask("How many paragraphs? (1-5)").int
        if (para_count >= 1) and (para_count <= 5)
            repeat para_count
                say goblin_ipsum_paragraph() + "\n"
            xx
        else
            say "Please enter a number between 1 and 5."
        xx
    xx
xx

  • repeat with no argument runs forever — this is Goblin's infinite loop
  • :ask(...) prompts the user for input, .int converts it to an integer
  • The inner repeat para_count generates one paragraph per iteration, printing each with a trailing newline
  • Invalid input loops back and asks again

Step 5: Run It

goblin_ipsum()
goblin_ipsum()

Sample Output

Grotto troll under the hoard quiet elf gold. Stash broken ogre this of. Big fang shinies strange beast little the grak. Snortum cave a witch tiny bones.
Wizard over orc that stash. The monster gold grotto goblin. Strange bones troll of elf hoard under tiny. Ogre and the cave little grak wizard. Broken beast over shinies.

Tips

  • Make gbln_words larger for more variety — the bigger the list, the less repetition
  • Adjust the 2...18 range in wc to control sentence length — smaller numbers give tighter sentences
  • Swap pick for secure_pick if you want cryptographically random output (overkill for ipsum, but it works)
  • The with dups flag allows the same word to appear multiple times in one sentence — remove it for more variety at the cost of needing a larger word list
  • You can also call collect as a function: collect(sc, goblin_ipsum_sentence())

Full Script

gbln_words | [
    "grak", "snortum", "jabberfang", "muck-pit", "shinies", "grotto", "cave", "rev", "pain",
    "skitter", "chitter", "scrapclave", "bog-brew", "stash", "fang", "hidden", "treasures", "keeper",
    "tether", "hoard", "bones", "gold", "lock", "club", "hut", "clan", "warrior",
    "graveyard", "coin", "loot", "glam-glam", "mutton", "hock", "priest", "priestess", "magic", "sorceror",
    "boom", "goblin", "filch", "snicker", "clank", "rusty", "witch", "wizard", "feast", "supper", "rotten",
    "ogre", "giant", "beast", "monster", "elf", "dwarf", "hobbit", "orc", "troll", "gremlin", "imp", "demons",
    "bats", "spider", "snake", "pirates", "ghouls", "coffin", "totem", "power", "knife", "stick",
    "many-many", "doggums", "yum-yum", "lashy", "terribles",
]

commons | [
    "the", "and", "in", "under", "over", "through", "with", "from", "above", "if",
    "of", "a", "this", "that", "little", "old", "hungry", "loud", "go",
    "quiet", "strange", "broken", "big", "tiny", "at", "there", "be", "for", "out",
]

act goblin_ipsum_sentence
    wc, wc2 | [ pick 1 from 2...18, pick 1 from 2...6 ]
    rest_words   | pick {wc} from gbln_words with dups
    common_words | pick {wc2} from commons with dups
    all | shuffle(rest_words + common_words)
    all[0] |! :title(all[0])
    final | :join(all, " ")
    final + ". "
xx

act goblin_ipsum_paragraph
    sc | pick 1 from 3...7
    sentences | collect sc of goblin_ipsum_sentence()
    :pack(sentences)
xx

act goblin_ipsum
    repeat
        para_count | :ask("How many paragraphs? (1-5)").int
        if (para_count >= 1) and (para_count <= 5)
            repeat para_count
                say goblin_ipsum_paragraph() + "\n"
            xx
        else
            say "Please enter a number between 1 and 5."
        xx
    xx
xx

goblin_ipsum()
gbln_words | [
    "grak", "snortum", "jabberfang", "muck-pit", "shinies", "grotto", "cave", "rev", "pain",
    "skitter", "chitter", "scrapclave", "bog-brew", "stash", "fang", "hidden", "treasures", "keeper",
    "tether", "hoard", "bones", "gold", "lock", "club", "hut", "clan", "warrior",
    "graveyard", "coin", "loot", "glam-glam", "mutton", "hock", "priest", "priestess", "magic", "sorceror",
    "boom", "goblin", "filch", "snicker", "clank", "rusty", "witch", "wizard", "feast", "supper", "rotten",
    "ogre", "giant", "beast", "monster", "elf", "dwarf", "hobbit", "orc", "troll", "gremlin", "imp", "demons",
    "bats", "spider", "snake", "pirates", "ghouls", "coffin", "totem", "power", "knife", "stick",
    "many-many", "doggums", "yum-yum", "lashy", "terribles",
]

commons | [
    "the", "and", "in", "under", "over", "through", "with", "from", "above", "if",
    "of", "a", "this", "that", "little", "old", "hungry", "loud", "go",
    "quiet", "strange", "broken", "big", "tiny", "at", "there", "be", "for", "out",
]

act goblin_ipsum_sentence
    wc, wc2 | [ pick 1 from 2...18, pick 1 from 2...6 ]
    rest_words   | pick {wc} from gbln_words with dups
    common_words | pick {wc2} from commons with dups
    all | shuffle(rest_words + common_words)
    all[0] |! :title(all[0])
    final | :join(all, " ")
    final + ". "
xx

act goblin_ipsum_paragraph
    sc | pick 1 from 3...7
    sentences | collect sc of goblin_ipsum_sentence()
    :pack(sentences)
xx

act goblin_ipsum
    repeat
        para_count | :ask("How many paragraphs? (1-5)").int
        if (para_count >= 1) and (para_count <= 5)
            repeat para_count
                say goblin_ipsum_paragraph() + "\n"
            xx
        else
            say "Please enter a number between 1 and 5."
        xx
    xx
xx

goblin_ipsum()

Try It Yourself

  • Save the script as ipsum.gob
  • Run goblin run ipsum.gob from your shell
  • Or drop it in your api directory, run goblin start, and visit http://localhost:5173/api/ipsum in your browser