SHOW:
|
|
- or go back to the newest paste.
| 1 | os.loadAPI("uap")
| |
| 2 | - | os.loadAPI("lg")
|
| 2 | + | os.loadAPI("/lg/lg")
|
| 3 | os.loadAPI("json")
| |
| 4 | lg.setup("term")
| |
| 5 | lg.clearScreen() | |
| 6 | lg.fillScreen(colors.yellow) | |
| 7 | lg.fill(1,lg.getSize().x,3,3,colors.white) | |
| 8 | lg.drawText(2,3,colors.black,colors.white,"Updates:") | |
| 9 | str = nil | |
| 10 | obj = nil | |
| 11 | str = http.get("https://raw.githubusercontent.com/Timasbro/creatopico_os/main/apps.json").readAll()
| |
| 12 | obj = json.decode(str) | |
| 13 | local object = json.decodeFromFile("/apps.json")
| |
| 14 | local offset = 5 | |
| 15 | for key,value in pairs( obj ) do | |
| 16 | for key2,value2 in pairs( object ) do | |
| 17 | if (key == key2) then | |
| 18 | - | if (value ~= value2) then |
| 18 | + | if (value ~= value2 and key ~= "iggnore") then |
| 19 | - | lg.drawBT(key,2,string.len(value)+1,offset,offset,colors.white,colors.orange,key.." -> "..value) |
| 19 | + | lg.drawBT(key,2,string.len(key.." -> "..value)+1,offset,offset,colors.white,colors.orange,key.." -> "..value) |
| 20 | offset = offset + 2 | |
| 21 | obj[key] = nil | |
| 22 | else | |
| 23 | obj[key] = nil | |
| 24 | end | |
| 25 | end | |
| 26 | end | |
| 27 | end | |
| 28 | for key,value in pairs( obj ) do | |
| 29 | if (key ~= "iggnore") then | |
| 30 | lg.drawBT(key,2,string.len(value)+1,offset,offset,colors.white,colors.orange,key.." -> INSTALL") | |
| 31 | offset = offset + 2 | |
| 32 | end | |
| 33 | end | |
| 34 | uap.upd() | |
| 35 | while true do | |
| 36 | local event, button, x, y = os.pullEvent( "mouse_click" ) | |
| 37 | if (lg.isButton(x,y) ~= false) then | |
| 38 | str = nil | |
| 39 | obj = nil | |
| 40 | str = http.get("https://raw.githubusercontent.com/Timasbro/creatopico_os/main/pastebins.json").readAll()
| |
| 41 | obj = json.decode(str) | |
| 42 | for key,value in pairs( obj ) do | |
| 43 | if (key == lg.isButton(x,y)) then | |
| 44 | shell.run("delete",key)
| |
| 45 | shell.run("pastebin","get",value,"/"..key.."/"..key)
| |
| 46 | str2 = http.get("https://raw.githubusercontent.com/Timasbro/creatopico_os/main/apps.json").readAll()
| |
| 47 | obj2 = json.decode(str2) | |
| 48 | local object = json.decodeFromFile("/apps.json")
| |
| 49 | local name = lg.isButton(x,y) | |
| 50 | local ver = "latest" | |
| 51 | for key,value in pairs( obj2 ) do | |
| 52 | if (key == name) then | |
| 53 | ver = value | |
| 54 | end | |
| 55 | end | |
| 56 | object[name] = ver | |
| 57 | prettystring = json.encodePretty(object) | |
| 58 | local file = fs.open("apps.json","w")
| |
| 59 | file.write(prettystring) | |
| 60 | file.close() | |
| 61 | os.reboot() | |
| 62 | end | |
| 63 | end | |
| 64 | else | |
| 65 | end | |
| 66 | end | |
| 67 | term.setCursorPos(1,lg.getSize().y) | |
| 68 | lg.exit() | |
| 69 |