Mudlib hooks

Documentation for the object-hooks functions for the mudlib in /std/object/hooks.c.

Module Information

The hook module is included as part of OBJECT, and allows a general method of allowing keeping track of and calling hooks, along with a method if specifying how multiple hooks should be resolved.

Functions

void add_hook(string tag, function hook)

add_hook(string tag, function hook) sets up the function ‘hook’ to be called whenever call_hooks(tag, …) is done. Note that if you want to remove the tag later, you have to do so with the _exact_ same function pointer.

e.g.

function my_hook = (: my_hook_func :);

add_hook(“foo”, my_hook);

remove_hook(“foo”, my_hook);

void remove_hook(string tag, function hook)

Remove a hook added with add_hook. The function pointer passed must be the same one that was passed to add_hook.

see: add_hook

void hook_state(string tag, mixed hook, int state)

hook_state(tag, hook, state) Either add or remove a hook based on the state ‘state’

varargs mixed call_hooks(string tag, mixed func, mixed start, mixed *args...)

Call a set of hooks, with the specified method for resolving multiple hooks. A setting from /include/hooks.h can be used, or a function pointer which is appropriate for implode()ing with the return values.

E.g.

call_hooks(“foo”, (: $1 + $2 :), 2) will return 2 + the sum of the return

values of the hooks

but 2 + call_hooks(“foo”, HOOK_SUM) is faster.

see: implode see: add_hook

File generated by Lima 1.1a4 reStructured Text daemon.