DemiMUD is a MUD codebase written in Rust.
It's mostly made just for fun, and to learn Rust, with no concrete plans to run it somewhere. Given its features however, it may be a very good source of inspiration for other aspiring MUD coders.
The MUD only has about 10 commands (say
, look
, get
, drop
, map
,
movement commands and emotes).
It is able to load some basic room and mob descriptions from the Dawn of Time (repo) stock areas, and allow exploration, but no interaction with anything except for picking up and dropping objects.
Some basic support for mobprogs is available, enough to mostly support the first 13 rooms of Dawn of Time's MudSchool area, which is a great tutorial to learn the game's commands.
Mobs are able to react to speech, actions, items being given to them, and players entering the room, which brings the world to life a bit.
Because DemiMUD is a way to learn coding, DemiMUD is specifically built for development.
DemiMUD is split in two crates: netcore
and mudlib
, with mudlib
compiling
has a shared object (.dll/.so/.dylib). This split allows netcore
to keep up
connections alive while mudlib
is unloaded and reloaded again, in order to
hot-swap code.
mudlib
also uses catch_unwind()
in a couple of places and reloads the whole
world on panics while throwing away the old (likely corrupted) world, which
makes it convenient while coding new features. With something like
cargo watch
, simply saving a file and sending the restart
command is
enough to get the new code up and running.
Frustrated by the limitation of many MUDs to restrict using skills or abilities on certain types of objects (e.g. only on players, or only on mobs), I decided to make everything be an entity.
Rooms, objects, mobs, players, are all rooms.
The MUD is built to model all of its entities as containers, which allows for more natural handling of e.g. the insides of vehicles, picking up pets, allowing things to happen inside a player's inventory, etc.
Rooms and mobs are objects, and so are their exits. Someone can pick up a room, or a mob, or even pick up an exit. Don't worry, that mob is not stuck there, it can exit you by going through the exit you just picked up.
DemiMUD is not based on an Entity Component System, but it takes some concepts from it.
Rather than segregating things into types, things instead have capabilities. An object can be a weapon, have health, and be the target of a fireball, all at the same time.
The capability to contain and be contained, to be adressed (short description and gender) and to be described (internal/external descriptions) are universal.
Besides the normal multi-player net server, the MUD can also be compiled to a stand-alone single-player CLI.
Since it's a simple CLI, it also compiles to WASI. You can see a demo of it at
https://webassembly.sh/ by typing demimud
, which will run the engine inside
your browser.
Note that Firefox does not support user input outside of dialog prompts for security reasons, you'll have a better experience with other browsers for now.
The Dawn of Time areas are not included in it yet, since properly handling their license is difficult (although not impossible).
Currently only tested on Windows; there might be issues with CRLF line endings on other systems.
To build it, git clone
this repository and run cargo build --release
. You
will need the Rust compiler (see https://rustup.rs) and any of its dependencies
(e.g. MSVC build tools on Windows).
The game currently uses area data from Dawn of Time and socials from
Ultra-Envy, see the README.md file inside ./data/
on how to get them.
To run it, run cargo run --release
or run the target/release/netcore
executable directly; netcore
will then load target/release/mudlib.dll
(or
.so
or .dylib
on Linux/MacOS) from the binary's directory.