Advertisement
thegreatstudio

install2

Mar 18th, 2013
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.19 KB | None | 0 0
  1. shell.run("pastebin", "get", "JaQMssHV", "/load")
  2. if not load then
  3. os.loadAPI("/load") -- TheOriginalBIT's API
  4. end
  5.  
  6. --[[
  7. your logo didn't fit on the screen, now it does
  8. ]]--
  9. local logo = {
  10.   "5555  5 5 5555  5555 5555  5555 55555",
  11.   "5     5   5   5 5    5     5  5 5    ",
  12.   "5 555 5 5 55555 5555 555   5  5 55555",
  13.   "5   5 5 5 5       55 5     5555     5",
  14.   "55555 5 5 55555 5555 5555  5555 55555",
  15. }
  16.  
  17. --[[
  18. We use this because the pastebin program spams stuff to the screen and to reduce screen tearing my api only updates the lines it needs to on the screen
  19. so we make our own to stop the printing to the screen
  20. ]]--
  21. local function download(code, path)
  22.   local response = http.get( "http://pastebin.com/raw.php?i="..textutils.urlEncode( code ) )
  23.    
  24.   if response then
  25.     local contents = response.readAll()
  26.     response.close()
  27.    
  28.     local file = fs.open( path, "w" )
  29.     file.write( contents )
  30.     file.close()
  31.   end
  32. end
  33.  
  34. --[[
  35. This is all the instructions you want the installer to do.
  36. func is the function that it has to call
  37. param is what to give to the function
  38. visual can only be used if you are wanting to show them text, it doesn't move the progress bar, it just updates the progress text
  39. ]]--
  40. local instructions = {
  41.   {func = fs.makeDir, param = {"gliese"}},
  42.   {func = fs.makeDir, param = {"gliese/sysfiles"}},
  43.   {visual = "Installing Gliese OS Development Stage..."},
  44.   {func = download, param = {"bJR1Zsut", "gliese/clrs"}},
  45.   {func = fs.delete, param = { "/startup" }},
  46.   {func = download, param = {"Zwj4pttD", "/startup"}},
  47.   {func = download, param = {"UEfxpFg3", "gliese/set"}},
  48.   {func = download, param = {"VqhvSXJd", "gliese/start"}},
  49.   {func = download, param = {"sqY4sUBU", "gliese/list"}},
  50.   {func = download, param = {"kTWKJzVg", "gliese/gfb"}},
  51.   {func = download, param = {"HyDGJaXG", "gliese/delete"}},
  52.   {func = download, param = {"i8KHsHgR", "gliese/mdp"}},
  53.   {func = download, param = {"gMYRfL9i", "gliese/help"}},
  54.   {func = download, param = {"1e0XC30i", "gliese/text"}},
  55.   {func = download, param = {"q9CeVngm", "gliese/pastebin"}},
  56.   {func = download, param = {"t3D4tbpY", "gliese/quit"}},
  57.   {func = download, param = {"73r1J115", "gliese/restart"}},
  58.   {func = download, param = {"D8Dz7X83", "gliese/shell"}},
  59.   {func = download, param = {"ZcDyAW6U", "gliese/tacoinstall"}},
  60.   {func = download, param = {"zJ7qtPVx", "gliese/gui"}},
  61.   {func = download, param = {"HfbAuqBG", "gliese/sysfiles/fLib"}},
  62.   {func = download, param = {"DZP7i7XA", "gliese/taco"}},
  63.   {func = download, param = {"b8zZfN7m", "gliese/sysfiles/background"}},
  64.   {func = download, param = {"dhU58yVF", "gliese/icon.nfp"}},
  65.   {visual = "Done!"},
  66. }
  67.  
  68. --[[
  69. the total number of instructions - 2
  70. why do we use #instructions because its the number of instructions we wish to perform that are in the above table
  71. why -2 because we have 2 visuals in there, they don't tigger an update, so the api will be waiting for 2 updates it will never get
  72. ]]--
  73. local totalTriggers = #instructions - 2
  74. local bar = load.init( load.LOGO_IS_LOAD, logo, totalTriggers, nil, 14, colors.red, "Starting up...", "Gliese OS Installer", "By Thegreatstudio" )
  75.  
  76. --[[
  77. Main function. this downloads and installs all the files
  78. ]]--
  79. local function install()
  80.  
  81.   -- just a simple message to them
  82.   bar:setMessage( "Making a file system directory...")
  83.   -- make sure they see it
  84.   sleep(0.1)
  85.  
  86.   -- now lets go through and do the instructions
  87.   for i = 1, #instructions do
  88.     -- out current instruction
  89.     local inst = instructions[i]
  90.  
  91.     if inst.func then
  92.       -- call the function with the parameters
  93.       inst.func( unpack(inst.param) )
  94.       -- trigger an update
  95.       bar:triggerUpdate( "Loading ("..bar:getFormattedProgress()..")..." )
  96.     else -- it didn't have a function so lets assume it is a visual update
  97.       -- change the message
  98.       bar:setMessage(inst.visual)
  99.       -- make sure they see it
  100.       sleep(0.1)
  101.     end
  102.   end
  103.  
  104.   -- tell them its rebooting
  105.   bar:setMessage( "System is now rebooting..." )
  106. end
  107.  
  108. --[[ run the api ]]--
  109. local function render()
  110.   bar:run()
  111. end
  112.  
  113. parallel.waitForAll( render, install )
  114.  
  115. -- sleep so they can see the message and then reboot
  116. sleep(1)
  117. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement