Synopsis: Converting a short description to relevant keywords. April 98 From erwin@pip.dknet.dk Wed Apr 15 22:58:44 1998 Date: Wed, 15 Apr 1998 22:58:40 +0200 (MET DST) From: "Erwin S. Andreasen" X-Sender: erwin@shire.shire.dk Reply-To: erwin@pip.dknet.dk To: rom@rom.org Subject: Re: Name checking against mobs In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Status: O X-Status: On Thu, 16 Apr 1998, Zimmer wrote: > That is.. existing players w/ mobile names wouldn't be affected but new > players still wouldn't be allowed to create w/ mobile names. Mention of names and keywords prompts me to share this piece of code I use for the medit_short command: it automatically derives the keywords from the short description, skipping probably unimportant numbers and puts them in keywords. So, you just do "short the ugly little boy" and get "boy little ugly" as keywords in addition to setting the short description. This is done in reverse order, since I assume the first keyword is the important one that can be used as a short-short description in certain places (e.g. in death messages where a weapon is used to kill someone, rather than writing: Your >> the scimitar of ultimate pain << bites deep into $N, in the sudden stillness $E totters and then falls... ... it's just "Your scimitar bites deep... ". Anyway, the code is pretty simple, and looks like this (I leave figuring out where to actually call this function an exercsise to the reader :) // convert short description to a keyword list, return it str_dup'ed char * short_to_name (const char *short_desc) { char name[MSL], tmp[MSL]; char arg[MIL]; name[0] = NUL; // Strip color for short_desc // Weird cast, I don't even remember why anymore.. :) short_desc = (char*)nocolor(short_desc); do { short_desc = one_argument(short_desc, arg); if (strlen(arg) > 2 && str_cmp(arg, "the") && str_cmp(arg,"some") && str_cmp(arg, "with")) { sprintf (tmp, "%s%s%s", arg, name[0] ? " " : "", name); strcpy (name, tmp); } } while (arg[0]); if (!name[0]) strcpy (name, "no name"); return str_dup(name); } ============================================================================== Erwin Andreasen Herlev, Denmark UNIX System Programmer <*> (not speaking for) DDE ==============================================================================