← All Workshops
MudEngine Part 8: Inventory & Chat
Step 3 / 10
Add Items to game.toml
Each room in game.toml now gets an items field — a list of item names that are lying on the ground. Players start with empty inventories.
Items are just strings — no durability, no stats, no types. This keeps the workshop focused on the architecture. You can always add item properties in a future part.
Add items to your rooms. Every room should have at least one item:
mud-engine/game.toml
[[rooms]] id = 0 name = "Forest Path" description = "A winding path leads through ancient oaks. Sunlight filters through the canopy." exits = [ { direction = "south", destination = 3 }, { direction = "east", destination = 1 }, ] items = ["rusty sword", "map fragment"] [[rooms]] id = 1 name = "Hilltop" description = "From this vantage point you can see the entire valley. A cool breeze carries the scent of pine." exits = [ { direction = "south", destination = 4 }, { direction = "west", destination = 0 }, { direction = "east", destination = 2 }, ] items = ["old compass"] [[rooms]] id = 2 name = "Abandoned Tower" description = "A crumbling stone tower stands alone. Vines crawl up its walls and crows nest in the windows." exits = [ { direction = "south", destination = 5 }, { direction = "west", destination = 1 }, ] items = ["crystal key", "dusty tome"] [[rooms]] id = 3 name = "Dark Forest" description = "Twisted trees block out most of the light. Strange sounds echo through the undergrowth." exits = [ { direction = "north", destination = 0 }, { direction = "south", destination = 6 }, { direction = "east", destination = 4 }, ] items = ["silver ring"] [[rooms]] id = 4 name = "Town Square" description = "A bustling town square with a fountain at its center. Cobblestones gleam from the morning rain." exits = [ { direction = "north", destination = 1 }, { direction = "south", destination = 7 }, { direction = "west", destination = 3 }, { direction = "east", destination = 5 }, ] items = ["loaf of bread"] [[rooms]] id = 5 name = "Temple Courtyard" description = "Ancient stone pillars surround a quiet courtyard. Moss clings to weathered statues." exits = [ { direction = "north", destination = 2 }, { direction = "south", destination = 8 }, { direction = "west", destination = 4 }, ] items = ["golden chalice"] [[rooms]] id = 6 name = "Riverbank" description = "A slow-moving river borders a muddy bank. Frogs croak from the reeds." exits = [ { direction = "north", destination = 3 }, { direction = "east", destination = 7 }, ] items = ["shiny pebble"] [[rooms]] id = 7 name = "Old Bridge" description = "A weathered stone bridge crosses the river. Moss covers the ancient masonry." exits = [ { direction = "north", destination = 4 }, { direction = "west", destination = 6 }, { direction = "east", destination = 8 }, ] items = ["lantern"] [[rooms]] id = 8 name = "Graveyard" description = "Rows of moss-covered headstones stretch into the fog. An iron gate creaks in the wind." exits = [ { direction = "north", destination = 5 }, { direction = "west", destination = 7 }, ] items = ["ancient coin"] # Players are added here at runtime by the server. # Each entry now also has an items field: # # [[players]] # id = "..." # name = "Alice" # room = 4 # items = ["rusty sword"] [[players]]
🎯 Item philosophy
For this workshop items are simple string names. This is intentional:
- The server stores
items: Vec<String>on both rooms and players - The client renders them in lists — the chat panel, inventory panel, and player list
- Validation is a simple
containscheck on the room's item list (for take) or the player's item list (for drop) - When an item is taken, it's removed from the room and added to the player (and vice versa for drop)
This design makes the workshop approachable. Once the architecture works, upgrading items to structs with descriptions, weights, or types is straightforward.
Step 3 / 10