reactor control and safety system attempting server connection

This commit is contained in:
Mikayla Fischler
2022-01-01 19:45:33 -05:00
parent 0dac25d9e7
commit 26cce3a46a
7 changed files with 407 additions and 0 deletions

29
common/util.lua Normal file
View File

@@ -0,0 +1,29 @@
-- timestamped print
function print_ts(message)
term.write(os.date("[%H:%M:%S] ") .. message)
end
-- ComputerCraft OS Timer based Watchdog
-- triggers a timer event if not fed within 'timeout' seconds
function new_watchdog(timeout)
local self = {
_timeout = timeout,
_wd_timer = os.startTimer(_timeout)
}
local get_timer = function ()
return self._wd_timer
end
local feed = function ()
if self._wd_timer ~= nil then
os.cancelTimer(self._wd_timer)
end
self._wd_timer = os.startTimer(self._timeout)
end
return {
get_timer = get_timer,
feed = feed
}
end