From 0ba3a7fe87901afe707473c23019f31587207631 Mon Sep 17 00:00:00 2001 From: Ale32bit Date: Sun, 11 Oct 2015 11:29:26 +0200 Subject: [PATCH] Update sPhone.lua --- src/sPhone.lua | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/src/sPhone.lua b/src/sPhone.lua index fd7d0a8..36613ac 100644 --- a/src/sPhone.lua +++ b/src/sPhone.lua @@ -34,6 +34,34 @@ local function crash(err) shell.run("/rom/programs/shell") end +local function recovery() + term.setBackgroundColor(colors.white) + term.setTextColor(colors.black) + term.clear() + term.setCursorPos(1,1) + print("sPhone Recovery") + print("1: Hard Reset") + print("2: Update sPhone") + print("3: Continue Booting") + while true do + local _, k = os.pullEvent("char") + if k == 1 then + for k, v in pairs(fs.list("/")) do + if not fs.isReadOnly(v) then + fs.delete(v) + end + end + print("Installing sPhone...") + sleep(0.5) + setfenv(loadstring(http.get("https://raw.githubusercontent.com/Sertex-Team/sPhone/master/src/installer.lua").readAll()),getfenv())() + elseif k == 2 then + setfenv(loadstring(http.get("https://raw.githubusercontent.com/Sertex-Team/sPhone/master/src/installer.lua").readAll()),getfenv())() + elseif k == 3 then + break + end + end +end + local function kernel() term.setBackgroundColor(colors.white) term.setCursorPos(1,1) @@ -45,9 +73,18 @@ local function kernel() else print("Missing bootImage") end - sleep(1) + local bootTimer = os.startTimer(1) + while true do + local e,k = os.pullEvent() + if e == "key" and k == 56 then + recovery() + break + elseif e == "timer" then + break + end + end _G.sPhone = { - version = "Alpha 2.4.3", + version = "Alpha 2.5", user = "Run sID", devMode = false, mainTerm = term.current()