Update store.lua

This commit is contained in:
Ale32bit 2016-07-30 19:24:32 +02:00 committed by GitHub
parent ead0bf47ea
commit d42d0837f2

View file

@ -1,12 +1,11 @@
sPhone.winOk("Work In","Progress")
local host = "https://raw.githubusercontent.com/Sertex-Team/sPhone-Store/master/"
local host = "https://raw.github.com/Sertex-Team/sPhone-Store/master/"
local index = host.."index.lua"
local apps = host.."apps/"
local save = "/.sPhone/apps/storeApps/"
local db = "/.sPhone/apps/storeData/database"
local appsL = {}
local w, h = term.getSize()
local function redrawM()
term.setBackgroundColor(colors.white)
term.setTextColor(colors.black)
term.clear()
@ -18,6 +17,13 @@ visum.align("center"," Store",false,1)
term.setTextColor(colors.black)
term.setBackgroundColor(colors.white)
term.setCursorPos(1,3)
end
redrawM()
term.setCursorPos(1,2)
visum.align("center"," Loading",false,2)
term.setCursorPos(1,3)
local c = http.get(index).readAll()
@ -28,16 +34,38 @@ for k, v in pairs(appsIndex) do
local a = textutils.unserialize(aa)
table.insert(appsL,a)
end
function redrawA()
for i = 1, #appsL do
print(appsL[i].name)
end
end
local function redraw()
redrawM()
redrawA()
end
redrawA()
local mx,my = term.getCursorPos()
term.setCursorPos(1,2)
term.clearLine()
term.setCursorPos(mx,my)
while true do
redraw()
local _, _, x, y = os.pullEvent("mouse_click")
if x == w and y == 1 then
break
end
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 f = fs.open("/.sPhone/apps/storeApps/"..appsL[y-2].name.."/"..appsL[y-2].main,"w")
f.write(data)
f.close()
local f = fs.open("/.sPhone/apps/storeApps/"..appsL[y-2].name.."/sPhone-Main.lua","w")
f.write(textutils.serialize(appsL[y-2]))
f.close()
sPhone.winOk("Installed")
end
end