Update init.lua

This commit is contained in:
Ale32bit 2016-11-20 17:07:19 +01:00 committed by GitHub
parent 20b4071247
commit be33a44a20

View file

@ -96,6 +96,8 @@ local function recovery()
elseif k == 4 then elseif k == 4 then
fs.delete("/.sPhone/config") fs.delete("/.sPhone/config")
fs.delete("/.sPhone/cache") fs.delete("/.sPhone/cache")
fs.delete("/.sPhone/apps/spk")
fs.delete("/.sPhone/autorun")
os.reboot() os.reboot()
elseif k == 5 then elseif k == 5 then
safemode = false safemode = false
@ -129,14 +131,16 @@ end
if e == "key" and k == 56 then if e == "key" and k == 56 then
recovery() recovery()
break break
elseif e == "timer" then elseif e == "timer" and k == bootTimer then
_G.safemode = false safemode = false
break break
end end
end end
if not fs.exists("/.sPhone/sPhone") then if not fs.exists("/.sPhone/sPhone") then
crash("No OS found") printError("sPhone not installed")
shell.run("/.sPhone/init -u")
return
end end
@ -178,23 +182,16 @@ if argData["-u"] then
setfenv(loadstring(http.get("https://raw.githubusercontent.com/BeaconNet/sPhone/master/src/installer.lua").readAll()),getfenv())() setfenv(loadstring(http.get("https://raw.githubusercontent.com/BeaconNet/sPhone/master/src/installer.lua").readAll()),getfenv())()
end end
if argData["-s"] then
runningOnStartup = true
end
os.pullEvent = os.oldPullEvent os.pullEvent = os.oldPullEvent
local ok, err = pcall(function() local ok, err = pcall(function()
setfenv(loadfile("/.sPhone/sPhone"), setmetatable({ setfenv(loadfile("/.sPhone/sPhone"), setmetatable({
crash = crash, crash = crash,
safemode = safemode, safemode = safemode,
runningOnStartup = runningOnStartup,
}, {__index = getfenv()}))() }, {__index = getfenv()}))()
end) end)
if not ok then if not ok then
crash(err) crash(err)
end end
crash("sPhone stopped running!")
_G.term = nil -- The OS ends here - This string force to crash the pda to shutdown _G.term = nil -- The OS ends here - This string force to crash the pda to shutdown