Advertisement
HangMan23

TheAdvancedOS V2.3

Jan 27th, 2019
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.14 KB | None | 0 0
  1. local internet = require("internet")
  2. local gpu = require("component").gpu
  3. local unicode = require("unicode")
  4. local io = require("io")
  5. local fs = require("filesystem")
  6. local computer = require("computer")
  7.  
  8. local PClose = false
  9. local version = "AdvancedOS V2.3"
  10.  
  11. local function get(URL)
  12.  
  13.   local req = internet.request(URL)
  14.   local text = ""
  15.  
  16.   for line in req do
  17.  
  18.     text = text .. line
  19.  
  20.   end
  21.  
  22.   return text
  23.  
  24. end
  25.  
  26. local function download(paste, path)
  27.  
  28.   local file, reason = io.open(path, "w")
  29.  
  30.   if not file then
  31.  
  32.     error("Failed to open file wor writing: " .. reason)
  33.  
  34.   end
  35.  
  36.   file:write(get("https://pastebin.com/raw/" .. paste))
  37.   file:close()
  38.  
  39. end
  40.  
  41. local local_require = function(name)
  42.  
  43.   local result, reason = loadfile("/lib/"..name..".lua")
  44.  
  45.   if result then
  46.  
  47.     return result()
  48.  
  49.   else
  50.  
  51.     return nil, reason
  52.  
  53.   end
  54.  
  55. end
  56.  
  57. ss = {
  58. unicode.char(9474),
  59. unicode.char(8730),
  60. unicode.char(9587),
  61. unicode.char(8681),
  62. unicode.char(74214)
  63. }
  64.  
  65. ------------------------------------------------
  66.  
  67. print("Downloading files links...")
  68. download("FUFz0Wmg", "/lib/timelessPaths.lua")
  69. local links = local_require("timelessPaths")
  70.  
  71. print("Downloading programs links...")
  72. download(links.programs, "/lib/files.lua")
  73. local files = local_require("files")
  74.  
  75. print("Downloading ExtraUtilits library...")
  76. download(links.ExtraUtilits, "/lib/ExtraUtilits.lua")
  77. fs.makeDirectory("/lib/ExtraUtilitsModules")
  78. download(links.Modules, "/Modules.lua")
  79.  
  80. local modules = loadfile("/Modules.lua")()
  81.  
  82. for i = 1, #modules do
  83.  
  84.   print("Downloading ExtraUtilits modules #" .. tostring(i))
  85.   download(modules[i][1], modules[i][2])
  86.  
  87. end
  88.  
  89. local EU = local_require("ExtraUtilits")
  90.  
  91. print("")
  92. print("Successful!")
  93.  
  94. ------------------------------------------------
  95.  
  96. buttons = {}
  97.  
  98. y = 21
  99.  
  100. for i = 1, #files do
  101.  
  102.   local function func()
  103.  
  104.     if files[i].mode then
  105.  
  106.       buttons[i][6] = 0xff0000
  107.       buttons[i][7] = ss[3]
  108.       files[i].mode = false
  109.       EU.draw(buttons)
  110.  
  111.     elseif not files[i].mode then
  112.  
  113.       buttons[i][6] = 0x00ff00
  114.       buttons[i][7] = ss[2]
  115.       files[i].mode = true
  116.       EU.draw(buttons)
  117.  
  118.     end
  119.  
  120.   end
  121.  
  122.   buttons[i] = {61, y, 1, 1, 0x323232, 0x00ff00, ss[2], func, mode = true}
  123.  
  124.   if not files[i].mode then
  125.  
  126.     buttons[i][6] = 0xff0000
  127.     buttons[i][7] = ss[3]
  128.  
  129.   end
  130.  
  131.   y = y + 1
  132.  
  133. end
  134.  
  135. local function wind()
  136.  
  137.   gpu.setBackground(0x323232)
  138.  
  139.   gpu.fill(60, 20, 40, 20,  " ")
  140.   gpu.setForeground(0xff9326)
  141.   gpu.set(160 / 2 - unicode.wlen(version) / 2, 20, version)
  142.  
  143.   y = 21
  144.  
  145.   for i = 1, #files do
  146.  
  147.     gpu.set(62, y, ss[1])
  148.     y  = y + 1
  149.  
  150.   end
  151.  
  152.   y = 21
  153.  
  154.   gpu.setForeground(0xffffff)
  155.  
  156.   for i = 1, #files do
  157.  
  158.     if files[i].text then
  159.  
  160.       gpu.set(63, y, files[i].text)
  161.  
  162.     else
  163.  
  164.       gpu.set(63, y, files[i][1])
  165.  
  166.     end
  167.  
  168.     y = y + 1
  169.  
  170.   end
  171.  
  172. end
  173.  
  174. close = function()
  175.  
  176.   PClose = true
  177.   buttons.close = true
  178.  
  179. end
  180.  
  181. done = function()
  182.  
  183.   buttons.close  = true
  184.  
  185. end
  186.  
  187. buttons[#buttons + 1] = {99, 20, 1, 1, 0x323232, 0xff0000, ss[3], close}
  188. buttons[#buttons + 1] = {99, 39, 1, 1, 0x323232, 0x00ff00, ss[4], done}
  189.  
  190. ------------------------------------------------
  191.  
  192. local function install()
  193.  
  194.   gpu.setBackground(0x323232)
  195.  
  196.   if not PClose then
  197.  
  198.     for i = 1, #files do
  199.  
  200.       if files[i].mode then
  201.  
  202.         gpu.setForeground(0xffffff)
  203.         gpu.set(60, 39, "Installing " .. files[i][1] .. "...")
  204.  
  205.         x = {}
  206.  
  207.         if files[i].text then
  208.  
  209.           x[i] = 63 + unicode.wlen(files[i].text)
  210.  
  211.         else
  212.  
  213.           x[i] = 63 + unicode.wlen(files[i][1])
  214.  
  215.         end
  216.  
  217.         gpu.setForeground(0x00ff00)
  218.         --if i ~= 1 then gpu.set(x[i - 1], i + 19, " ") end
  219.         gpu.set(x[i], i + 20, ss[5])
  220.  
  221.         download(files[i][2], files[i][1])
  222.         if files[i].code ~= nil then
  223.           load(files[i].code)()
  224.         end
  225.         os.sleep(1)
  226.  
  227.       end
  228.  
  229.     end
  230.  
  231.     gpu.fill(60, 39, 40, 1, " ")
  232.  
  233.   end
  234.  
  235. end  
  236.  
  237. ------------------------------------------------
  238.  
  239. local function clear()
  240.  
  241.   fs.remove("/lib/timelessPaths.lua")
  242.   fs.remove("/lib/prog.lua")
  243.   fs.remove("/Modules.lua")
  244.  
  245.   if PClose then
  246.  
  247.     fs.remove("/lib/ExtraUtilits.lua")
  248.  
  249.   else
  250.  
  251.     for i = 1, #files do
  252.  
  253.       if files[i].timeless then
  254.  
  255.         fs.remove(files[i][1])
  256.  
  257.       end
  258.  
  259.     end
  260.  
  261.     computer.shutdown(true)
  262.  
  263.   end
  264.  
  265. end
  266.  
  267. ------------------------------------------------
  268.  
  269. local function main()
  270.   wind()
  271.   EU.draw(buttons)
  272.   EU.buttonPress(buttons)
  273.   install()
  274.   os.sleep(1)
  275. end
  276.  
  277. ------------------------------------------------
  278.  
  279. local function intro()
  280.  
  281. local gpu = require("component").gpu
  282. local EU = require("ExtraUtilits")
  283.  
  284. local function body()
  285.  
  286.   color = 0x000000
  287.  
  288.   repeat
  289.  
  290.     gpu.setBackground(color)
  291.     gpu.setForeground(0xffffff - color)
  292.     gpu.fill(68, 22, 24, 5, " ")
  293.     gpu.set(69, 24, "Calhoz Inc Tehnologies")
  294.     gpu.set(68, 26, "2019")
  295.     color = color + 0x111111
  296.     os.sleep(0.1)
  297.  
  298.   until color == 0xffffff
  299.  
  300.   os.sleep(1)
  301.  
  302. end
  303.  
  304. EU.screenBackup(body)
  305.  
  306. end
  307.  
  308. ------------------------------------------------
  309.  
  310. intro()
  311. EU.screenBackup(main)
  312. clear()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement