← All Workshops

MudEngine Part 8: Inventory & Chat

From Movement to Interaction

In Part 6 and Part 7 players could walk around the 3×3 grid and see each other in real time. But they couldn't interact — no picking things up, no talking to each other, no sense of shared space beyond a location indicator.

In this part we add three features that turn a map into a living world:

1. Inventory system

Rooms contain items (defined in game.toml). Players can take items from the current room into their inventory and drop them back. Every pickup and drop is broadcast to all players, so everyone sees who is carrying what.

2. Chat / Say

Players type say Hello! (or just `"Hello!") and the message appears to every other player in the same room. This creates a shared-space communication channel — what you say is only heard by those nearby.

3. Floating player list

The sidebar from Part 6 becomes a fixed-position panel that stays glued to the right edge of the screen. It always shows every connected player, their current room, and what items they carry — updated in real time.

Architecture

ClientMessage::Say { message }  ──▶  Server broadcasts Chat { from, message, room }
ClientMessage::Take { item }    ──▶  Server moves item from room → player, broadcasts
ClientMessage::Drop { item }    ──▶  Server moves item from player → room, broadcasts

The server is still the single source of truth for every action. All inventory changes are validated before they happen: you can only take items that exist in your current room, and you can only drop items you actually have.

"Server" "Player A" "Player B" "ClientMessage" "Broadcast" "Chat / ItemTaken / ItemDropped" say hello take sword drop shield Validate action Update GameState save_game_state() Broadcast to all players Sees chat + inventory changes