Fixes upon fixes
This commit is contained in:
parent
f48288f1a3
commit
3ae928522c
2 changed files with 47 additions and 44 deletions
11
src/init.lua
11
src/init.lua
|
@ -74,11 +74,13 @@ local function recovery()
|
|||
print("Installing sPhone...")
|
||||
sleep(0.5)
|
||||
setfenv(
|
||||
loadstring(http.get("https://raw.githubusercontent.com/SertexTeam/sPhone/master/src/installer.lua").readAll()),
|
||||
loadstring(http.get("https://raw.githubusercontent.com/SertexTeam/sPhone/master/src/installer.lua")
|
||||
.readAll()),
|
||||
getfenv())()
|
||||
elseif k == 3 then
|
||||
setfenv(
|
||||
loadstring(http.get("https://raw.githubusercontent.com/SertexTeam/sPhone/master/src/installer.lua").readAll()),
|
||||
loadstring(http.get("https://raw.githubusercontent.com/SertexTeam/sPhone/master/src/installer.lua")
|
||||
.readAll()),
|
||||
getfenv())()
|
||||
elseif k == 4 then
|
||||
fs.delete("/.sPhone/config")
|
||||
|
@ -124,9 +126,9 @@ while true do
|
|||
end
|
||||
end
|
||||
|
||||
if not fs.exists("/.sPhone/sPhone") then
|
||||
if not fs.exists("/.sPhone/sPhone.lua") then
|
||||
printError("sPhone not installed")
|
||||
shell.run("/.sPhone/init -u")
|
||||
shell.run("/.sPhone/init.lua -u")
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -145,7 +147,6 @@ end
|
|||
|
||||
if not pocket or not term.isColor() then
|
||||
printError("Computer not supported: use an Advanced Pocket Computer or an Advanced Wireless Pocket Computer")
|
||||
return
|
||||
end
|
||||
|
||||
local tArgs = { ... }
|
||||
|
|
|
@ -76,11 +76,8 @@ local function kernel(...)
|
|||
term.setTextColor(colors.black)
|
||||
if not fs.isDir("/.sPhone/autorun/" .. v) then
|
||||
if not sPhone.safeMode then
|
||||
local f = fs.open("/.sPhone/autorun/" .. v, "r")
|
||||
local script = f.readAll()
|
||||
f.close()
|
||||
print("Loading script " .. v)
|
||||
local ok, err = pcall(function() setfenv(loadstring(script), getfenv())() end)
|
||||
local ok, err = pcall(loadfile("/.sPhone/autorun/" .. v, "t", _ENV))
|
||||
if not ok then
|
||||
term.setTextColor(colors.red)
|
||||
print("Script error: " .. v .. ": " .. err)
|
||||
|
@ -1069,53 +1066,58 @@ local function kernel(...)
|
|||
local f = fs.open("/.sPhone/apps/spk/" .. spk .. "/.spk", "r")
|
||||
local script = f.readAll()
|
||||
f.close()
|
||||
_config = textutils.unserialize(script)
|
||||
local _config = textutils.unserialize(script)
|
||||
if not script then
|
||||
return false, "config corrupted"
|
||||
end
|
||||
|
||||
local result = {}
|
||||
local ok, err = pcall(function()
|
||||
result = { setfenv(loadfile(fs.combine("/.sPhone/apps/spk", _config.id .. "/files/" .. _config.main)),
|
||||
setmetatable({
|
||||
spk = {
|
||||
getName = function()
|
||||
return (_config.name or nil)
|
||||
end,
|
||||
local func, err = loadfile(
|
||||
fs.combine("/.sPhone/apps/spk", _config.id .. "/files/" .. _config.main),
|
||||
"t",
|
||||
setmetatable({
|
||||
spk = {
|
||||
getName = function()
|
||||
return (_config.name or nil)
|
||||
end,
|
||||
|
||||
getID = function()
|
||||
return (_config.id or nil)
|
||||
end,
|
||||
getID = function()
|
||||
return (_config.id or nil)
|
||||
end,
|
||||
|
||||
getPath = function()
|
||||
return "/.sPhone/apps/spk/" .. _config.id
|
||||
end,
|
||||
getPath = function()
|
||||
return "/.sPhone/apps/spk/" .. _config.id
|
||||
end,
|
||||
|
||||
getDataPath = function()
|
||||
return "/.sPhone/apps/spk/" .. _config.id .. "/data"
|
||||
end,
|
||||
getDataPath = function()
|
||||
return "/.sPhone/apps/spk/" .. _config.id .. "/data"
|
||||
end,
|
||||
|
||||
getAuthor = function()
|
||||
return (_config.author or nil)
|
||||
end,
|
||||
getAuthor = function()
|
||||
return (_config.author or nil)
|
||||
end,
|
||||
|
||||
getVersion = function()
|
||||
return (_config.version or nil)
|
||||
end,
|
||||
getVersion = function()
|
||||
return (_config.version or nil)
|
||||
end,
|
||||
|
||||
getType = function()
|
||||
return (_config.type or nil)
|
||||
end,
|
||||
getType = function()
|
||||
return (_config.type or nil)
|
||||
end,
|
||||
|
||||
open = function(file, mode)
|
||||
return fs.open("/.sPhone/apps/spk/" .. _config.id .. "/data/" .. file, mode)
|
||||
end,
|
||||
},
|
||||
string = string,
|
||||
sPhone = sPhone,
|
||||
}, { __index = getfenv() }))() }
|
||||
end)
|
||||
open = function(file, mode)
|
||||
return fs.open("/.sPhone/apps/spk/" .. _config.id .. "/data/" .. file, mode)
|
||||
end,
|
||||
},
|
||||
string = string,
|
||||
sPhone = sPhone,
|
||||
}, { __index = _ENV })
|
||||
)
|
||||
|
||||
if not func then
|
||||
return false, err
|
||||
end
|
||||
|
||||
local ok, result = pcall(func)
|
||||
if not ok then
|
||||
return false, err
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue