A better “say”

This is the second “challenge” post.  The first challenge post explains what they are.

Improving the “say” command

The first half of this challenge is to improve the “say” command.  As you recall from previous posts, commands are in /command/*.c.  Here are some things wrong with it that you should fix.

  • It does not print any message to the person doing the speaking.  That can be disconcerting, and is confusing when you look back over a conversation to see only the other person’s comments.  (In fact, it doesn’t look like a conversation at all!)
  • It does not capitalize the names of the people speaking.  For example, you might see this:
    jim says: hello
    That’s hardly good style.  Tweak this so you get this instead:
    Jim says: hello
  • If you’re feeling really ambitious (I wasn’t) you can make it use quotation marks correctly, like this:
    Jim says, “Hello.”
    Recall that this can get quite confusing with nested quotes and whether the user put their own punctuation on, etc.


In an earlier post I advocated replacing all publicly-facing instances of the string “Lil” in your lib with your MUD’s name.  There are two problems with this.

  • Although I happen to be writing a lib-and-MUD combination, you may just be writing a lib and intending others to make MUDs.  So why hardcode the name of the MUD into your lib?
  • It forces you to put the same string in more than one place (not only the one or more instances of the thing in the lib, but also the instance you already put in the config file way back when).

It turns out that the name you put in the config file is actually available to you, in code, provided by the driver.  The MUD_NAME #define is guaranteed to be a string containing the name from the config file.  (Who knew?  Well, the docs did, actually.  That’s where I found it.)

So the second half of this challenge is to use MUD_NAME instead of each instance of the actual string literal containing the name of your MUD.  Just a search-and-destroy, this one.

  1. #1 by Vitamin D on April 16, 2012 - 4:23 pm

    salutations from over the ocean. interesting article I will return for more.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: