No active sessions yet.

No games yet.

No conversations yet.

No characters yet.

Generators

A plugin tool that makes new places, creatures and things while people are playing.

Everything else a plugin does works on things that already exist. A generator (a plugin tool) makes new ones during play, in response to what the players did.

You describe the job in a sentence:

Add one new location further into the mine, connected to where they are standing.
Put something in it: something living, something worth taking, or nothing if the
place should be empty. Reuse creatures and items this mine already has where they
fit, rather than inventing near-duplicates.

The model gets an overview of your world and makes everything the task needs in one call: places, people, items, creatures, abilities, effects, events, and sketches of what lies further on.

Where things end up

The game puts what was made where the tool fired, unless the model said otherwise:

  • a new place goes on the map next to the one it opens off (where the party is, by default)
  • a creature spawns there
  • a person lives there
  • an item drops on the ground
  • an event happens there

So it is all present this turn, and the narrator can describe it.

When it needs to look first

Some jobs read before they decide: "look at what they did to the shrine, then either restore it or let it rot; add three of these; move that camp". Set "mode": "agent" for those. The tool then runs as an agent with the editor's tools: it reads the world, edits what exists, and moves things on the map. Anything new uses the normal build step and gets placed the same way. It takes several model calls instead of one, so use it only when one call can't do the job.

Tell it to reuse

A generator that only makes new things produces a list instead of a world. The tenth room gets the tenth new monster and nothing feels like it belongs. Because it reads before it writes, it can put more of the crawlers from four rooms ago here instead. Say "reuse what fits", or it won't.

Where it writes

Everything a generator makes belongs to that play session instead of your permanent game. Two groups playing your world get different mines. Your authored game stays exactly as you left it. A generator can also make a session-only version of something you wrote, like your innkeeper in a worse mood.

Declaring one

{
  "key": "newRoom",
  "describe": "The task, in your own words.",
  "context": "'They are ' + ($.player.fields.depth || 0) + ' rooms in.'",
  "body": "$.grantAbility({ abilityExpr: $.minted.name })",
  "fallback": "Copper Bit"
}
  • describe: the task. What to make. Don't explain what an item is; it knows.
  • context: an expression giving what's happening right now, as prose. "They're nine rooms deep and just collapsed a tunnel."
  • mode: "build" (the default, one call) or "agent" (reads first; several calls).
  • body: optional rule steps to run afterwards, for anything else that should happen.
  • fallback: an authored item to use if generation fails. Always set one.

Firing it

From a rule, for mechanical triggers like a threshold, a timer, or a reached location.

if ($.field('corruption') > 80) {
  $.tool({ tool: 'spawnBloom' })
}

At the edge of the map, use the onMapEdge hook. It fires when the party arrives somewhere with every exit already visited, which is exactly when a dungeon should grow:

// hook: onMapEdge
$.tool({ tool: 'newRoom' })

The room is made on arrival, ready to enter next turn.

From the model's judgment, for questions about the fiction ("did that fight leave salvage?"): add a yes/no field to a section and fire the tool in the section's body when the answer is yes.

if ($.answer.leftSalvage) {
  $.tool({ tool: 'salvage' })
}

Acting on what it made

What was made is already placed. For anything more, like a second copy of the new item at the party's feet, use the body. You can't know the names beforehand, but you can read them here. $.minted.name is the first thing made (a new place first), $.minted.mob the first creature, $.minted.item the first item.

$.spawnItem({ itemExpr: $.minted.item })
$.grantAbility({ abilityExpr: $.minted.name })

The Expr versions take an expression, while the plain ones take a fixed name. Use one or the other.

Cost

A generator is an extra model call while the player waits: one call, and once more if the first came up empty. In agent mode it's capped (twelve tool calls and six writes, each build counting as one write). A runaway just means a slow turn at worst. It still costs something every time, so gate it. A generator with no condition runs every turn.

Put it on background when the result can wait without delaying the player. Put it on rollPreprocess when the narrator has to describe what appeared this turn.

What it can't do

  • Edit plugins. A running game doesn't rewrite its rules.
  • Delete things. A player might be holding or standing in them.
  • Change your game. Only the session.