NAME
msg.c - give messages to several persons from one string
FUNCTIONS
msg - deliver messages
fix_msg - low level message fixer
see_names - redefine for your own purposes
USAGE
Normally you would use the function msg() to deliver messages;
some cases requires finer control. In those cases you can call
fix_msg directly. msg.c can either be inherited or used as a
daemon ("/std/msg"->msg()). Inheriting should only be used for
objects that will use msg() or fix_msg a lot.
=======================================================================
NAME
msg - deliver messages
SYNTAX
varargs void msg(string message,mixed first,mixed second, mixed third);
DESCRIPTION
This is a general-purpose routine to delivering strings to players.
The message is modified to gramatically fit each recipient. To do
this the message contains markers that will be replaced before
delivery. All markers look like this: \b
is a number specifying who this marker is about. That is 1 for
first person, 2 for second, etc. This corresponds to the 2nd, 3rd and
4th argument to this function. 1 is the default. Identifier is one of
the follwing:
OBJ Usually used for the 'object' in the sentence
(that is \b2OBJ). That is, the target of a feeling or
similar.
obj This is usually used instead of OBJ the second time around.
POSS Possessive form, for instance used when referring to
someone's head: "\b2POSS head"
poss second time you refer to someone's head, use "\b2poss head"
instead; that way it will say his/her/its head instead.
PRON The pronoun, which simply refers to the person in question,
is normally used in the beginning of sentences to represent
the person doing something: "\bPRON smile\b$.\n"
pron used instead of PRON second time around
is will be replaced with is or are
{string1,string2} will be replaced with string1 for those referred to
by and string2 for others.
$ Same as {,s}
And modifiers is zero of more of the follwing:
cap the output of this identifier will be caplitalized.
Example: "\bcapOBJ" might produce "Him"
Note that names are automatically capitalized anyway, the 'cap'
modifier should only be used in the beginning of sentences.
fix the output of this token will be the same for all players.
Example: "\bfixOBJ" will give the name of the first person
to all persons involved.
The other arguments to the function are used to specify exactly who
are first, second and third person.
First, an object or array of objects specifying who is first person,
defaults to this_player().
Second, an object or array of objects specifying who is second person,
(That is, the 'target') defaults to ({}).
Third, an object or array of objects specifying who is third person;
that is, all the rest that should see the message. msg() depends on
that there are no \b3 in the message. Defaults to all livings in
the same room as this_player() except those given in first or second.
If this isn't enough control for you, you can also give completely
different messages to first, second and third. This is done with the
\b| separator. If there is no \b| in message first second and third
will have their messages generated from the same string. If there is
one \b| first will have his/her/its/their message generated from the
first part and second and third from the second part. If there are
two \b| first, second and third will all have their own string to
generate their messages from.
A special case is also provided for simplicity: if the message
contains no \b whatsoever it will be written to 'first' (normally
this_player()) the way it is.
EXAMPLES
"/std/msg"->msg("\bPRON smile\b$ happily.\n");
/* 0 will use the default: this_player() */
"/std/msg"->msg("\bPRON \b{kiss,kisses} \b2OBJ.\n",0,target);
"/std/msg"->msg("\bPRON smile and think evil thoughts.\n"+
"\b|\bPRON smiles.\n");
=======================================================================
NAME
fix_msg - low level message fixer
SYNTAX
string fix_msg(message, mixed *persons, object active);
DESCRIPTION
This is the low-level routine used by msg(). You should normally
not have to use it. The message has the same tags as the argument
for msg() except for the \b| separators. The second argument is an
array of arrays of objects, with persons[0] representing first person,
persons[1] representing second person(s) etc. etc. The third argument
is the person for which the message should be generated. The ready-
parsed message is then returned.
=======================================================================
NAME
see_names - who can see what?
SYNTAX
int see_names(object who, object active);
DESCRIPTION
This function shouldn't actually be called, but in some cases you
will have to redefine this function. This requires that you
inherit msg.c of course. see_names is supposed to return true if
who can see active. If it returns false who will get 'Someone' instead
of the name.
=======================================================================
Help topics available:
| booklet.doc | msg.doc | msg.examples | text.doc |
You are guest number 194 since November 2019.
This file was last modified: June 2000.