MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1 | SYNOPSIS |
| 2 | #include <sys/driver_hooks.h> |
| 3 | |
| 4 | set_driver_hook(H_RESET, value) |
| 5 | |
| 6 | <value> being: |
| 7 | |
Zesstra | 8513612 | 2021-05-08 20:32:01 +0200 | [diff] [blame] | 8 | void <name>( void ) |
Zesstra | daf2c67 | 2025-08-02 15:59:17 +0200 | [diff] [blame] | 9 | void|int <closure> ( void ) |
| 10 | void|int <closure> (object obj_to_reset) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 11 | |
| 12 | DESCRIPTION |
Zesstra | daf2c67 | 2025-08-02 15:59:17 +0200 | [diff] [blame] | 13 | Optional hook to reset an object. Hook setting can be any |
| 14 | closure, or the name of the function (static or public) to |
| 15 | call in the object. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 16 | |
Zesstra | daf2c67 | 2025-08-02 15:59:17 +0200 | [diff] [blame] | 17 | If the hook is an unbound lambda closure, it is bound to the |
| 18 | object to be reset and called with no argument. If the hook |
| 19 | is any other type of closure, it is called with the target |
| 20 | object as argument. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 21 | |
| 22 | If the result of this call is a positive number, it is used as |
Zesstra | 7ea4a03 | 2019-11-26 20:11:40 +0100 | [diff] [blame] | 23 | the interval to wait before the next reset(). If the result |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 24 | is 0, the default interval computed from TIME_TO_RESET is |
Zesstra | 7ea4a03 | 2019-11-26 20:11:40 +0100 | [diff] [blame] | 25 | used. If the result is a negative number, the object will not |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 26 | be reset again, unless directed otherwise by set_next_reset(). |
| 27 | |
| 28 | If the hook is defined as the name of an lfun in the object, |
Zesstra | 8513612 | 2021-05-08 20:32:01 +0200 | [diff] [blame] | 29 | it is called in the object with no argument, and any result |
Zesstra | 7ea4a03 | 2019-11-26 20:11:40 +0100 | [diff] [blame] | 30 | is ignored. In this call the previous_object() is the object |
| 31 | initiating the reset. If the function does not exist, the |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 32 | object won't be reset again. |
| 33 | |
| 34 | Note that an object is only reset by call to this hook if it |
| 35 | has been used since the last reset. |
| 36 | |
| 37 | HISTORY |
| 38 | LDMud 3.2.10 allowed static functions to be given by name. |
Zesstra | 8513612 | 2021-05-08 20:32:01 +0200 | [diff] [blame] | 39 | LDMud 3.6.5 removed the argument given for the lfun call. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 40 | |
| 41 | SEE ALSO |
| 42 | hooks(C) |