Writing Advanced Messages
in KidPub Press Headquarters
In the chapter about messages, you saw how to write simple messages such as the oarrive and arrive messages on an exit.
Sometimes you want to do something more complicated. This chapter shows you how to use substitution to insert things into messages. If you haven't already read the chapter on simple messages, you might want to do that before reading this chapter.
This chapter is about some advanced work, so don't worry if you don't understand it. Most KidMud players will never use this information, but if you want to make KidMud even more magical, read on and learn!
Substitution
Any message may have one or more substitutions placed in it. A substitution takes a special group of characters, started by a % sign, and substitutes a name or location into the message. This lets you write a generic message that will be displayed with a player's name or location, different for each character.
Take a look at this string:
"%Td %t:(looks) at %dd oddly."
It has three substitutions to be made in it: `%Td', `%t:(looks)', and `%dd'.
In most cases, a substition consists of three elements:
- The % sign, indicating that a substitution should be made.
- A symbol indicating the object that should be considered.
- A symbol indicating what about that object to substitute.
The Object Specifier
The object specifier is the letter that follows the % sign. Consider the string:
"%Td %t:(looks) at %dd oddly."
In `%Td' and in `%t:', the object specifer is `t'. In `%dd', the object specifer is `d'.
The possible letters and the objects that they correspond to include:
t - represents the thing where the verb calling :pronoun_sub() is stored
n - represents the player that started the command
d - represents the direct object of the initial command
i - represents the indirect object of the initial command
l - represents the location of the player
As an example, If Munchkin typed this command:
put duck in pond
and the duck had this as a @put_in_water message:
"%Nd %n:(puts) %td in %id."
Then:
%Nd would get the `d' information on Munchkin and capitalize it.
%n:(puts) would conjugate `puts' according to Munchkin's gender.
%td would get the `d' information from the duck.
%id would get the `d' information from the pond.
The Information Specifier
The character following the object specifier is the information specifier. It specifies what sort of information to get about the object. It can be any of these characters:
n - the object's name ("Susan", "duck", "king and queen")
d - definite-article ("Susan", "the duck","the king and queen")
i - indefinite-article ("Susan", "a duck", "a king and queen")
o - the objective pronoun ("her", "him", "them")
p - possessive adjective ("her", "his", "their")
q - possessive pronoun ("hers", "his", "theirs")
r - reflexive pronoun ("herself", "himself", "themselves")
s - subjective pronoun ("she", "he, "they")
Sometimes, several characters follow the object specifier:
'i - indefinite possessive ("a duck's")
'd - definite possessive ("the duck's")
'n - possessive name ("duck's")
In using any of these, you can capitalize the object specifier to have the phrase capitalize--for example, `%Nd' might become "The duck". If you capitalize both the object specifier and the information specifier (`%ND'), you'll get all caps--"THE DUCK".
Information Specifiers for Verb Conjugation
You often want to insert a verb into a sentence, but the conjugation depends on the context that it's used in. Give this as the information specifer in order to have pronoun_sub conjugate a verb:
:(foos) - conjugate the verb `to foo'
For example:
"%ns %n:(runs)"
will result in "he runs", "she runs", or "they run", depending on the gender of the player who called the verb.
If you capitalize the verb, the result will be capitalized:
"%ns %n:(Runs)"
=> "he Runs"
Information Specifiers for Pluralizing Nouns
If you want to make a noun singular or plural depending on context, you can give the noun as an information specifier, and it will be pluralized if the object you specified is plural. This is the format of the information specification:
'(noun)
For example, this string:
"%nD %n:(shakes) %d'd %d'(hand)."
may result in either:
"Munchkin shakes Susan's hand."
or
"Munchkin shakes the king and queen's hands."
Again, capitalizing the noun will result in a capitalized substitution.
See more stories by Perry
KidPub Authors Club members can post their own stories, comment on stories they've read, play on KidMud, enter our contests, and more! Want to join in on the fun? Joining is easy!
