[−][src]Attribute Macro auxtools::hook
#[hook]
The hook
attribute is used to define functions that may be used as proc hooks,
and to optionally hook those procs upon library initialization.
Examples
Here we define a hook that multiplies a number passed to it by two.
It can now be used to hook procs, for example hooks::hook("/proc/double_up", double_up);
ⓘThis example is not tested
#[hook] fn double_up(num: Value) { if let Some(num) = num.as_number() { Value::from(num * 2.0); } Value::null() }
This function is used to hook /mob/proc/on_honked
.
By specifying the proc path, we hook the proc immediately upon startup.
ⓘThis example is not tested
#[hook("/mob/proc/on_honked")] fn on_honked(honker: Value) { src.call("gib", &[]); honker.call("laugh", &[]); Value::null() }