From e3b570c0d882740ac8215b25a6c700185ac03257 Mon Sep 17 00:00:00 2001 From: Ale32bit Date: Tue, 15 Nov 2016 23:19:35 +0100 Subject: [PATCH] Update init.lua --- src/init.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/init.lua b/src/init.lua index 355526f..997a669 100644 --- a/src/init.lua +++ b/src/init.lua @@ -98,10 +98,10 @@ local function recovery() fs.delete("/.sPhone/cache") os.reboot() elseif k == 5 then - _G.safemode = false + safemode = false break elseif k == 6 then - _G.safemode = true + safemode = true break end end @@ -134,17 +134,11 @@ end break end end - -_G.crash = crash if not fs.exists("/.sPhone/sPhone") then crash("No OS found") end - local fscript = fs.open("/.sPhone/sPhone","r") - local script = fscript.readAll() - fscript.close() - local runningOnStartup @@ -190,11 +184,17 @@ end 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 crash(err) 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