Weird Looking: javascript mud client 2

javascript mud client 2

March 28, 2006 11:04am (4 years, 5 months and 1 week ago)
Click to enlargen
I woke up early this morning and decided to start from scratch on my javascript mud client.  After writing the single worst implementation of a web server ever (it would have gone nicely with my networking final project, which included the single worst implementation of a web client ever), I was able to get it working.

Basically, I rewrote the MUD to accept HTTP requests and wrap a javascript call around the output from each pulse.  Taking Matt's advice, I decided to use <b> tags with short class names, rather than the <span style=”color:…”> stuff I was doing before.

Example (mud prompt): <script>parent.push('<br><b class=g>&lt;20hp 100m 100mv&gt; <b class=X>');</script>

The browser downloads this “page” inside a hidden <iframe> (using the hack I previously posted for Internet Explorer, just a plain iframe for FF).  The push() function in the frame’s parent creates a new <pre> tag, stuffs the argument text inside it, then appends it to the display <div>.  Then the div’s scroll is set to the bottom.

Mud input uses a form submit handler, which takes the value of the <input> and sticks it into an XMLHttpRequest, which is sent to the aforementioned worst web server implementation ever.

I hacked it into QuickMUD rather than my own code base so that, should I ever decide to clean it up, other people can use it.

Okay, so it’s pretty trivial.  But it was fun.

Comments

Mar 28, 2006 12:04pm
I suppose if I got ambitious, the next step would be to transmit variables over the stream.  Then your current stats could show up in some sort of a heads-up display, the window’s style could change based on what type of room you’re in, it could bring up pictures of things you encounter…

You could build up a fairly media-rich game this way.  hmmm…  Now I want to do that.
Apr 3, 2006 12:12pm
Ello.  This looks quite interesting.  I’ve been pondering doing something similar - in order to try to make MUDs look less intimidating.  I wonder if you have a live demo up?
Apr 3, 2006 6:40pm
http://devel.bluecadaver.com:8080/

You can try it out, if you’re using Firefox.  My DHTML breaks IE horribly, and I don’t really want to fix it for my little proof of concept.

Also, the structure of the ROM codebase is just bad for this.  Connections are accepted in one pass of select(), and input can’t be processed until the next pass.  So there’s a 0.25-0.5 second lag on commands.  It’d probably be possible to hack in a second select() to help with that.

I’m planning the framework for a new game with threading and support for keepalive requests to throttle the AJAX stuff as much as possible.  It’ll also have a lot of other interface additions.  Basically, GUI controls like WOW and EQ have for manipulating equipment and inventory, character settings, etc.  So it’s shaping up to be a pretty long-term (but interesting) project.
Apr 4, 2006 1:32pm
That’s really quite impressive (although perhaps more because I haven’t seen it done before).  <a href=”http://cryosphere.net/”>my mud</a> has a <a href=”http://www.evilmagic.org/musicmud/”>custom codebase</a> that I think I ought to be able to hack up to do a similar thing.  My mud does stuff
like have wordwrap in the server-side output stack (so that if you resize your window it can wrap to fit), so I’m considering creating a new mud-to-client protocol that would allow  most text to be wordwrapped nicely in proportional fonts, using tables/pre when needed for tables and ascii-art, etc.  'cos i reckon the visual look of muds is a big turnoff, and more modern text formatting would be good.

anyway, yes.  i am very interested in this still ;)
Apr 4, 2006 2:52pm
I’m not entirely sure where I’d like the pretty-text-with-graphics/monospace split to be.  While I enjoy ascii-art as much as the next guy, you could also just insert an <img> tag into the stream.

I was reading MusicMUD’s documentation earlier.  I’m interested in how you embed lua into the code – scripting is something else I’ve been thinking about.  I will have to download it after work and check it out.  Speaking of which, I’m already late.
Apr 4, 2006 5:55pm
Well. basically we have objects that can have arbritrary properties on, and a bunch of properties that can be set on them get 'trapped' when certain actions happen.  E.g. an item of food could have lua.after_consume, which gets called after it has been eaten.  Several parameters get set appropriately for context, and it can then call whatever internal hooks it likes.

For more sophisticated effects, we have say, lua.before_entry, which would get called as a trap on a room, before the player tries to move there.  In addition to doing checks and printing a message, it would be able to return 'don’t let them move there’, aborting the command processing.

And then on top of that we have (at least in our version, I can’t remember whether this is in the public release yet), traps on objects, to say, get their name, so they can get totally dynamic.

Lua worked pretty well straight out of the box, although we have done a modification to it that counts instructions, so infinite loops are impossible (as we aren’t threaded).  Lua5 properly supports coroutines so in the long term we want to move to that.
Apr 5, 2006 12:33am
I downloaded it and had a look.  I actually have a pretty similar system as far as trapping events (though with a really horrible custom scripting language).

Lua seems pretty nice.  I’m also looking at Mozilla’s embeddable javascript engine, though I don’t know if it’ll work for this.

Leave a comment


Accepts BBCode with a few enhancements.