MudEngine Part 8: Inventory & Chat
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.
This is the world's initial item layout (static data, like the exits). Once players start taking and dropping, the live positions become in-memory state flushed to Players.toml by the autosave task from Part 7 — never written back to Game.toml.
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:
[[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"] # Game.toml stays read-only, exactly like in Part 7. # The `items` list on each room is the **initial** item layout: the server seeds # the live ground state from it at startup. As players take and drop items, the # *current* positions are tracked in memory and flushed to Players.toml by the # autosave task — never written back into this file.
For this workshop items are simple string names. This is intentional:
- The server stores ground items (
Vec<String>per room) and inventory items (Vec<String>per player) - The client renders them in lists — the chat panel, inventory panel, room items panel, and player list
- Validation is a simple
containscheck on the room's ground items (for take) or the player's inventory (for drop) - When an item is taken, it's removed from the room and added to the player (and vice versa for drop)
Where items live follows Part 7's file split. Game.toml defines the initial item layout (each room's items is the seed). From the moment the first player takes or drops something, the current positions are live state — they stay in memory and are flushed to Players.toml by the autosave task. Game.toml is never rewritten.
This design makes the workshop approachable. Once the architecture works, upgrading items to structs with descriptions, weights, or types is straightforward.