From 895750ea141a7445721adb3d92817af5a916cbac Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Tue, 5 Apr 2022 17:28:19 -0400 Subject: [PATCH] print, println, println_ts --- scada-common/util.lua | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/scada-common/util.lua b/scada-common/util.lua index f6fd611..1d4e11c 100644 --- a/scada-common/util.lua +++ b/scada-common/util.lua @@ -1,14 +1,33 @@ +-- we are overwriting 'print' so save it first +local _print = print + +-- print +function print(message) + term.write(message) +end + +-- print line +function println(message) + _print(message) +end + -- timestamped print function print_ts(message) term.write(os.date("[%H:%M:%S] ") .. message) end +-- timestamped print line +function println_ts(message) + _print(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) + _wd_timer = os.startTimer(timeout) } local get_timer = function ()