Update sPhone.lua

This commit is contained in:
Ale32bit 2016-11-03 13:19:34 +01:00 committed by GitHub
parent 6958692508
commit 04be0e2316

View file

@ -1,6 +1,6 @@
local function kernel() local function kernel()
_G.sPhone = { _G.sPhone = {
version = "Alpha 3.5", version = "Alpha 3.6",
user = "Guest", user = "Guest",
devMode = false, devMode = false,
mainTerm = term.current(), mainTerm = term.current(),
@ -746,6 +746,12 @@ end
end end
local config = textutils.unserialize(script.config) local config = textutils.unserialize(script.config)
if not config.id then
error("SPK: id not found",2)
end
if not config.main then
error("SPK: main not found",2)
end
writeDown(textutils.unserialize(script.files),"/.sPhone/apps/spk/"..config.id) writeDown(textutils.unserialize(script.files),"/.sPhone/apps/spk/"..config.id)
local f = fs.open("/.sPhone/apps/spk/"..config.id.."/.spk","w") local f = fs.open("/.sPhone/apps/spk/"..config.id.."/.spk","w")
f.write(textutils.serialize(config)) f.write(textutils.serialize(config))
@ -758,7 +764,11 @@ end
error("Cannot open config",2) error("Cannot open config",2)
end end
lists[config.id] = true if not config.name then
config.name = config.id
end
lists[config.id] = config.name
local f = fs.open("/.sPhone/config/spklist","w") local f = fs.open("/.sPhone/config/spklist","w")
f.write(textutils.serialize(lists)) f.write(textutils.serialize(lists))
@ -803,11 +813,11 @@ end
setfenv(loadfile(fs.combine("/.sPhone/apps/spk",config.id.."/"..config.main)), setmetatable({ setfenv(loadfile(fs.combine("/.sPhone/apps/spk",config.id.."/"..config.main)), setmetatable({
spk = { spk = {
getName = function() getName = function()
return config.name return (config.name or nil)
end, end,
getID = function() getID = function()
return config.id return (config.id or nil)
end, end,
getPath = function() getPath = function()
@ -815,11 +825,11 @@ end
end, end,
getAuthor = function() getAuthor = function()
return config.author return (config.author or nil)
end, end,
getVersion = function() getVersion = function()
return config.version return (config.version or nil)
end, end,
}, },
string = string, string = string,