Documentation Area

CHAPTER 1
Extra Descriptions:
Sometimes you might want to change the long description or some item
descriptions dynamically, for example if you have a virtual gate, that
can be open or closed.
This is rather easy to implement by overwriting the function query_long()
or the function long(str).
Via query_long() you only can manipulate the long description set via
set_long() - see page 5 or https://nemesis.de/lpc/doc/room2/page5 and
page 9 or https://nemesis.de/lpc/doc/room2/page9 . query_long() returns
(does not write!!) the long description. So it might look like this:
int gate_is_open;
//[...]
query_long() {
if (gate_is_open) return query_long()+"The gate is open.\n";
return query_long()+"The gate is open.\n";
}
On the other side there is the function long() which writes(!) the
whole long description including day and night description. It is
called whenever a player 'look's, looks at/examines something or
when he/she/it is in 'verbose' mode (not 'brief' mode) and enters
a room. Its single argument is the item (here str) the player wants
to look at. If you simply look, it is called without argument. This
small example shows the use of the long function:
int gate_is_open;
//[...]
long(str) {
::long(str); /* make sure to call the original function */
if (gate_is_open && (!str || str=="gate"))
write("The gate is open.\n");
if (!gate_is_open && (!str || str=="gate"))
write("The gate is closed.\n");
}
Here "The gate is ....\n" is at the end of the room description above
the obvious exits. And by adding an item "gate" players can look at the
gate and see if it is open or close. Therefor you have to add a so-called
ID for the gate:
set_items( ({ "gate", 0 });
In this case, the item "gate" must not have a description. You can
achieve this via the '0' as description.
AND don't forget to set values like 'gate_is_open' in reset() back to
a good and valid start.
Changed/modified/modernised by Kiri in August 2016.
See also: