Update store.lua

This commit is contained in:
Ale32bit 2016-11-03 13:20:12 +01:00 committed by GitHub
parent e8b7dd9c29
commit 47f993523b

View file

@ -1,8 +1,6 @@
local host = "https://raw.github.com/Sertex-Team/sPhone-Store/master/" local host = "https://raw.github.com/Sertex-Team/sPhone-Store/master/"
local index = host.."index.lua" local index = host.."index.lua"
local apps = host.."apps/" local apps = host.."apps/"
local save = "/.sPhone/apps/storeApps/"
local db = "/.sPhone/apps/storeData/database"
local appsL = {} local appsL = {}
local w, h = term.getSize() local w, h = term.getSize()
local function redrawM() local function redrawM()
@ -29,14 +27,13 @@ local c = http.get(index).readAll()
local appsIndex = textutils.unserialize(c) local appsIndex = textutils.unserialize(c)
for k, v in pairs(appsIndex) do
local aa = http.get(apps..v.."/sPhone-Main.lua").readAll()
local a = textutils.unserialize(aa)
table.insert(appsL,a)
end
function redrawA() function redrawA()
for i = 1, #appsL do for k,v in pairs(appsIndex) do
print(appsL[i].name) print(v)
table.insert(appsL, {
path = k,
id = v,
})
end end
end end
@ -59,13 +56,15 @@ while true do
end end
if appsL[y-2] then if appsL[y-2] then
local data = http.get("https://raw.github.com/Sertex-Team/sPhone-Store/master/apps/"..appsL[y-2].storePath.."/"..appsL[y-2].main).readAll() local data = http.get("https://raw.github.com/Sertex-Team/sPhone-Store/master/apps/"..appsL[y-2].path).readAll()
local f = fs.open("/.sPhone/apps/storeApps/"..appsL[y-2].name.."/"..appsL[y-2].main,"w") local f = fs.open("/tmp/sPhoneStore/"..appsL[y-2].id..".spk","w")
f.write(data) f.write(data)
f.close() f.close()
local f = fs.open("/.sPhone/apps/storeApps/"..appsL[y-2].name.."/sPhone-Main.lua","w") local status = sPhone.install("/tmp/sPhoneStore/"..appsL[y-2].id..".spk")
f.write(textutils.serialize(appsL[y-2])) if status then
f.close() sPhone.winOk("Installed")
sPhone.winOk("Installed") else
sPhone.winOk("Error while installing")
end
end end
end end