Yogstation 13 - Modules - TypesVar Details - Proc Details

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/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

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...)

Calling a global proc (/proc/procname):

GLOBAL_PROC_REF(procname)

CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(some_proc_here))

proc defined on current(src) object or global:

PROC_REF(procname)

CALLBACK(src, PROC_REF(some_proc_here))

Callback on a type different from source:

TYPED_PROC_REF(type, procname)

CALLBACK(other, TYPED_PROC_REF(some_type_here, some_proc_here))

Vars

argumentsA list of arguments to pass into the proc
delegateThe proc we will be calling on the object
objectThe object we will be calling the proc on
userA weak reference to the user who triggered this callback

Procs

InvokeInvoke this callback
InvokeAsyncInvoke this callback async (waitfor=false)
NewCreate 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