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_CREATE_OB, value) |
| 5 | |
| 6 | <value> being: |
| 7 | |
Zesstra | 8513612 | 2021-05-08 20:32:01 +0200 | [diff] [blame] | 8 | void <name> ( void ) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 9 | int <closure> ( void ) |
| 10 | int <closure> (object obj_to_init) |
| 11 | |
| 12 | DESCRIPTION |
Zesstra | daf2c67 | 2025-08-02 15:59:17 +0200 | [diff] [blame] | 13 | Optional hooks to initialize an explicitly loaded object/blueprint |
| 14 | after creation. Hook setting can be any closure, or the name of |
| 15 | the function (static or public) to 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 expecting an argument, |
| 18 | it is bound to the current object and called with the created |
| 19 | object as argument. If the hook is an unbound lambda closure |
| 20 | without arguments, it is bound to the object to be initalized |
| 21 | and called. If the hook is any other type of closure, it is called |
| 22 | with the created object as argument. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 23 | |
| 24 | If the result of the closure call is a non-zero number, it is used |
| 25 | as the interval to wait before the first reset(), else the default |
| 26 | interval computed from TIME_TO_RESET is used. |
| 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 |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 30 | is ignored. |
| 31 | |
| 32 | HISTORY |
| 33 | LDMud 3.2.10 allowed static functions to be given by name. |
Zesstra | 8513612 | 2021-05-08 20:32:01 +0200 | [diff] [blame] | 34 | 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] | 35 | |
| 36 | SEE ALSO |
Zesstra | 8513612 | 2021-05-08 20:32:01 +0200 | [diff] [blame] | 37 | hooks(C), create_super(H), create_clone(H), create_lwobject(H) |