Skip to main content

add_succeeded_mess

Discworld tmp help

add_succeeded_mess

Name

add_succeeded_mess - For use with add_command

Syntax

void add_succeeded_mess(object dir, string mess, object *in_dir);

Description

This allows you to change the succeeded message displayed when the person succeededs with somewthing and you are using add_command.

The message given can be either a string or an array of two strings. The former is the normal use: The string is parsed from the perspective of this_player() and that of the observers, so that they get separate, grammatically correct messages. The latter permits you to give separate messages to this_player() as well as the observers.

It does several transformations on the message passed to it to get nice useful messages out of it. Each of the transformation things start with a $ and have one letter after them. A list of them follows.

$NName of the person. Changes to you when printing to the player.
$VThe verb. Puts an s on the end when it is displaying it to everyone.
$DDirect object(s). Makes a query_multiple_short list of the direct objects and stuffs it in here.
$IIndirect object(s). Same as above, but the indirect ones. These map to the ones got with %I in the original add_command.
$pPossessive string.
$oObjective string.
$rPronoun string.
$sPluralisation helper. It becomes an 's' when printed to everyting and is not placed in when printed to the originator.
$esAnother pluralisation helper. Does the same as for 's' but it replaces with 'es' instead. eg: reach -> reaches.
$yAnother pluralisation helper. It becomes a 'y' or an 'ies' depending on the pluralisation needed.

If no succeeded message is set for a given thingy. To parseing the incoming pattern to figure out the message to print. It does this fairly well...

Examples:

A good example of an object that uses add_command and this feature is /obj/misc/torch.c


/* Light up the torch */
int do_light() {
/* Check to see if we are already lit */
if (lit) {
this_player()->add_failed_mess(this_object(), "$D is already lit.\n",
({ }));
return 0;
}
/* Set ourselves as lit. */
lit = 1;
/* Tell the player about it. */
this_player()->add_succeeded_mess(this_object(), "$N $V $D, and "+
"the room glows with a soft light.\n",
({ }));
return 1;
} /* do_light() */

A chocolate where the player eating it gets a different message than others in the room.

int do_eat(){
...
this_player()->add_succeeded_mess( this_object(),
({ "You pop $D into your mouth, "
"where it melts, coating your "
"tongue in chocolate.\n",
"$N pop$s $D into $p mouth.\n", }),
({ }) );
return 1;
}

See also

add_command, add_failed_mess, add_succeeded