Update init.lua

This commit is contained in:
Ale32bit 2016-11-15 23:19:35 +01:00 committed by GitHub
parent f9a7607d34
commit e3b570c0d8

View file

@ -98,10 +98,10 @@ local function recovery()
fs.delete("/.sPhone/cache") fs.delete("/.sPhone/cache")
os.reboot() os.reboot()
elseif k == 5 then elseif k == 5 then
_G.safemode = false safemode = false
break break
elseif k == 6 then elseif k == 6 then
_G.safemode = true safemode = true
break break
end end
end end
@ -135,16 +135,10 @@ end
end end
end end
_G.crash = crash
if not fs.exists("/.sPhone/sPhone") then if not fs.exists("/.sPhone/sPhone") then
crash("No OS found") crash("No OS found")
end end
local fscript = fs.open("/.sPhone/sPhone","r")
local script = fscript.readAll()
fscript.close()
local runningOnStartup local runningOnStartup
@ -190,11 +184,17 @@ end
os.pullEvent = os.oldPullEvent os.pullEvent = os.oldPullEvent
local ok, err = pcall(function() setfenv(loadstring(script),getfenv())() end) local ok, err = pcall(function()
setfenv(loadfile("/.sPhone/sPhone"), setmetatable({
crash = crash,
safemode = safemode,
runningOnStartup = runningOnStartup,
}, {__index = getfenv()}))()
end)
if not ok then if not ok then
crash(err) crash(err)
end end
crash("Something went wrong...") 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