Advertisement
Pirnogion

InstallLAPI_G

Jan 13th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.30 KB | None | 0 0
  1. local OutputFile     = nil
  2. local outfile = nil
  3.  
  4. local GluedFile      = "LAPIPack"
  5. local GluedFileData  = nil
  6.  
  7. local running = true
  8.  
  9. term.setBackgroundColor(colors.white)
  10. term.setTextColor(colors.blue)
  11.  
  12. tx, ty = term.getSize()
  13.  
  14. term.clear()
  15. term.setCursorPos(tx/2-11, ty/2)
  16.  
  17. write("Install LayerAPI? y/n")
  18.  
  19. local _, key = os.pullEvent("char")
  20. if (key == "n") then shell.run("reboot") end
  21.  
  22. term.clear()
  23. term.setCursorPos(1, 1)
  24.  
  25. print("Download LAPI packet...")
  26. if (not shell.run("pastebin get eiKE970W LAPIPack")) then
  27.     term.clear()
  28.     term.setCursorPos(tx/2-8, ty/2)
  29.  
  30.     write("Error. Reboot...")
  31.     sleep(2)
  32. end
  33.  
  34. infile = fs.open(GluedFile, "r")
  35.  
  36. function unglue()
  37.     GluedFileData = infile.readLine()
  38.     if GluedFileData == "<eof>" then outfile.close() running = false return end
  39.    
  40.     local _, _i = string.find(GluedFileData, "<GluePath>")
  41.     if _i then
  42.         print("Unpack " .. string.sub(GluedFileData, _i) .. " file...")
  43.         if outfile then outfile.close() print("Done.")end
  44.         outfile = fs.open(string.sub(GluedFileData, _i), "a")
  45.         --unglue() --KILL MEGA RECURSIVE
  46.     else
  47.         if outfile then
  48.             outfile.writeLine(GluedFileData)
  49.             unglue()
  50.         else outfile.close() return end
  51.     end
  52. end
  53.  
  54. while running do
  55.     unglue()
  56. end
  57.  
  58. infile.close()
  59.  
  60. print("/nLAPI installed. Press any key.")
  61. shell.run("reboot")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement