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 | |
| 8 | void|int <closure> ( void ) |
Zesstra | 8513612 | 2021-05-08 20:32:01 +0200 | [diff] [blame] | 9 | void <name>( void ) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 10 | |
| 11 | DESCRIPTION |
Zesstra | 7ea4a03 | 2019-11-26 20:11:40 +0100 | [diff] [blame] | 12 | Optional hook to reset an object. Hook setting can be unbound |
| 13 | lambda closures, or the name of the function (static or public) |
| 14 | to call in the object. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 15 | |
| 16 | If the hook is a closure, it is bound to the object to be |
| 17 | reset and called with no argument. |
| 18 | |
| 19 | 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] | 20 | the interval to wait before the next reset(). If the result |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 21 | is 0, the default interval computed from TIME_TO_RESET is |
Zesstra | 7ea4a03 | 2019-11-26 20:11:40 +0100 | [diff] [blame] | 22 | 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] | 23 | be reset again, unless directed otherwise by set_next_reset(). |
| 24 | |
| 25 | 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] | 26 | it is called in the object with no argument, and any result |
Zesstra | 7ea4a03 | 2019-11-26 20:11:40 +0100 | [diff] [blame] | 27 | is ignored. In this call the previous_object() is the object |
| 28 | initiating the reset. If the function does not exist, the |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 29 | object won't be reset again. |
| 30 | |
| 31 | Note that an object is only reset by call to this hook if it |
| 32 | has been used since the last reset. |
| 33 | |
| 34 | HISTORY |
| 35 | LDMud 3.2.10 allowed static functions to be given by name. |
Zesstra | 8513612 | 2021-05-08 20:32:01 +0200 | [diff] [blame] | 36 | 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] | 37 | |
| 38 | SEE ALSO |
| 39 | hooks(C) |