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...")
|
print("Installing sPhone...")
|
||||||
sleep(0.5)
|
sleep(0.5)
|
||||||
setfenv(
|
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())()
|
getfenv())()
|
||||||
elseif k == 3 then
|
elseif k == 3 then
|
||||||
setfenv(
|
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())()
|
getfenv())()
|
||||||
elseif k == 4 then
|
elseif k == 4 then
|
||||||
fs.delete("/.sPhone/config")
|
fs.delete("/.sPhone/config")
|
||||||
|
@ -124,9 +126,9 @@ while true do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if not fs.exists("/.sPhone/sPhone") then
|
if not fs.exists("/.sPhone/sPhone.lua") then
|
||||||
printError("sPhone not installed")
|
printError("sPhone not installed")
|
||||||
shell.run("/.sPhone/init -u")
|
shell.run("/.sPhone/init.lua -u")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -145,7 +147,6 @@ end
|
||||||
|
|
||||||
if not pocket or not term.isColor() then
|
if not pocket or not term.isColor() then
|
||||||
printError("Computer not supported: use an Advanced Pocket Computer or an Advanced Wireless Pocket Computer")
|
printError("Computer not supported: use an Advanced Pocket Computer or an Advanced Wireless Pocket Computer")
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local tArgs = { ... }
|
local tArgs = { ... }
|
||||||
|
|
|
@ -76,11 +76,8 @@ local function kernel(...)
|
||||||
term.setTextColor(colors.black)
|
term.setTextColor(colors.black)
|
||||||
if not fs.isDir("/.sPhone/autorun/" .. v) then
|
if not fs.isDir("/.sPhone/autorun/" .. v) then
|
||||||
if not sPhone.safeMode then
|
if not sPhone.safeMode then
|
||||||
local f = fs.open("/.sPhone/autorun/" .. v, "r")
|
|
||||||
local script = f.readAll()
|
|
||||||
f.close()
|
|
||||||
print("Loading script " .. v)
|
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
|
if not ok then
|
||||||
term.setTextColor(colors.red)
|
term.setTextColor(colors.red)
|
||||||
print("Script error: " .. v .. ": " .. err)
|
print("Script error: " .. v .. ": " .. err)
|
||||||
|
@ -1069,53 +1066,58 @@ local function kernel(...)
|
||||||
local f = fs.open("/.sPhone/apps/spk/" .. spk .. "/.spk", "r")
|
local f = fs.open("/.sPhone/apps/spk/" .. spk .. "/.spk", "r")
|
||||||
local script = f.readAll()
|
local script = f.readAll()
|
||||||
f.close()
|
f.close()
|
||||||
_config = textutils.unserialize(script)
|
local _config = textutils.unserialize(script)
|
||||||
if not script then
|
if not script then
|
||||||
return false, "config corrupted"
|
return false, "config corrupted"
|
||||||
end
|
end
|
||||||
|
|
||||||
local result = {}
|
local func, err = loadfile(
|
||||||
local ok, err = pcall(function()
|
fs.combine("/.sPhone/apps/spk", _config.id .. "/files/" .. _config.main),
|
||||||
result = { setfenv(loadfile(fs.combine("/.sPhone/apps/spk", _config.id .. "/files/" .. _config.main)),
|
"t",
|
||||||
setmetatable({
|
setmetatable({
|
||||||
spk = {
|
spk = {
|
||||||
getName = function()
|
getName = function()
|
||||||
return (_config.name or nil)
|
return (_config.name or nil)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
getID = function()
|
getID = function()
|
||||||
return (_config.id or nil)
|
return (_config.id or nil)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
getPath = function()
|
getPath = function()
|
||||||
return "/.sPhone/apps/spk/" .. _config.id
|
return "/.sPhone/apps/spk/" .. _config.id
|
||||||
end,
|
end,
|
||||||
|
|
||||||
getDataPath = function()
|
getDataPath = function()
|
||||||
return "/.sPhone/apps/spk/" .. _config.id .. "/data"
|
return "/.sPhone/apps/spk/" .. _config.id .. "/data"
|
||||||
end,
|
end,
|
||||||
|
|
||||||
getAuthor = function()
|
getAuthor = function()
|
||||||
return (_config.author or nil)
|
return (_config.author or nil)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
getVersion = function()
|
getVersion = function()
|
||||||
return (_config.version or nil)
|
return (_config.version or nil)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
getType = function()
|
getType = function()
|
||||||
return (_config.type or nil)
|
return (_config.type or nil)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
open = function(file, mode)
|
open = function(file, mode)
|
||||||
return fs.open("/.sPhone/apps/spk/" .. _config.id .. "/data/" .. file, mode)
|
return fs.open("/.sPhone/apps/spk/" .. _config.id .. "/data/" .. file, mode)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
string = string,
|
string = string,
|
||||||
sPhone = sPhone,
|
sPhone = sPhone,
|
||||||
}, { __index = getfenv() }))() }
|
}, { __index = _ENV })
|
||||||
end)
|
)
|
||||||
|
|
||||||
|
if not func then
|
||||||
|
return false, err
|
||||||
|
end
|
||||||
|
|
||||||
|
local ok, result = pcall(func)
|
||||||
if not ok then
|
if not ok then
|
||||||
return false, err
|
return false, err
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue