36 lines
716 B
Lua
36 lines
716 B
Lua
local dbg_file
|
|
function dbg(...)
|
|
if dbg_file then
|
|
local out = io.open(dbg_file, "a")
|
|
if not out then return end
|
|
for i = 1, select("#", ...) do
|
|
local value = select(i, ...)
|
|
if type(value) == "table" then
|
|
out:write(textutils.serialise(value))
|
|
else
|
|
out:write(tostring(value))
|
|
out:write("\t")
|
|
end
|
|
end
|
|
out:write("\n")
|
|
out:close()
|
|
else
|
|
local pretty = require("cc.pretty")
|
|
for i = 1, select("#", ...) do
|
|
local value = select(i, ...)
|
|
pretty.pretty_print(value)
|
|
end
|
|
end
|
|
end
|
|
|
|
return setmetatable({}, { __call = function(_, file)
|
|
if dbg_file then return end
|
|
|
|
if file then
|
|
dbg_file = fs.combine(shell.dir(), file)
|
|
if dbg_file then
|
|
fs.delete(dbg_file)
|
|
end
|
|
end
|
|
end})
|