blob: 1e7e80898ae4e9d51a1a502ccee41a161b1092f4 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001SYNOPSIS
2 #include <sys/driver_hooks.h>
3
4 set_driver_hook(H_MODIFY_COMMAND, value)
5
6 <value> being:
7
8 int|string <closure>(string cmd, object player)
9 int|string <name>(string cmd)
10 <mapping>
11
12DESCRIPTION
13 Optional hook to modify commands (both entered or given by a
Zesstradaf2c672025-08-02 15:59:17 +020014 call to command()) before the parser sees them.
MG Mud User88f12472016-06-24 23:31:02 +020015
16 Hook setting can be any closure, the name of the function to
17 call in the object, or a mapping.
18
19 For interactives this hook is used only if the interactive
20 object has no command modifier already set by the efun
21 set_modify_command().
22
23 If the hook is a closure, it is called with the entered
24 command as first, and the command giving player as second
Zesstradaf2c672025-08-02 15:59:17 +020025 argument. Unbound lambda closures are bound to the command
26 giving player.
MG Mud User88f12472016-06-24 23:31:02 +020027
28 If the hook is a string, it is used as the name of an lfun
29 in the command giving player, which is called with the command
30 as argument.
31
32 If the hook is a mapping, it is queried with the given command
33 as index, and the data retrieved is used as new command
34 (defaults to 0 if no data is stored for a given command). If
35 an entry is a closure instead of a string, it is called as
36
37 int|string <closure>(string cmd, object player)
38
39 and the result from the call is used as 'the' command.
40
41 The result is treated equal in all three cases:
42 - If the result is a string, it is the new command to execute
43 instead of the given one. Note that it is not possible to
44 make several commands from one this way!
45 - If the result is a non-zero number, the given command is to
46 be ignored. In case of the closure/lfun setting this may
47 mean that the closure/lfun already executed it.
48 - If the result is 0, the originally given command is to be
49 used.
50
51 It is possible for the hook to change the command giver
52 (this_player()) for the execution of the command. This means that
53 even though the commands are execute for the original commandgiver,
54 this_player() will return the changed commandgiver.
55
56HISTORY
57
58SEE ALSO
59 hooks(C), command(H), modify_command_fname(H), notify_fail(H),
60 send_notify_fail(H)