Callback Datums
A datum that holds a proc to be called on another object, used to track proccalls to other objects
var/datum/callback/C = new(object|null, /proc/type/path|"procstring", arg1, arg2, ... argn)
var/timerid = addtimer(C, time, timertype)
you can also use the compiler define shorthand
var/timerid = addtimer(CALLBACK(object|null, /proc/type/path|procstring, arg1, arg2, ... argn), time, timertype)
Note: proc strings can only be given for datum proc calls, global procs must be proc paths
Also proc strings are strongly advised against because they don't compile error if the proc stops existing
In some cases you can provide a shortform of the procname, see the proc typepath shortcuts documentation below
var/result = C.Invoke(args, to, add)
additional args are added after the ones given when the callback was created
var/result = C.InvokeAsync(args, to, add)
Asyncronous - returns . on the first sleep then continues on in the background
after the sleep/block ends, otherwise operates normally.
(these operate on paths, not types, so to these shortcuts, datum is NOT a parent of atom, etc...)
GLOBAL_PROC_REF(procname)
CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(some_proc_here))
PROC_REF(procname)
CALLBACK(src, PROC_REF(some_proc_here))
TYPED_PROC_REF(type, procname)
CALLBACK(other, TYPED_PROC_REF(some_type_here, some_proc_here))
Vars | |
arguments | A list of arguments to pass into the proc |
---|---|
delegate | The proc we will be calling on the object |
object | The object we will be calling the proc on |
user | A weak reference to the user who triggered this callback |
Procs | |
Invoke | Invoke this callback |
InvokeAsync | Invoke this callback async (waitfor=false) |
New | Create a new callback datum |
Var Details
arguments
A list of arguments to pass into the proc
delegate
The proc we will be calling on the object
object
The object we will be calling the proc on
user
A weak reference to the user who triggered this callback
Proc Details
Invoke
Invoke this callback
Calls the registered proc on the registered object, if the user ref can be resolved it also inclues that as an arg
If the datum being called on is varedited, the call is wrapped via WrapAdminProcCall
InvokeAsync
Invoke this callback async (waitfor=false)
Calls the registered proc on the registered object, if the user ref can be resolved it also inclues that as an arg
If the datum being called on is varedited, the call is wrapped via WrapAdminProcCall
New
Create a new callback datum
Arguments
- thingtocall the object to call the proc on
- proctocall the proc to call on the target object
- ... an optional list of extra arguments to pass to the proc