AndreSoYeah

App Store

Jan 5th, 2013
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.34 KB | None | 0 0
  1. function askReplace()
  2.     write("Replace existing AppStore install?\n(Y/N)")
  3.     local resp = read()
  4.     if not (resp=="Y" or resp=="N") then
  5.         print("Please type \"Y\" or \"N\".")
  6.         return askReplace()
  7.     end
  8.     if(resp=="N") then
  9.         print("User cancelled reinstall.")
  10.         error()
  11.     end
  12.     fs.delete("AppStore")
  13. end
  14. if fs.exists("AppStore") then askReplace() end
  15.  
  16.  
  17. fs.makeDir("AppStore")
  18. function downloadFromSource(url_end,id)
  19.     url = "http://dl.dropbox.com/u/133665124/computercraft/appstore-install/"..url_end
  20.     local filecontents = nil
  21.     local link=http.get(url)
  22.     if not link then
  23.         term.setBackgroundColor(colors.black)
  24.         term.setTextColor(colors.red)
  25.         term.clear()
  26.         term.setCursorPos(1,1)
  27.         print("Zacpier's appstore installer is having trouble connecting\nto the remote server at:\n"..url.."\nPlease try again later.")
  28.         error()
  29.     end
  30.     filecontents = link.readAll()
  31.     link.close()
  32.     return filecontents
  33. end
  34.  
  35. function dlToFile(name)
  36. f = io.open("AppStore/"..name, 'w')
  37. f:write(downloadFromSource(name))
  38. f:close()
  39. print("Downloaded "..name..".")
  40. end
  41. dlToFile("Store")
  42. dlToFile("softwareSources")
  43. fs.makeDir("AppStore/img")
  44. dlToFile("img/appBox.nfp")
  45. dlToFile("img/back.nfp")
  46. dlToFile("img/description.nfp")
  47. dlToFile("img/install.nfp")
  48. dlToFile("img/mainFrame.nfp")
  49. print("Complete!\nTo launch the appstore, just type \"AppStore\\Store\".")
Advertisement
Add Comment
Please, Sign In to add comment