← All Workshops

MudEngine Part 3: File-Based World Loading

Play!

Run the REPL just like in Part 2. The world is now loaded from Game.toml instead of being hardcoded — but the gameplay is identical.

The real power comes when you edit Game.toml and add new rooms.

Run the REPL
cargo run
Play session (expected output)
> look
Town Square
A bustling town square with a fountain at its center. Cobblestones gleam from the morning rain.

Exits: north east

> north
Market Street
A narrow lane lined with wooden stalls. The scent of fresh bread and spices hangs in the air.

Exits: south

> east
You cannot go east from here.

> south
Town Square
A bustling town square with a fountain at its center. Cobblestones gleam from the morning rain.

Exits: north east

> east
Temple Courtyard
Ancient stone pillars surround a quiet courtyard. Moss clings to weathered statues.

Exits: west

> quit
Farewell, adventurer!
mud-engine-repl/Game.toml
[[rooms]]
id = 4
name = "Dark Forest"
description = "Twisted trees block out the sky. Eyes gleam in the shadows."
exits = [
    { direction = "south", destination = 2 },
]
🎯 Add your own rooms

Open Game.toml and add the Dark Forest room (paste the snippet above into the file). Then add a matching exit in Market Street (id = 2) so you can reach it:

exits = [
    { direction = "south", destination = 4 },
    { direction = "south", destination = 1 },
]

Wait — that last edit is wrong! A room cannot have two exits with the same direction: the loader collects exits into a HashMap<String, usize>, and a duplicate "south" key silently overwrites the earlier entry — no error, just one of the destinations quietly disappearing. You would need to change one to "north" instead. Try it and see which destination wins.