Following is a routine for Hugo 2.1 that parses for extraneous "scenery" words in room descriptions. Say you have a line such as "Ribbons of rainbow light cascade off the opulent orb" in one of your room descriptions. You should never have such a line in one of your room descriptions, but if you do you might well not be interested in writing a bunch of code to handle the eventuality of the player inquiring about "ribbons," "rainbow" and "light." If these are not actual game objects, you will want some way to reply to such inquiries in a halfway intelligent fashion without going through the bother of actually making them game objects. This routine allows you to do that by checking a new property called "extra_words" for the current location each turn. If it finds a match between a word on the input line and a word in the location's extra_word list, it generates a custom error message (instead of the default "That makes no sense," which itself makes no sense in the context we're considering). There are four things required to implement this routine: 1. The new property "extra_words" must be defined somewhere in your code (it must come before the first location in your game). 2. The ExtraWords() routine itself must be either #include'd as a header or pasted somewhere into your code. In this case, I recommend pasting. 3. There must be a call to ExtraWords() immediately following the call to PreParse in the Parse() routine (i.e. you will have to edit HUGOLIB.H to add the line). Alternately, you could rename ExtraWords to PreParse and simply "replace PreParse." Either way works equally well, though the latter is better form and maintains compatibility with future versions of Hugo. 4. You must provide a custom error message. The code for steps 1 and 2 is provided in the next section. Step 3 is straightforward enough and shouldn't require explanation. Step 4 is covered at the end. !---------------------------------------------------------------------------- ! ExtraWords is a user-added routine to parse for extraneous words in room ! descriptions. If such a word is found, an appropriate message is generated ! to the player (e.g. "You don't need to refer to that."). ExtraWords takes ! no arguments. ! property extra_words ! must come before first room obj routine ExtraWords { local a, x ! a=input counter, x=extra_words cntr for (a=1; a <= words; a=a+1) { for (x=1; x <= location.#extra_words; x=x+1) { if word[a] = location.extra_words#x { ParseError(100) ! call ParseError even though } ! CustomError is going to provide } ! the error message } } !---------------------------------------------------------------------------- ! Here's how to code custom error messages. Note that you could send the ! extra-word as a second argument to make an even more specific message ! (e.g. "You don't need to refer to the ribbons") if you wanted to. In ! that case the call would be to "ParseError(100, word[a])" and the ! error message code would look like: ! ! print "You don't need to refer to the "; obj; "." ! ! Be careful when doing something like this, however. Since the extra_words ! are not game objects, Hugo has no way of determining articles and so on ! for them. You don't want to end up with a message that reads "You don't ! need to refer to the John Travolta." ! ! Also, remember that custom error messages must always be numbered 100 or ! greater. Those below 100 are reserved to Hugo and will give improper ! output if you try to use them. replace CustomError(errornumber, obj) { select errornumber case 100 print "You don't need to refer to that." case else return false } !---------------------------------------------------------------------------- Now, to use your newfound ability, simply give (where required) your room definitions the property "extra_words" and list out the words you want to have recognized. For instance: room dancehall "Studio 54" { long_desc "You are in a decadent disco parlor, with scores of scantily attired weirdos gyrating about you. A large mirror ball turns above, out of synch with the weirdos. Ribbons of rainbow light cascade off the opulent orb." extra_words "ribbons", "rainbow", "light" } The extra_words list can accommodate any number of members. Note that the extra_words property works *only* with room objects (that is to say, locations). !---------------------------------------------------------------------------- Enjoy! This document is provided as-is, with no warranty whatsoever express or implied, by Cardinal Teulbachs, Archbishop of Frith.