Mastodon Politics, Power, and Science: Building Infinite Worlds: How Nested Metadata Powers Modern TTRPG Tools

Saturday, December 6, 2025

Building Infinite Worlds: How Nested Metadata Powers Modern TTRPG Tools

 J. Rogers, SE Ohio

A journey from world maps to dungeon rooms, and everything in between

The Problem: Campaign Complexity Hell

Every dungeon master knows the struggle. You start with a world map, add some villages, toss in a dungeon or two, and suddenly you're drowning in Google Docs, loose papers, and that one critical NPC description you swear you wrote down somewhere.

Traditional TTRPG tools treat each piece of content as isolated: your world map is separate from your dungeon maps, your NPC notes live in a different document from your village descriptions, and good luck remembering which tavern was in which town.

What if your entire campaign was actually a single, interconnected web of data?

The Vision: Everything Connected

Imagine this workflow:

  1. Generate a world map from satellite-style heightmap data
  2. Place a village marker on that map
  3. Click the marker and instantly zoom into a detailed village map with buildings
  4. Click a building and explore its hand-crafted interior
  5. Find stairs in that building leading to a secret basement
  6. Discover a hidden door in that basement leading to ancient catacombs
  7. Explore 40+ procedurally generated dungeon rooms across multiple levels
  8. All while tracking NPCs, rumors, loot, and quest hooks at every level

And here's the kicker: the AI generates contextually-appropriate content at each level, using everything above it as context.

The Architecture: Portals All The Way Down

The secret sauce is treating everything as nodes connected by portals.

The Node Hierarchy

Campaign (Root)
├─ World Map (generated terrain)
│  ├─ Village: Thornhaven
│  │  ├─ Chapel of the Dawn
│  │  │  └─ Chapel Interior (3 floors)
│  │  │     └─ Secret Crypt Below
│  │  ├─ Market Square
│  │  └─ Margaret's Farm
│  └─ The Secret Dungeon
│     ├─ Sector (0,0): The Pale Apothecary
│     ├─ Sector (0,1): The Sunken Vaults
│     └─ Level 2 - Sector (0,0): The Deep Labs

Every node knows:

  • What it contains (buildings, rooms, monsters)
  • What's above it (parent context)
  • What's adjacent to it (neighboring sectors)
  • How to render itself (world map vs dungeon grid vs building floor plan)

The Portal System: Universal Connections

Instead of hardcoding "dungeon entrances" or "building doors," we use a universal portal system:

Portal {
  source: Where you are
  destination: Where you're going
  type: stairs | slide | teleporter | door | trapdoor
  bidirectional: Can you go back?
  locked: Does it need a key?
  discovered: Have players found it?
}

This single system handles:

  • Village → Building: "Click the Tavern to enter"
  • Building floor → floor: Stairs up and down
  • Dungeon → Deeper levels: One-way slides, hidden passages
  • World → Dungeon: Entrance markers
  • Secret connections: Hidden doors, teleporters

When you create a two-way staircase, the system automatically generates the return staircase at the destination. One-way traps? Just mark it as unidirectional—no matching portal appears.

The Magic: Context-Aware AI Generation

Here's where it gets interesting. When generating content, the AI sees the full context chain:

Generating a Village Building

AI sees:
- Campaign: Generic fantasy
- World: Temperate forests, established trade routes  
- Village: "Thornhaven - paranoid farmers, recent disappearances"
- Building: "Chapel of the Dawn - neglected, radiating coldness"

AI generates:
→ Interior with dusty pews, cracked holy brazier, priest's quarters
→ NPCs tied to village rumors (paranoid priest investigating well water)
→ Hidden basement with evidence of the larger mystery
→ Portal to the actual dungeon under the village

Generating a Dungeon Sector

AI sees:
- Campaign game_system: "D&D 5e", party_level: 7
- Entrance description: "Moss-covered beneath scarred oak"
- Adjacent sectors: North="Sunken Vaults (wealth)", East="Iron Foundry (heat)"
- Village context: "Missing animals, metallic water taste"

AI generates:
→ Theme: "The Pale Apothecary - fleshcrafting horror"
→ 38 rooms with D&D 5e stat blocks appropriate for level 7
→ Encounters that explain village mysteries (contaminated water source)
→ Loot that makes sense (alchemical ingredients, surgical tools)
→ Exits that thematically connect to adjacent sectors

The AI doesn't just generate isolated content—it weaves narrative threads through multiple levels of your campaign.

The Interface: Context-Aware Panels

The UI adapts to what you're looking at:

Village View

Sidebar shows:
├─ NPCs (6)
│  ├─ Father Elara @ Chapel (paranoid, sleep-deprived)
│  ├─ Ma Margaret @ Farm (offering bounty for missing dog)
│  └─ Roric 'Red' @ Stables (saw suspicious figure at well)
├─ Rumors (5)
│  ├─ [!] Priest dumping silver dust in well
│  └─ [?] Three travelers vanished asking about dungeon
└─ Locations (7) [click any to enter]

Dungeon View

Sidebar shows:
├─ Rooms (38) [12 cleared]
│  ├─ ✓ R1: Morbid Pantry (looted)
│  ├─ • R5: Dissection Theater (active: Flesh Stitcher)
│  └─ 🔒 R35: Perpetual Binding (boss - uncleared)
├─ Active Encounters (3)
│  └─ ⚔️ Flesh Stitcher (CR 6, 120 HP) [Roll Initiative]
├─ Loot Tracker
│  └─ Found: 450 GP | Unclaimed: R19, R26, R35
└─ Portals
   ├─ ⬆️ Surface Exit (Room 13)
   ├─ ⬇️ Level 2 (Room 25 - one-way slide!)
   └─ 🚪 Secret passage to Sunken Vaults

The same codebase powers everything—it just shows you what's relevant right now.

The Tech: Why This Works

1. Single Source of Truth

Everything lives in one SQLite database. Your world map settings, dungeon room states, NPC dialogues, loot distribution—it's all interconnected.

2. Lazy Loading

Don't generate the entire megadungeon upfront. Generate Sector (0,0) when players enter. Generate adjacent sectors only when they discover exits. Generate Level 2 when they find the stairs.

3. Persistent State

Track everything: Which rooms are cleared? Which NPCs have been talked to? Which portals are discovered? Which loot has been taken? Reload your campaign months later and pick up exactly where you left off.

4. System-Agnostic with System-Specific Stats

Store campaign.game_system = "dnd5e" at the top level. Every AI generation includes appropriate stat blocks:

  • D&D 5e: CR, HP, AC, attack bonuses
  • Pathfinder 2e: Level, AC, saves
  • OSE: HD, descending AC, morale
  • Generic fantasy: Difficulty ratings

5. The Portal Trigger System

CREATE TRIGGER create_reverse_portal
AFTER INSERT ON portals
WHEN NEW.is_bidirectional = 1
BEGIN
  -- Automatically create the return portal
  INSERT INTO portals (source ↔ dest)
END;

Create one staircase down, get the staircase up for free.

Real-World Example: The Mystery of Thornhaven

Let's see this in action with a complete session flow:

Session 1: World Map

  • DM generates world, places "Thornhaven" village marker
  • Clicks marker → AI generates village with 7 buildings, 6 NPCs, 5 rumors
  • Players arrive, talk to NPCs, hear about missing animals and bad-tasting well water

Session 2: Village Exploration

  • Players enter Chapel, meet Father Elara (the paranoid priest)
  • Investigate Village Well, find metallic tang in water
  • Follow animal tracks toward "Secret Dungeon" marker on village outskirts

Session 3: Dungeon - Level 1

  • Enter dungeon → AI generates Sector (0,0): The Pale Apothecary
  • 38 rooms of body horror, intelligent undead, chemical hazards
  • Clear rooms 1-13, sidebar tracks cleared status
  • Discover the water contamination source (Room 19)
  • Find locked portal to "Sunken Vaults" (needs key from boss)

Session 4: Dungeon - Deeper

  • Fall through one-way slide in Room 25 → Auto-generates Level 2
  • New AI generation uses Level 1 context: "deeper, more dangerous variant of apothecary theme"
  • Eventually find return path through hidden passage
  • Boss fight in Room 35, obtain key to north sector

Session 5: Expansion

  • Use key to unlock portal to Sector (0,1): The Sunken Vaults
  • AI generates wealth-hoard theme that connects to apothecary narrative
  • Players discover the Pale Master was accumulating resources for a ritual
  • New portals hint at even larger dungeon complex

All tracked automatically. All interconnected. All contextualized.

The Future: Infinite Possibility Space

This architecture enables some wild possibilities:

Dynamic Quest Chains: NPC in village references dungeon event, dungeon clue points to different village, creating emergent storylines

Procedural Megadungeons: Generate hundreds of sectors on-demand, each contextually connected to neighbors

Multi-Campaign Universes: Different campaigns in same database can reference shared world events

Time Progression: Update village state based on how long players spent in dungeon (rumors change, NPCs react)

Player Mapping: Auto-generate player-facing "fog of war" maps from discovered rooms and portals

The Philosophy: Structure Enables Creativity

Some DMs worry that tools like this reduce creativity. The opposite is true.

By handling the structure (how things connect, where data lives, what's been discovered), the tool frees you to focus on what matters: crafting memorable moments, roleplaying NPCs, and improvising based on player choices.

The AI generates the baseline. You add the magic.

Try It Yourself

The architecture described here is:

  • Simple: Nodes, portals, metadata—three concepts total
  • Flexible: Works for any campaign structure
  • Extensible: Add new node types or portal mechanics easily
  • Portable: SQLite database = your entire campaign in one file

Whether you're building a tool, running a campaign, or just daydreaming about megadungeons, this mental model of "everything is connected" changes how you think about TTRPG content.


What's the deepest you've nested content in your campaigns? Village → building → basement → secret cave → ancient ruin? Share your stories in the comments!


Technical Deep-Dive Links

For developers interested in implementation details:

  • Database schema for portal system
  • Context-aware AI prompt engineering
  • Sidebar panel architecture
  • Lazy-loading content generation strategies

Next article: "From Pixels to Portals: Rendering Multi-Level Dungeons on a 2D Canvas"

No comments:

Post a Comment

h vs ℏ: A Proof That Planck's Constant Is a Coordinate Choice, Not Physics

J. Rogers, SE Ohio Abstract We prove that the choice between h (Planck's constant) and ℏ (reduced Planck's constant) represents a co...