Files
GS13NG/datum/callback.html
2025-02-05 06:19:18 +00:00

36 lines
6.9 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><base href="../"><link rel="stylesheet" href="dmdoc.css"><title>/datum/callback - /tg/ Station 13</title></head><body><header><a href="index.html">/tg/ Station 13</a> - <a href="index.html#modules">Modules</a> - <a href="index.html#types">Types</a><a href="datum/callback.html#var">Var Details</a> - <a href="datum/callback.html#proc">Proc Details</a></header><main><h1>Callback Datums <aside>/<a href="datum.html">datum</a>/<a href="datum/callback.html">callback</a></aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/callback.dm#L43"><img src="git.png" width="16" height="16" title="code/datums/callback.dm 43"></a></h1><p>A datum that holds a proc to be called on another object, used to track proccalls to other objects</p>
<h2 id="usage">USAGE</h2>
<pre><code>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)
</code></pre>
<p>Note: proc strings can only be given for datum proc calls, global procs must be proc paths</p>
<p>Also proc strings are strongly advised against because they don't compile error if the proc stops existing</p>
<p>In some cases you can provide a shortform of the procname, see the proc typepath shortcuts documentation below</p>
<h2 id="invoking-the-callback">INVOKING THE CALLBACK</h2>
<p><code>var/result = C.Invoke(args, to, add)</code> additional args are added after the ones given when the callback was created</p>
<p><code>var/result = C.InvokeAsync(args, to, add)</code> Asyncronous - returns . on the first sleep then continues on in the background
after the sleep/block ends, otherwise operates normally.</p>
<h2 id="proc-typepath-shortcuts">PROC TYPEPATH SHORTCUTS</h2>
<p>(these operate on paths, not types, so to these shortcuts, datum is NOT a parent of atom, etc...)</p>
<h3 id="proc-defined-on-current-src-object-or-overridden-at-src-or-any-of-its-parents">proc defined on current(src) object OR overridden at src or any of it's parents:</h3>
<p>PROC_REF(procname)</p>
<p><code>CALLBACK(src, PROC_REF(some_proc_here))</code></p>
<h3 id="global-proc">global proc</h3>
<p>GLOBAL_PROC_REF(procname)</p>
<p><code>CALLBACK(src, GLOBAL_PROC_REF(some_proc_here))</code></p>
<h3 id="proc-defined-on-some-type">proc defined on some type</h3>
<p>TYPE_PROC_REF(/some/type, some_proc_here)</p><table class="summary" cellspacing="0"><tr><td colspan="2"><h2>Vars</h2></td></tr><tr><th><a href="datum/callback.html#var/arguments">arguments</a></th><td>A list of arguments to pass into the proc</td></tr><tr><th><a href="datum/callback.html#var/delegate">delegate</a></th><td>The proc we will be calling on the object</td></tr><tr><th><a href="datum/callback.html#var/object">object</a></th><td>The object we will be calling the proc on</td></tr><tr><th><a href="datum/callback.html#var/user">user</a></th><td>A weak reference to the user who triggered this callback</td></tr><tr><td colspan="2"><h2>Procs</h2></td></tr><tr><th><a href="datum/callback.html#proc/Invoke">Invoke</a></th><td>Invoke this callback</td></tr><tr><th><a href="datum/callback.html#proc/InvokeAsync">InvokeAsync</a></th><td>Invoke this callback async (waitfor=false)</td></tr><tr><th><a href="datum/callback.html#proc/New">New</a></th><td>Create a new callback datum</td></tr></table><h2 id="var">Var Details</h2><h3 id="var/arguments"><aside class="declaration">var </aside>arguments <aside> /list</aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/callback.dm#L50"><img src="git.png" width="16" height="16" title="code/datums/callback.dm 50"></a></h3><p>A list of arguments to pass into the proc</p><h3 id="var/delegate"><aside class="declaration">var </aside>delegate <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/callback.dm#L48"><img src="git.png" width="16" height="16" title="code/datums/callback.dm 48"></a></h3><p>The proc we will be calling on the object</p><h3 id="var/object"><aside class="declaration">var </aside>object <aside> /<a href="datum.html">datum</a></aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/callback.dm#L46"><img src="git.png" width="16" height="16" title="code/datums/callback.dm 46"></a></h3><p>The object we will be calling the proc on</p><h3 id="var/user"><aside class="declaration">var </aside>user <aside> /<a href="datum.html">datum</a>/weakref</aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/callback.dm#L54"><img src="git.png" width="16" height="16" title="code/datums/callback.dm 54"></a></h3><p>A weak reference to the user who triggered this callback</p><h2 id="proc">Proc Details</h2><h3 id="proc/Invoke"><aside class="declaration">proc </aside>Invoke<aside>(...) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/callback.dm#L99"><img src="git.png" width="16" height="16" title="code/datums/callback.dm 99"></a></aside></h3><p>Invoke this callback</p>
<p>Calls the registered proc on the registered object, if the user ref
can be resolved it also inclues that as an arg</p>
<p>If the datum being called on is varedited, the call is wrapped via <a href="global.html#proc/WrapAdminProcCall" title="/global">WrapAdminProcCall</a></p><h3 id="proc/InvokeAsync"><aside class="declaration">proc </aside>InvokeAsync<aside>(...) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/callback.dm#L132"><img src="git.png" width="16" height="16" title="code/datums/callback.dm 132"></a></aside></h3><p>Invoke this callback async (waitfor=false)</p>
<p>Calls the registered proc on the registered object, if the user ref
can be resolved it also inclues that as an arg</p>
<p>If the datum being called on is varedited, the call is wrapped via WrapAdminProcCall</p><h3 id="proc/New">New<aside>(thingtocall, proctocall, ...) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/callback.dm#L62"><img src="git.png" width="16" height="16" title="code/datums/callback.dm 62"></a></aside></h3><p>Create a new callback datum</p>
<p>Arguments</p>
<ul>
<li>thingtocall the object to call the proc on</li>
<li>proctocall the proc to call on the target object</li>
<li>... an optional list of extra arguments to pass to the proc</li>
</ul></main><footer>tgstation.dme <a href="https://github.com/evilew/GS13-Citadel/tree/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e">e8e0068</a> (master) — <a href="https://github.com/SpaceManiac/SpacemanDMM/blob/master/crates/dmdoc/README.md">dmdoc 1.9.0</a></footer></body></html>