Callback Datums
A datum that holds a proc to be called on another object, used to track proccalls to other objects
USAGE
var/datum/callback/C = new(object|null, PROC_REF(procname), arg1, arg2, ... argn)
var/timerid = addtimer(C, time, timertype)
you can also use the compiler define shorthand
var/timerid = addtimer(CALLBACK(object|null, PROC_REF(procname), 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
INVOKING THE CALLBACK
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.
PROC TYPEPATH SHORTCUTS
(these operate on paths, not types, so to these shortcuts, datum is NOT a parent of atom, etc...)
proc defined on current(src) object OR overridden at src or any of its parents:
PROC_REF(procname)
CALLBACK(src, PROC_REF(some_proc_here))
global proc
GLOBAL_PROC_REF(procname)
CALLBACK(src, GLOBAL_PROC_REF(some_proc_here))
proc defined on some type
TYPE_PROC_REF(/some/type/, 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 | |
Destroy | Qdel a callback datum This is not allowed and will stack trace. callback datums are structs, if they are referenced they exist |
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
Destroy
Qdel a callback datum This is not allowed and will stack trace. callback datums are structs, if they are referenced they exist
Arguments
- force set to true to force the deletion to be allowed.
- ... an optional list of extra arguments to pass to the proc
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