From d68f8f9edd898d18e8acaae80620630faa45ec46 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Fri, 4 Aug 2017 07:08:44 +1000 Subject: [PATCH] added loadfile, run and srun to shutil. --- modules/lib/shutil.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/lib/shutil.lua b/modules/lib/shutil.lua index 6470187..af33592 100644 --- a/modules/lib/shutil.lua +++ b/modules/lib/shutil.lua @@ -24,3 +24,15 @@ function mem() io.write(tostring(math.floor(computer.freeMemory()/1024)).."K\t") print(tostring(math.floor((computer.totalMemory()-computer.freeMemory())/1024)).."K\t") end +function loadfile(fn) + local f=io.open(fn,"rb") + local S=f:read("*a") + f:close() + return load(S) +end +function run(fn,...) + print(pcall(loadfile(fn),...)) +end +function srun(fn,...) + spawn(fn,print(pcall(loadfile(fn),...))) +end