Files
VOREStation/code/controllers/hooks.dm
Kashargul 3735a31e05 Fix a bunch of issues and runtimes (#17951)
* selection target

* ugh

* fix deadmin

* larger

* fix paper icons

* those are inverted

* don't miss that

* fix all

* point transfer

* add nostrip flag to items

* un....  teppi

* .

* end life proc after qdel

* this could be null in very rare cases

* this has a lot of sleeps, someday should be refactored and check for qdeleted

* needs to be an object

* qdel check this

* use the rsc properly

* wtf?

* .

* fix narrate

* .

* push

* inform user, null it

* .

* can be null

* fix maint lurkers

* .

* spans

* .

* fix that too

* urg

* fix distillery

* don't wrap them

* needs usr

* Update cash_register.dm

* quick hook cleanup

* lots of fixes

* .

* clean that up for reasons
2025-07-05 00:45:18 -04:00

40 lines
1.0 KiB
Plaintext

/**
* @file hooks.dm
* Implements hooks, a simple way to run code on pre-defined events.
*/
/** @page hooks Code hooks
* @section hooks Hooks
* A hook is defined under /hook in the type tree.
*
* To add some code to be called by the hook, define a proc under the type, as so:
* @code
/hook/foo/proc/bar()
if(1)
return 1 //Sucessful
else
return 0 //Error, or runtime.
* @endcode
* All hooks must return nonzero on success, as runtimes will force return null.
*/
/**
* Calls a hook, executing every piece of code that's attached to it.
* @param hook Identifier of the hook to call.
* @returns 1 if all hooked code runs successfully, 0 otherwise.
*/
/proc/callHook(hook, list/arguments=null)
var/hook_path = text2path("/hook/[hook]")
if(!hook_path)
error("Invalid hook '/hook/[hook]' called.")
return 0
var/requester = new hook_path
var/status = 1
for(var/P in typesof("[hook_path]/proc"))
if(!call(requester, P)(arglist(arguments)))
error("Hook '[P]' failed or runtimed.")
status = 0
return status