← All Workshops
MudEngine Part 8: Inventory & Chat
Step 14 / 14
Congratulations!
You just added inventory, chat, and a floating HUD to the MUD engine!
What we achieved:
- Inventory system — players can take items from rooms and drop them back, with full server-side validation and real-time broadcasting
- Chat / Say — room-scoped communication using
saycommand, with client-side filtering - Floating player list — a
position: fixedpanel that follows the viewport on the right edge, showing every connected player, their room, and their carried items - Command input — a single text box handles
say,take,drop(and'shorthand) via simple text parsing - Data-driven items —
Game.tomldefines each room's initial item layout; live positions are in-memory state flushed toPlayers.tomlby the autosave task, never written back toGame.toml - Real-time inventory visibility — every pickup and drop is broadcast to all players, so everyone sees who is carrying what
Architecture recap
Client Server
────── ──────
say hello ──Say────▶ Broadcast Chat { room, from, message }
take sword ──Take───▶ Validate in-room → ground → player's items → broadcast
drop map ──Drop───▶ Validate in-inventory → player's items → ground → broadcast
│
▼
All players receive Chat / ItemTaken / ItemDropped
│
▼
Client filters chat by room, updates signals
│
▼
Autosave task writes Players.toml (Game.toml stays read-only)
What's next?
The dungeon keeps growing! Future parts could explore:
- Monsters & combat — NPCs roaming the world, attack commands, health bars, death
- Item properties — upgrade
Vec<String>to item structs with descriptions, weights, types, and usable effects - NPC chat — NPCs that respond to
saycommands with scripted dialogue - Doors & keys — lock rooms behind doors that require specific items (like the "crystal key" from the Abandoned Tower)
- Quest system — track objectives, trigger events when a player picks up certain items
- Sound effects — play audio cues when items are taken, dropped, or when a chat arrives
The MUD talks! 🗣️🎒
📚 What we learned
| Concept | How we used it |
|---|---|
| ClientMessage variants | Say, Take, Drop — new message types for inventory and chat interaction |
| Server-side validation | Take checks room inventory; Drop checks player inventory; both are atomic inside the Mutex lock |
| Action file split | Each player action (Move/Say/Take/Drop) lives in its own file under server/, keeping the mud_ws endpoint a thin dispatcher |
| Room-scoped chat | Chat messages include a room field; the client filters by comparing to the player's current room |
| Fixed-position UI | position: fixed to keep the player list pinned to the viewport edge |
| Command parsing | Splitting input on the first whitespace character to extract verb + argument |
| Item persistence | Initial item layout in Game.toml; live ground + inventory flushed to Players.toml by the autosave task |
| **Inventory visibility | Items are shown in the floating player list, room items panel, and inventory panel — all updated in real time |
| Reusable components | FloatingPlayerList and InventoryPanel extracted as separate #[component] functions with ReadOnlySignal props |
| PlayerMoved inventory | The server sends a player's real inventory in PlayerMoved, and ItemTaken/ItemDropped keep the ground in sync |
| Disconnect drops items | On cleanup, carried items are returned to the current room's ground before the player is removed; the autosave task flushes the result to Players.toml |
Step 14 / 14