#100 interactive reactor controls (start, scram, reset)

This commit is contained in:
Mikayla Fischler
2022-11-06 18:41:52 -05:00
parent aaab34f1a8
commit 806b217d58
12 changed files with 211 additions and 39 deletions

View File

@@ -27,7 +27,7 @@ end
---@param time number seconds
---@param f function callback function
function tcallbackdsp.dispatch_unique(time, f)
-- ignore if already registered
-- cancel if already registered
for timer, entry in pairs(registry) do
if entry.callback == f then
-- found an instance of this function reference, abort it
@@ -49,6 +49,18 @@ function tcallbackdsp.dispatch_unique(time, f)
-- log.debug(util.c("TCD: queued callback for ", f, " [timer: ", timer, "]"))
end
-- abort a requested callback
---@param f function callback function
function tcallbackdsp.abort(f)
for timer, entry in pairs(registry) do
if entry.callback == f then
-- cancel event and remove from registry (even if it fires it won't call)
util.cancel_timer(timer)
registry[timer] = nil
end
end
end
-- lookup a timer event and execute the callback if found
---@param event integer timer event timer ID
function tcallbackdsp.handle(event)