blob: f5664600b2cf6cfaefb3cf90b84f3fc7ced41d7c [file] [log] [blame]
Zesstrad59c3892019-11-28 20:53:39 +01001SYNOPSIS
2 int notify_fail(string str)
3 int notify_fail(closure cl)
4
Zesstra715ec202025-07-09 22:18:31 +02005DESCRIPTION
6 Store str as the error message given instead of the default
7 message ``What ?''. The result is always 0.
Zesstrad59c3892019-11-28 20:53:39 +01008
Zesstra715ec202025-07-09 22:18:31 +02009 If a closure is given, it is executed to return the error
10 message string, but not before all attempts to execute the
11 commandline failed (read: not at the time of the call to
12 notify_fail()). The closure receives as argument the original
13 commandgiver; usually it is identical to this_player(), unless
14 the modify_cmd hook changed that.
Zesstrad59c3892019-11-28 20:53:39 +010015
Zesstra715ec202025-07-09 22:18:31 +020016 If notify_fail() is called more than once for this command, only the
17 last call will be used. However, calls to notify_fail() in nested
18 commands have no effect on this command.
Zesstrad59c3892019-11-28 20:53:39 +010019
Zesstra715ec202025-07-09 22:18:31 +020020 The idea of this function is to give better error messages
21 instead of simply 'What ?'.
Zesstrad59c3892019-11-28 20:53:39 +010022
Zesstra715ec202025-07-09 22:18:31 +020023 It is also better to use
Zesstra5481d492021-04-08 20:07:06 +020024 notify_fail(message); return 0;
Zesstra715ec202025-07-09 22:18:31 +020025 instead of
Zesstrad59c3892019-11-28 20:53:39 +010026 write(message); return 1;
27
Zesstra715ec202025-07-09 22:18:31 +020028 Other objects will get the chance to evaluate the verb.
Zesstrad59c3892019-11-28 20:53:39 +010029
Zesstra715ec202025-07-09 22:18:31 +020030HISTORY
31 Returntype changed in LDMud 3.2.6 from void to int.
32 Since LDMud 3.2.7, notify-fail settings are saved over nested
33 commands, and NPCs can see their notify-fail messages.
34
35
36SEE ALSO
Zesstrad59c3892019-11-28 20:53:39 +010037 add_action(E), command(E), query_verb(E), query_command(E),
38 query_notify_fail(E), hooks(C)