print, println, println_ts
This commit is contained in:
@@ -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
|
-- timestamped print
|
||||||
function print_ts(message)
|
function print_ts(message)
|
||||||
term.write(os.date("[%H:%M:%S] ") .. message)
|
term.write(os.date("[%H:%M:%S] ") .. message)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- timestamped print line
|
||||||
|
function println_ts(message)
|
||||||
|
_print(os.date("[%H:%M:%S] ") .. message)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- ComputerCraft OS Timer based Watchdog
|
-- ComputerCraft OS Timer based Watchdog
|
||||||
-- triggers a timer event if not fed within 'timeout' seconds
|
-- triggers a timer event if not fed within 'timeout' seconds
|
||||||
function new_watchdog(timeout)
|
function new_watchdog(timeout)
|
||||||
local self = {
|
local self = {
|
||||||
_timeout = timeout,
|
_timeout = timeout,
|
||||||
_wd_timer = os.startTimer(_timeout)
|
_wd_timer = os.startTimer(timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
local get_timer = function ()
|
local get_timer = function ()
|
||||||
|
|||||||
Reference in New Issue
Block a user