<HEAD> <TITLE> notify_fail - set the default error message to a specified string </TITLE> </HEAD> <BODY BACKGROUND=http://www.imaginary.com/~beek/gifs/bg.jpg TEXT=#000000 ALINK=#FFFF00 VLINK=#550000 LINK=#000099> <center> <H1> notify_fail - set the default error message to a specified string </H1> </center> <p> <b> int notify_fail( string | function str ); </b> <p> This efun is only available if NO_ADD_ACTION is not compiled in. <p> Store `str' as the error message to be returned instead of the default message `What?'. The message will be displayed if a 0 is returned from all actions setup via add_action(). This is the preferred way to display error messages since it allows other objects a chance to respond to the same verb (command). Do not use write() to display the error message since this will require you to return a 1 (unless you want to see the result of the write() in addition to the 'What?' message). However, if you do return a 1, then no other objects will get a chance to respond to the user command. <p> Note: Getting this right in the presence of multiple failures is tricky, to say the least. One can use a function pointer instead, and have the routine resolve the collisions. <p> If a function is passed instead of a string, the function is called instead of printing a message. If the function returns a string, that string is used as the failure message. Also, this_player() is set correctly, so write() can be used. <p> If "notify_fail()" is called more than once, only the last call will have an effect. <p> The idea behind this function is to allow better error messages than `What?'. <p> As a side note, notify_fail() always returns zero, so return notify_fail(...) works as expected. <p> <A HREF=add_action.html> add_action </A> <p> <HR> <ADDRESS> <A HREF=http://wagner.princeton.edu/~tim> Tim Hollebeek </A> <p> <A HREF="http://www.imaginary.com/~beek/"> Beek </A>@ZorkMUD, Lima Bean, IdeaExchange, TMI-2, and elsewhere </ADDRESS>