mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-28 23:58:07 +01:00
[Ready for Review] Admin lua scripting (#65635) Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com> Co-authored-by: Y0SH1M4S73R <legoboyo@earthlink.net> Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
This commit is contained in:
co-authored by
Mothblocks
Y0SH1M4S73R
parent
cc051b4cb4
commit
15a223ff2d
@@ -0,0 +1,32 @@
|
||||
#define PROMISE_PENDING 0
|
||||
#define PROMISE_RESOLVED 1
|
||||
#define PROMISE_REJECTED 2
|
||||
|
||||
/**
|
||||
* Auxtools hooks act as "set waitfor = 0" procs. This means that whenever
|
||||
* a proc directly called from auxtools sleeps, the hook returns with whatever
|
||||
* the called proc had as its return value at the moment it slept. This may not
|
||||
* be desired behavior, so this datum exists to wrap these procs.
|
||||
*/
|
||||
/datum/auxtools_promise
|
||||
var/datum/callback/callback
|
||||
var/return_value
|
||||
var/runtime_message
|
||||
var/status = PROMISE_PENDING
|
||||
|
||||
/datum/auxtools_promise/New(...)
|
||||
callback = CALLBACK(arglist(args))
|
||||
perform()
|
||||
|
||||
/datum/auxtools_promise/proc/perform()
|
||||
set waitfor = 0
|
||||
try
|
||||
return_value = callback.Invoke()
|
||||
status = PROMISE_RESOLVED
|
||||
catch(var/exception/e)
|
||||
runtime_message = e.name
|
||||
status = PROMISE_REJECTED
|
||||
|
||||
#undef PROMISE_PENDING
|
||||
#undef PROMISE_RESOLVED
|
||||
#undef PROMISE_REJECTED
|
||||
Reference in New Issue
Block a user