superkh

boot

Dec 25th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.77 KB | None | 0 0
  1. --Vars-------------------------------------------------------------------
  2. os.pullEvent = os.pullEventRaw
  3. local w,h = term.getSize()
  4. local checkUpdate = true --change to true befor uploading
  5. local bufBoot = buf.createBuffer()
  6. local bufbar = nil
  7. -------------------------------------------------------------------------
  8. local function check()
  9.     for i=0,100,5 do
  10.         buf.increnetLoadbar(bufbar,i,true)
  11.         sleep(.01)
  12.     end
  13. end
  14. local function preLoad()
  15.   buf.bc(colors.blue)
  16.   buf.clsB(bufBoot)
  17.   buf.pos(math.floor((w/2)-3),math.floor(h/2-1))
  18.   buf.drawImageASCII(bufBoot,5,4,"os/images/AsciiArt",colors.blue,colors.grey)
  19.   bufbar = buf.createLoadbar(bufBoot,5,math.floor(h/2+2),math.floor(w-4),math.floor(h/2+3),colors.gray,colors.green,0)
  20.   local up = nil
  21.   if checkUpdate then
  22.     up = A.checkupdate()
  23.   else
  24.     up = false
  25.   end
  26.   if up then
  27.     local up2 = A.check2()
  28.     if up2 then
  29.         term.setBackgroundColor(colors.black)
  30.         term.setTextColor(colors.white)
  31.         term.clear()
  32.         local function cT(t,l)
  33.             term.setCursorPos((math.floor(w/2-t:len()/2 +.5)),l)
  34.             write(t)
  35.         end
  36.         cT("Updating OS",1)
  37.         print(string.rep("=",51))
  38.         if fs.exists("os/APIS/update") then
  39.             fs.delete("os/APIS/update")
  40.         end
  41.         A.pastebin("BqUbtktC","os/APIS/update")
  42.         shell.run("os/APIS/update")
  43.     end
  44.   end
  45.   buf.drawLoadbar(bufbar)
  46.   buf.drawBuffer(bufBoot)
  47.   check()
  48.   return true
  49. end
  50. -------------------------------------------------------------------------
  51. local function main()
  52.     preLoad()
  53.     return true
  54. end
  55. local ok, err = pcall(main)
  56. if not ok then
  57.     if err == "A:393: L2xbGSm5" or "A:396: L2xbGSm5" then
  58.         checkUpdate = false
  59.         local ok, err = pcall(main)
  60.         if not ok then
  61.             A.Error(err)
  62.         else
  63.             shell.run("os/login")
  64.         end
  65.     else
  66.         A.Error(err)
  67.     end
  68. else
  69.     shell.run("os/login")
  70. end
Add Comment
Please, Sign In to add comment