FFGFlash

install

Sep 14th, 2021 (edited)
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.77 KB | None | 0 0
  1. local drive = peripheral.find("drive")
  2. if drive then drive.ejectDisk() end
  3. local t,c,b,a = "///nekOS///", "77800000877", "f", colors.black
  4. if term.isColor() then c,b,a = "edb00000bde", "7", colors.gray end
  5. local w,h = term.getSize()
  6. local function get(code, path)
  7.   path = path or code
  8.   local res = http.get("http://pastebin.com/raw.php?i="..textutils.urlEncode(code))
  9.   if not res then return false, "Failed to get paste." end
  10.   local data = res.readAll()
  11.   res.close()
  12.   fs.delete(path)
  13.   local file = fs.open(path, "w")
  14.   file.write(data)
  15.   file.close()
  16.   return true
  17. end
  18. local function load(path)
  19.   if not fs.exists(path) then return {} end
  20.   local f = fs.open(path, "r")
  21.   local t = textutils.unserialize(f.readAll())
  22.   f.close()
  23.   return t
  24. end
  25. local current,total = 0,0
  26. local function progress(message)
  27.   local perc = current / total
  28.   local ii = math.floor(perc * w)
  29.   term.setCursorPos(1,h-1)
  30.   term.clearLine()
  31.   term.write(message)
  32.   local perstr = ""..(math.floor(perc * 1000) / 10).."%"
  33.   term.setCursorPos(w-string.len(perstr)+1,h-1)
  34.   term.write(perstr)
  35.   term.setCursorPos(1,h)
  36.   term.clearLine()
  37.   for i=1,ii,1 do term.blit("#","8",b) end
  38. end
  39. term.setTextColor(colors.white)
  40. term.setBackgroundColor(term.isColor() and colors.gray or colors.black)
  41. term.clear()
  42. term.setCursorPos(1,1)
  43. term.setCursorPos(math.floor((w - string.len(t)) / 2), math.floor(h / 2))
  44. for i=1,#t,1 do
  45.   term.blit(string.sub(t,i,i),string.sub(c,i,i),b)
  46.   sleep(1/5)
  47. end
  48. get("ki96M55P", ".manifest")
  49. local manifest = load(".manifest")
  50. for k,v in pairs(manifest.Files) do total = total + 1 end
  51. local x,y = term.getCursorPos()
  52. for k,v in pairs(manifest.Files) do
  53.   progress("Downloading "..k.."...")
  54.   get(v.Code, k)
  55.   current = current + 1
  56.   sleep(1/total)
  57. end
  58. os.reboot()
Add Comment
Please, Sign In to add comment