← All Workshops

MudEngine Part 3: File-Based World Loading

Create game.toml

The game.toml file lives in the project root (next to Cargo.toml). It defines all rooms as an array of tables, each with a name, description, and list of exits.

Each exit has a direction and a destination — the name of the target room. Using names instead of numeric indices makes the file readable and lets you reorder rooms freely.

mud-engine-repl/game.toml
[[rooms]]
id = 1
name = "Town Square"
description = "A bustling town square with a fountain at its center. Cobblestones gleam from the morning rain."
exits = [
    { direction = "north", destination = 2 },
    { direction = "east", destination = 3 },
]

[[rooms]]
id = 2
name = "Market Street"
description = "A narrow lane lined with wooden stalls. The scent of fresh bread and spices hangs in the air."
exits = [
    { direction = "south", destination = 1 },
]

[[rooms]]
id = 3
name = "Temple Courtyard"
description = "Ancient stone pillars surround a quiet courtyard. Moss clings to weathered statues."
exits = [
    { direction = "west", destination = 1 },
]
🔍 TOML structure
  • Each room has a numeric id (unique across all rooms)
  • [[rooms]] is TOML syntax for an array of tables — each block adds one element to the rooms list
  • exits is an array of inline tables — compact { key = "value" } syntax for each exit
  • The destination is a room id, not a name. Exits reference rooms by their numeric id, which never changes even if you rename the room.

The same file can grow to 100 rooms without any code changes — the loader is the same regardless of how many rooms you define.