A
          / \      _             Play Now                         Nemesis on fb
          | |     | |  _______   _        _   _______    _______   _    _______
          | |\    | | |   ____| |  \    /  | |   ____|  /   ____| | |  /   ____|
 /-------/-------------------------------------------------------------------,
O= Home <=XX|  About  News  Pics  Adventurers  Wizards  Download  Connect     >
 \-------\-------------------------------------------------------------------'
          | |   \   | |  |____  | |      | | |  |____   ___ \  \  | |  ___ \  \
          | |     \_| |_______| |_|      |_| |_______| |_______/  |_| |_______/
          \ /
           V  

Documentation Area

Document Path: /doc/room2/page15


<
                                  CHAPTER 1                                     
Extra Actions:

   Sometimes players should not only be able to examine objects but
   perform actions on them. For example, per convention signs should be
   readable (AND should be "examinable").

   Actions can be given to the player using the init function. It's called
   whenever a player enters the room (to be exact: whenever a living object
   "gets in contact" with another object). Add a sign to your long desc and
   a room item for the sign via set_items and add the following code to the
   end of your file:

extra_init() {
	add_action("read", "read");
}

/* You also can do it this way - without the "//" but you have to call the
 * original init function via '::init()'!
//init() {
//	::init();       // This calls init in the room code to enable exits
//	add_action("read", "read");
//}
 * By using extra_init() the original init is called automatically!
 */

read(str) {
	if (valid_id(str) != "sign") return 0; // getting the "right" sign!
	if (this_player()->test_dark()) return 1; // reading in darkness? NO ;)
	say(this_player()->query_name()+" reads the sign.\n");
	long(str); // simply take the room item :-) you should have set it :-)
	return 1;
}

   This shows the use of init in room2 rooms. The exact working of all the
   functions above is explained on another place.

   Perspectives: An easy to use 'read' add_action is planned like the
   READ_CMD feature of EXTD_ROOM, but without EXTD_ROOM. For EXTD_ROOM see
   page 18 or https://nemesis.de/lpc/doc/room2/page18 and for READ_CMD see
   page 21 or https://nemesis.de/lpc/doc/room2/page21 .

   And about signs, signpost and other readable things:
   Please have a look at the note "Re: Read or Look at Signs??" (Kiri, Jun
   12 2016) on the complaints board in the sheriff's office in the village
   ('goto /room/sheriff/office2') or https://nemesis.de/lpc/board/4 .

   Changed/modified/modernised by Kiri in August 2016.

See also:
>

This page was generated in LPC

Imprint / Impressum