From 8372f83779a6f8ef60b53fb99477d96d5f33fbdf Mon Sep 17 00:00:00 2001 From: Ale2610 Date: Fri, 31 Jul 2015 20:27:52 +0200 Subject: [PATCH] Update sPhone.lua --- src/sPhone.lua | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/src/sPhone.lua b/src/sPhone.lua index 71d6e86..f3a0459 100644 --- a/src/sPhone.lua +++ b/src/sPhone.lua @@ -1,5 +1,3 @@ -_G.sPhone = {} - local function crash(err) os.pullEvent = os.pullEventRaw if not err then @@ -22,8 +20,47 @@ local function crash(err) end end -function kernel() +local function kernel() + _G.sPhone = { + version = "1.0", + eApp = false, + } + if not fs.exists("/.sPhone/apis") then + fs.makeDir("/.sPhone/apis") + end + + for k, v in ipairs(fs.list("/.sPhone/apis")) do + os.loadAPI("/.sPhone/apis/"..v) + end + + function os.version() + return "sPhone "..sPhone.version + end + + local function clear() + term.setBackgroundColor(colors.white) + term.clear() + term.setCursorPos(1,1) + term.setTextColor(colors.black) + end + + os.forceShutdown = os.shutdown + os.forceReboot = os.reboot + + function os.shutdown() + clear() + print("Goodbye") + sleep(1) + os.forceShutdown() + end + + function os.reboot() + clear() + print("See you!") + sleep(1) + os.forceReboot() + end end local ok, err = pcall(kernel)