Advertisement
_56cool_

оskillcraftos

Dec 5th, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.92 KB | None | 0 0
  1. ----------------------СТАРТОВЫЕ ПРЕЛЕССССТИ-------------------------
  2.  
  3. local XSize, YSize = term.getSize()
  4. local Selector = 1
  5. local zaderzhka = 0.1
  6. local progressBarWidth = 20
  7. local ColorGray = colors.gray
  8. local ColorLightGray = colors.lightGray
  9. local ColorDownloadBack = colors.gray
  10. local ColorDownloadFront = colors.lightGray
  11.  
  12. -----------СМЕНА ЦВЕТОВОЙ ПАЛИТРЫ, ЕСЛИ МОНИТОР ЧЕРНО-БЕЛЫЙ---------
  13.  
  14. if not term.isColor() then
  15.         ColorGray = colors.black
  16.         ColorLightGray = colors.black
  17.         ColorDownloadBack = colors.white
  18.         ColorDownloadFront = colors.black
  19. end
  20.  
  21. -----------МАССИВ СО ДАННЫМИ О КАЖДОЙ ПРОГРАММЕ НА ПАСТЕБИНЕ--------
  22.  
  23. local Data = {
  24.         --АПИ
  25.         {["paste"]="vjs77QA6",["path"]="System/API/cluster",["type"]="API",["category"]="APIs"},
  26.         {["paste"]="LAKBDeQt",["path"]="System/API/zip",["type"]="API",["category"]="APIs"},
  27.         {["paste"]="TRUJgUme",["path"]="System/API/context",["type"]="API",["category"]="APIs"},
  28.         {["paste"]="Z2kWNQaJ",["path"]="System/API/config",["type"]="API",["category"]="APIs"},
  29.         {["paste"]="6gTj9LxN",["path"]="System/API/image",["type"]="API",["category"]="APIs"},
  30.         {["paste"]="JPYBYVTd",["path"]="System/API/filemanager",["type"]="API",["category"]="APIs"},
  31.         {["paste"]="D1QiSj9L",["path"]="System/API/windows",["type"]="API",["category"]="APIs"},
  32.         {["paste"]="2M3z7Ycf",["path"]="System/API/xml",["type"]="API",["category"]="APIs"},
  33.         {["paste"]="kWNeNPn5",["path"]="System/API/encryptor.cfg",["type"]="API",["category"]="APIs"},
  34.         {["paste"]="CpTj9QHL",["path"]="System/API/encryptor",["type"]="API",["category"]="APIs"},
  35.         {["paste"]="ApGP6e6x",["path"]="System/API/syntax",["type"]="API",["category"]="APIs"},
  36.         --СИСТЕМА
  37.         {["paste"]="1KJcUxPU",["path"]="OS",["type"]="other",["category"]="OS"},
  38.         {["paste"]="HQ5zT3vG",["path"]="System/OS/Icons/default.png",["type"]="other",["category"]="OS"},
  39.         {["paste"]="Be0DWVWX",["path"]="System/OS/Icons/folder.png",["type"]="other",["category"]="OS"},
  40.         {["paste"]="90rS8nxX",["path"]="System/OS/Icons/image.png",["type"]="other",["category"]="OS"},
  41.         {["paste"]="EupZQv59",["path"]="System/OS/Icons/config.png",["type"]="other",["category"]="OS"},
  42.         {["paste"]="PhCccHT4",["path"]="System/OS/Icons/os.png",["type"]="other",["category"]="OS"},
  43.         {["paste"]="eWMNUsb6",["path"]="System/OS/Icons/zip.png",["type"]="other",["category"]="OS"},
  44.         {["paste"]="0rMSM2x2",["path"]="System/OS/Icons/disk.png",["type"]="other",["category"]="OS"},
  45.         --ДОПОЛНЕНИЯ К ПРИЛОЖЕНИЯМ
  46.         {["paste"]="J4tPebM0",["path"]="System/MineCode/logo.png",["type"]="other",["category"]="MineCode IDE"},
  47.         {["paste"]="kAjvzgRN",["path"]="System/MineCode/syntax_colors.cfg",["type"]="other",["category"]="MineCode IDE"},
  48.         {["paste"]="yT9eRQu9",["path"]="System/Photoshop/pslogo.png",["type"]="other",["category"]="Photoshop"},
  49.         --ОБЫЧНЫЕ ПРИЛОЖЕНИЯ
  50.         {["paste"]="qDczAPkV",["path"]="Applications/Cobblestone",["type"]="other",["category"]="applications"},
  51.         {["paste"]="dkvshvvL",["path"]="Applications/RednetSpy",["type"]="other",["category"]="applications"},
  52.         --{["paste"]="hUVMQFGU",["path"]="Applications/RednetSend",["type"]="other",["category"]="applications"},
  53.         --{["paste"]="QqpHrszL",["path"]="Applications/View",["type"]="other",["category"]="applications"},
  54.         {["paste"]="x824frsu",["path"]="Applications/Transfer",["type"]="other",["category"]="applications"},
  55.         {["paste"]="pMSt4K2K",["path"]="Applications/Reactor",["type"]="other",["category"]="applications"},
  56.         {["paste"]="W7ucXtTm",["path"]="Applications/Mine",["type"]="other",["category"]="applications"},
  57.         {["paste"]="Sexqhkdq",["path"]="Applications/Grief",["type"]="other",["category"]="applications"},
  58.         {["paste"]="Bsv3iBiN",["path"]="Applications/CBPaint",["type"]="other",["category"]="applications"},
  59.         {["paste"]="HJg7u7ui",["path"]="Applications/Calibrate",["type"]="other",["category"]="applications"},
  60.         {["paste"]="Xn8THcUC",["path"]="Applications/About",["type"]="other",["category"]="applications"},
  61.         --{["paste"]="uQCTsyd6",["path"]="Applications/MenuDemo1",["type"]="other",["category"]="applications"},
  62.         --{["paste"]="8PL6sQf7",["path"]="Applications/MenuDemo2",["type"]="other",["category"]="applications"},
  63.         --{["paste"]="g0VdnK3X",["path"]="Applications/FileDemo",["type"]="other",["category"]="applications"},
  64.         --НОВЫЕ СУПЕР-ХИТРОЖОПЫЕ ПРИЛОЖЕНИЯ
  65.  
  66.  
  67.         {["paste"]="iDuJCAPS",["icon"]="LVeGQ7pU",["path"]="AirDrop",["type"]="Application",["category"]="applications"},
  68.         {["paste"]="sXj77Y2B",["icon"]="764jWGZX",["path"]="NewsTicker",["type"]="Application",["category"]="applications"},
  69.         {["paste"]="sfY8Hwwb",["icon"]="rc2sddVB",["path"]="Pastebin",["type"]="Application",["category"]="applications"},
  70.         {["paste"]="gt9f7EfZ",["icon"]="sj5uhGUz",["path"]="BSOD",["type"]="Application",["category"]="applications"},
  71.         {["paste"]="D8hSLB2L",["icon"]="DZjpMD68",["path"]="CodeDoor",["type"]="Application",["category"]="applications"},
  72.         {["paste"]="4nFps3sF",["icon"]="PA9HFXnX",["path"]="MineCode",["type"]="Application",["category"]="applications"},
  73.         {["paste"]="CBvTqxRj",["icon"]="hm1jMLhc",["path"]="Photoshop",["type"]="Application",["category"]="applications"},
  74.         {["paste"]="hHum7Qqb",["icon"]="mMhJSh7x",["path"]="Graph",["type"]="Application",["category"]="applications"},
  75. }
  76.  
  77. --ЗАГРУЗИТЬ КОНКРЕТНОЕ ПРИЛОЖЕНИЕ
  78. local function downloadApp(pasteApp,pasteIcon,path)
  79.         fs.delete(path..".app")
  80.         pastebin(pasteApp,path..".app/main")
  81.         pastebin(pasteIcon,path..".app/Resources/icon.png")
  82. end
  83.  
  84. --ПРОСТАЯ ЗАЛИВКА ЭКРАНА ЦВЕТОМ
  85. local function clearScreen(color)
  86.         term.setBackgroundColor(color)
  87.         term.clear()
  88. end
  89.  
  90. --ПЛАВНОЕ ВКЛЮЧЕНИЕ ЭКРАНА
  91. local function fadeIn(time)
  92.         clearScreen(ColorGray)
  93.         sleep(time)
  94.         clearScreen(ColorLightGray)
  95.         sleep(time)
  96.         clearScreen(colors.white)
  97.         sleep(time)
  98. end
  99.  
  100. --ПЛАВНОЕ ЗАТУХАНИЕ ЭКРАНА
  101. local function fadeOut(time)
  102.         clearScreen(ColorLightGray)
  103.         sleep(time)
  104.         clearScreen(ColorGray)
  105.         sleep(time)
  106.         clearScreen(colors.black)
  107.         sleep(time)
  108.         term.setCursorPos(1,1)
  109.         term.setTextColor(colors.white)
  110. end
  111.  
  112. --УНИВЕРСАЛЬНАЯ ФУНКЦИЯ ДЛЯ ОТОБРАЖЕНИЯ ТЕКСТА ПО ЦЕНТРУ ЭКРАНА
  113. local function centerText(how,coord,text,textColor,backColor)
  114.         term.setTextColor(textColor)
  115.         term.setBackgroundColor(backColor)
  116.         if how == "xy" then
  117.                 term.setCursorPos(math.floor(XSize/2-#text/2),math.floor(YSize/2))
  118.         elseif how == "x" then
  119.                 term.setCursorPos(math.floor(XSize/2-#text/2),coord)
  120.         elseif how == "y" then
  121.                 term.setCursorPos(coord,math.floor(YSize/2))
  122.         end
  123.         term.write(text)
  124. end
  125.  
  126. --НАРИСОВАТЬ ГОРЗОНТАЛЬНУЮ ЛИНИЮ УКАЗАННОЙ ДЛИНЫ И ЦВЕТА
  127. local function horisontalBar(x,y,width,color)
  128.         for i=x,(x+width-1) do
  129.                 paintutils.drawPixel(i,y,color)
  130.         end
  131. end
  132.  
  133. --ОТОБРАЖЕНИЕ ШКАЛЫ ЗАГРУЗКИ С ПРОГРЕССОМ В ПРОЦЕНТАХ
  134. local function progressBar(size,action,percent)
  135.         local doneSize = math.ceil(percent/100*size)
  136.         local startingY = math.floor(YSize/2-1)
  137.         local startingX = math.floor(XSize/2-size/2)
  138.         horisontalBar(1,startingY,XSize,colors.white)
  139.         centerText("x",startingY,"Installing "..action,ColorGray,colors.white)
  140.         horisontalBar(startingX,startingY+2,size,ColorDownloadBack)
  141.         horisontalBar(startingX,startingY+2,doneSize,ColorDownloadFront)
  142.         sleep(zaderzhka)
  143. end
  144.  
  145. --ЗАГРУЗИТЬ ВСЕ ФАЙЛЫ С ПАСТЕБИНА
  146. local function downloadAll()
  147.         clearScreen(colors.white)
  148.         progressBar(progressBarWidth,"started",0)
  149.  
  150.         fs.makeDir("Applications")
  151.         fs.makeDir("System")
  152.         --fs.makeDir("Documents")
  153.         --fs.makeDir("Images")
  154.         --fs.makeDir("Documents/MineCode")
  155.  
  156.         local oneFileIsHowMuchPercent = 1/#Data*100
  157.  
  158.         for i=1,#Data do
  159.                 if Data[i]["type"] == "Application" then
  160.                         downloadApp(Data[i]["paste"],Data[i]["icon"],Data[i]["path"])
  161.                 else
  162.                         pastebin(Data[i]["paste"],Data[i]["path"])
  163.                 end
  164.                 progressBar(progressBarWidth,Data[i]["category"],i*oneFileIsHowMuchPercent)
  165.         end
  166.  
  167.         clearScreen(colors.white)
  168.         centerText("x",math.floor(YSize/2),"Done.",ColorLightGray,colors.white)
  169.         os.pullEvent("key")
  170. end
  171.  
  172. --ЗАГРУЗИТЬ ВСЕ АПИ
  173. local function downloadAPIs()
  174.         for i=1,#Data do
  175.                 if Data[i]["type"] == "API" then
  176.                         pastebin(Data[i]["paste"],Data[i]["path"])
  177.                 end
  178.         end
  179. end
  180.  
  181. --УДАЛИТЬ ВСЕ МОИ ФАЙЛЫ
  182. local function deleteOld()
  183.         fs.delete("Applications")
  184.         fs.delete("Documents")
  185.         fs.delete("Images")
  186.         fs.delete("System")
  187.         fs.delete("OS")
  188.         fs.delete("MineCode")
  189.         fs.delete("startup")
  190.         fs.delete("Startup")
  191. end
  192.  
  193. --УДАЛИТЬ ВООБЩЕ ВСЕ ФАЙЛЫ
  194. local function deleteAll()
  195.         local fileList = fs.list("")
  196.         for i=1,#fileList do
  197.                 if not fs.isReadOnly(fileList[i]) then
  198.                         fs.delete(fileList[i])
  199.                 end
  200.         end
  201. end
  202.  
  203. --НАРИСОВАТЬ СЕЛЕКТОР ДЛЯ ВЫБОРА ПРИ СТАРТЕ ПРОГРАММЫ
  204. local function drawSelection(y,text,id)
  205.         if id == Selector then
  206.                 horisontalBar(math.floor(XSize/2-8),y,16,ColorLightGray)
  207.                 centerText("x",y,text,colors.white,ColorLightGray)
  208.         else
  209.                 horisontalBar(math.floor(XSize/2-8),y,16,colors.white)
  210.                 centerText("x",y,text,ColorLightGray,colors.white)
  211.         end
  212. end
  213.  
  214. --ОТОБРАЖЕНИЕ СТАРТОВОГО ИНТЕРФЕЙСА
  215. local function gui()
  216.         local startingY = math.floor(YSize/2-2)
  217.         centerText("x",startingY,"Welcome to ECS installer",ColorGray,colors.white)
  218.  
  219.         drawSelection(startingY+2,"Install OS",1)
  220.         drawSelection(startingY+3,"Clear computer",2)
  221.         drawSelection(startingY+4,"Download API",3)
  222.         drawSelection(startingY+5,"Exit",4)
  223. end
  224.  
  225. -----------------------СТАРТ ПРОГРАММЫ-----------------------
  226.  
  227. fadeIn(0)
  228. gui()
  229.  
  230. while true do
  231.         --ОТСЛЕЖИВАНИЕ КЛАВИШ СТРЕЛОК И ENTER
  232.         local event, scancode = os.pullEvent("key")
  233.         --ПЕРЕМЕСТИТЬСЯ ВЫШЕ
  234.         if scancode == 200 then
  235.                 Selector = Selector-1
  236.                 if Selector<1 then Selector=1 end
  237.                 gui()
  238.         --ПЕРЕМЕСТИТЬСЯ НИЖЕ
  239.         elseif scancode == 208 then
  240.                 Selector = Selector+1
  241.                 if Selector>4 then Selector=4 end
  242.                 gui()
  243.         --СКАЧАТЬ ВСЕ С ПАСТЕБИНА
  244.         elseif scancode == 28 and Selector == 1 then
  245.                 --deleteOld()
  246.                 downloadAll()
  247.                 break
  248.         --ОЧИСТИТЬ КОМП ОТ МОЕГО ГОВНА
  249.         elseif scancode == 28 and Selector == 2 then
  250.                 deleteAll()
  251.                 clearScreen(colors.white)
  252.                 centerText("x",math.floor(YSize/2),"Filesystem was cleared.",ColorLightGray,colors.white)
  253.                 local event, scancode = os.pullEvent("key")
  254.                 fadeOut(0)
  255.                 os.reboot()
  256.                 break
  257.         --СКАЧАТЬ ТОЛЬКО АПИ С ПАСТЕБИНА
  258.         elseif scancode == 28 and Selector == 3 then
  259.                 fs.delete("System/API")
  260.                 clearScreen(colors.white)
  261.                 centerText("x",math.floor(YSize/2),"Downloading APIs",ColorLightGray,colors.white)
  262.  
  263.                 --[[for i=1,11 do
  264.                         pastebin(Data[i]["paste"],Data[i]["path"])
  265.                 end]]
  266.                 downloadAPIs()
  267.  
  268.                 clearScreen(colors.white)
  269.                 centerText("x",math.floor(YSize/2),"APIs installed in /System/API",ColorLightGray,colors.white)
  270.                 local event, scancode = os.pullEvent("key")
  271.                 break
  272.         --ВЫЙТИ ИЗ ПРОГРАММЫ
  273.         elseif scancode == 28 and Selector == 4 then
  274.                 break
  275.         end
  276. end
  277.  
  278. fadeOut(0)
  279. term.setCursorPos(1,1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement