When my connection goes down, it tends to be for a week or two at a time. I don't really mind so much ... it gives me a chance to catch up on pet projects and whatnot. This last time, I started working on a
MUD client.
Most everything that I develop nowadays is written in
Ruby, and there's already a great client written with it called
Muby. The problem with Muby is that its memory footprint can get huge for some reason, and its user interface likes to break.
I'd been thinking about doing this for a while, so I'd already broken out about 200 lines of code from Muby's telnet library. That's one aspect of the code that I'd had no intention of writing. I jacked the actual connection code and some ANSI handling stuff. The rest of the connection methods are simplified rethinkings of what Muby offers.
I'm using a modified version of
Term::Visual for the user interface. It looks a lot like irssi/ircII. The problems with it are that A) the text wrapping method was broken due to a miscalculation in another method and B) anything more recent than termvisual-0.0.3 seems to require a library that is only available under Mac OSX.
When it all comes down, the only part of the client that I ended up writing fully from scratch was the scripting support, and it's so piss simple that it's hard to say that I even wrote it. To give an idea of the complexity, here are some of the line counts of the files in question (the comments are intact in all of the files):
194 connection.rb # Connection code, mostly jacked from Muby
106 visual.rb # The main Term::Visual library
137 input.rb # The class for the input window in Term::Visual
197 palette.rb # The color handling code for Term::Visual
383 window.rb # The output window for Term::Visual
52 user_scripts.rb # The user scripting support
I guess the reason for the simplicity of the scripting support is that I want this thing to be plenty versatile. When it comes down, there are only three commands specified for user scripts: print, echo, and send. The first two are literally the same thing ... echo is just an alias to print. It prints a message on the user's client window (it does not send this to the MUD server ... that's what send is for).
Here's the thing, though ... the entirety of the Ruby language (and all Ruby libraries that are installed) are at the user's disposal. For example, say that I wanted to spawn a new window to display my hit points, mana points, so on ... I can just require a windowing library in my user script, set up the window, and let it fly.
The only part of the scripting system that can really be described as "bulky" is triggers. Triggers watch for certain things to come from the server, and then they do something that you've told them to do when they see that text. For example, one of my triggers waits for the text "disarms you" and then retrieves my weapon.
Long story short, I don't have a good name for this thing, so I've just called it
Muddy for the time being. I haven't put a license on it, but I'm going to go out on a limb and state that I don't much mind if you want to play with the code and improve it. Since it's just been thrown out there, the code is a bit messy. I've got a bzr repository set up for it locally, but I haven't put one on the web server yet (mostly because the only reason to do so would be the ability to receive upstream changesets, and the version of bzr that Ed's got installed can't handle the repo format created by the version that I use).
If anybody wants to come MUD some time, feel free to drop by ScryMUD ... scrymud.net, port 4444.