how to install openos open opencomputers local component = require("component") local computer = require("computer") local shell = require("shell") local unicode = require("unicode") local event = require("event") local fs = require("filesystem") local internet = require("internet") local seri = require("serialization") local gpu = component.gpu shell.setWorkingDirectory("") how to install openos open opencomputers How to use it? how to install openos open opencomputers -----------------Computer checking for compliance with the system requirements-------------------------- --Create an array of stuff local stuff = {} print(" ") print("Analyzing computer for matching system requirements...") --Check whether it is a tablet if component.isAvailable("tablet") then how to install openos open opencomputers How to get it for free? how to install openos open opencomputers table.insert(stuff, "Tablet PC detected - You can't install MineOS on tablet because of primitive GPU and Screen.") end --Check the GPU if gpu.maxResolution() < 150 then table.insert(stuff, "Bad GPU or Screen - MineOS requires Tier 3 GPU and Tier 3 Screen.") end --Checks the RAM if math.floor(computer.totalMemory() / 1024 ) < 1536 then how to install openos open opencomputers How to use it? how to install openos open opencomputers table.insert(stuff, "Not enough RAM - MineOS requires at least 1536 KB RAM.") end if fs.get("bin/edit.lua") == nil or fs.get("bin/edit.lua").isReadOnly() then table.insert(stuff, "You can't install MineOS on floppy disk. Run \"install\" in command line and install OpenOS from floppy to HDD first. After that you're be able to install MineOS from Pastebin.") end --If found any discrepancy ICU requirements , then write that it is not so if #stuff> 0 then print(" ") how to install openos open opencomputers How to get it? how to install openos open opencomputers for i = 1, #stuff do print(stuff[i]) end print(" ") return else print("Done, everything's good. Proceed to downloading.") print(" ") end how to install openos open opencomputers How to dowload it? how to install openos open opencomputers ------------------------------------------------------------------------------------------ local lang local applications local padColor = 0x262626 local installerScale = 1 local timing = 0.2 how to install openos open opencomputers How to use it? how to install openos open opencomputers -----------------------------STAGE TRAINING------------------------------------------- --Gets the files from GitHub local function getFromGitHub(url, path) local sContent = "" local result, response = pcall(internet.request, url) if not result then return nil how to install openos open opencomputers How to dowload it? how to install openos open opencomputers end if fs.exists(path) then fs.remove(path) end fs.makeDirectory(fs.path(path)) local file = io.open(path, "w") for chunk in response do file:write(chunk) sContent = sContent .. chunk end how to install openos open opencomputers How to dowload it? how to install openos open opencomputers file:close() return sContent end --Save Files local function getFromGitHubSafely(url, path) local success, sRepos = pcall(getFromGitHub, url, path) if not success then how to install openos open opencomputers How to get it for free? how to install openos open opencomputers io.stderr:write("Can't download \"" .. url .. "\"!\n") return -1 end return sRepos end --Gets files from pastebin local function getFromPastebin(paste, filename) local cyka = "" local f, reason = io.open(filename, "w") how to install openos open opencomputers How to use it? how to install openos open opencomputers if not f then io.stderr:write("Failed opening file for writing: " .. reason) return end --io.write("Downloading from pastebin.com... ") local url = "http://pastebin.com/raw.php?i=" .. paste local result, response = pcall(internet.request, url) if result then --io.write("success.\n") for chunk in response do how to install openos open opencomputers How to dowload it? how to install openos open opencomputers --if not options.k then --string.gsub(chunk, "\r\n", "\n") --end f:write(chunk) cyka = cyka .. chunk end f:close() --io.write("Saved data to " .. filename .. "\n") else f:close() how to install openos open opencomputers How to dowload it? how to install openos open opencomputers fs.remove(filename) io.stderr:write("HTTP request failed: " .. response .. "\n") end return cyka end local GitHubUserUrl = "https://raw.githubusercontent.com/" how to install openos open opencomputers How to get it for free? how to install openos open opencomputers --------------------------------- Download all the necessary items --------------------------------- local preLoadApi = { { paste = "IgorTimofeev/OpenComputers/master/lib/ECSAPI.lua", path = "lib/ECSAPI.lua" }, { paste = "IgorTimofeev/OpenComputers/master/lib/colorlib.lua", path = "lib/colorlib.lua" }, { paste = "IgorTimofeev/OpenComputers/master/lib/image.lua", path = "lib/image.lua" }, { paste = "IgorTimofeev/OpenComputers/master/lib/config.lua", path = "lib/config.lua" }, { paste = "IgorTimofeev/OpenComputers/master/MineOS/Icons/Languages.pic", path = "MineOS/System/OS/Icons/Languages.pic" }, { paste = "IgorTimofeev/OpenComputers/master/MineOS/Icons/OK.pic", path = "MineOS/System/OS/Icons/OK.pic" }, how to install openos open opencomputers How to dowload it? how to install openos open opencomputers { paste = "IgorTimofeev/OpenComputers/master/MineOS/Icons/Downloading.pic", path = "MineOS/System/OS/Icons/Downloading.pic" }, { paste = "IgorTimofeev/OpenComputers/master/MineOS/Icons/OS_Logo.pic", path = "MineOS/System/OS/Icons/OS_Logo.pic" }, } print("Downloading file list") applications = seri.unserialize(getFromGitHubSafely(GitHubUserUrl .. "IgorTimofeev/OpenComputers/master/Applications.txt", "MineOS/System/OS/Applications.txt")) print(" ") for i = 1, #preLoadApi do print("Downloading must-have files (" .. fs.name(preLoadApi[i].path) .. ")") how to install openos open opencomputers How to dowload it? how to install openos open opencomputers getFromGitHubSafely(GitHubUserUrl .. preLoadApi[i].paste, preLoadApi[i].path) end print(" ") package.loaded.ecs = nil package.loaded.ECSAPI = nil _G.ecs = require("ECSAPI") _G.image = require("image") _G.config = require("config") how to install openos open opencomputers How to use it? how to install openos open opencomputers local imageOS = image.load("MineOS/System/OS/Icons/OS_Logo.pic") local imageLanguages = image.load("MineOS/System/OS/Icons/Languages.pic") local imageDownloading = image.load("MineOS/System/OS/Icons/Downloading.pic") local imageOK = image.load("MineOS/System/OS/Icons/OK.pic") ecs.setScale(installerScale) local xSize, ySize = gpu.getResolution() local windowWidth = 80 how to install openos open opencomputers How to use it? how to install openos open opencomputers local windowHeight = 2 + 16 + 2 + 3 + 2 local xWindow, yWindow = math.floor(xSize / 2 - windowWidth / 2), math.ceil(ySize / 2 - windowHeight / 2) local xWindowEnd, yWindowEnd = xWindow + windowWidth - 1, yWindow + windowHeight - 1 ------------------------------------------------------------------------------------------- local function clear() ecs.blankWindow(xWindow, yWindow, windowWidth, windowHeight) end how to install openos open opencomputers How to dowload it? how to install openos open opencomputers --ОБЪЕКТЫ local obj = {} local function newObj(class, name, ...) obj[class] = obj[class] or {} obj[class][name] = {...} end local function drawButton(name, isPressed) local buttonColor = 0x888888 how to install openos open opencomputers How to dowload it? how to install openos open opencomputers if isPressed then buttonColor = ecs.colors.blue end local d = { ecs.drawAdaptiveButton("auto", yWindowEnd - 3, 2, 1, name, buttonColor, 0xffffff) } newObj("buttons", name, d[1], d[2], d[3], d[4]) end local function waitForClickOnButton(buttonName) while true do local e = { event.pull() } if e[1] == "touch" then if ecs.clickedAtArea(e[3], e[4], obj["buttons"][buttonName][1], obj["buttons"][buttonName][2], obj["buttons"][buttonName][3], obj["buttons"][buttonName][4]) then how to install openos open opencomputers How to use it? how to install openos open opencomputers drawButton(buttonName, true) os.sleep(timing) break end end end end ------------------------------LANGUAGE------------------------------------ how to install openos open opencomputers How to dowload it? how to install openos open opencomputers ecs.prepareToExit() local downloadWallpapers, showHelpTips = false, false do clear() image.draw(math.ceil(xSize / 2 - 30), yWindow + 2, imageLanguages) how to install openos open opencomputers How to get it? how to install openos open opencomputers --Draw dat button drawButton("Select language",false) waitForClickOnButton("Select language") local data = ecs.universalWindow("auto", "auto", 36, 0x262626, true, {"EmptyLine"}, {"CenterText", ecs.colors.orange, "Select language"}, {"EmptyLine"}, {"Select", 0xFFFFFF, ecs.colors.green, "Russian", "English"}, {"EmptyLine"}, {"CenterText", ecs.colors.orange, "Change some OS properties"}, {"EmptyLine"}, {"Switch", 0xF2B233, 0xffffff, 0xFFFFFF, "Download wallpapers", true}, {"EmptyLine"}, {"Switch", 0xF2B233, 0xffffff, 0xFFFFFF, "Show help tips in OS", true}, {"EmptyLine"}, {"Button", {ecs.colors.orange, 0x262626, "OK"}}) downloadWallpapers, showHelpTips = data[2], data[3] --Sets the desired language how to install openos open opencomputers How to use it? how to install openos open opencomputers _G.OSSettings = { showHelpOnApplicationStart = showHelpTips, language = data[1] } ecs.saveOSSettings() --Downloads language ecs.info("auto", "auto", " ", " Installing language packages...") local pathToLang = "MineOS/System/OS/Installer/Language.lang" getFromGitHubSafely(GitHubUserUrl .. "IgorTimofeev/OpenComputers/master/Installer/" .. _G.OSSettings.language .. ".lang", pathToLang) getFromGitHubSafely(GitHubUserUrl .. "IgorTimofeev/OpenComputers/master/MineOS/License/" .. _G.OSSettings.language .. ".txt", "MineOS/System/OS/License.txt") --Apply the language how to install openos open opencomputers How to get it for free? how to install openos open opencomputers lang = config.readAll(pathToLang) end ------------------------------Get the axis------------------------------------ do clear() how to install openos open opencomputers How to get it? how to install openos open opencomputers image.draw(math.ceil(xSize / 2 - 15), yWindow + 2, imageOS) --Draw the center gpu.setBackground(ecs.windowColors.background) gpu.setForeground(ecs.colors.gray) ecs.centerText("x", yWindowEnd - 5 , lang.beginOsInstall) --Button drawButton("->",false) how to install openos open opencomputers How to use it? how to install openos open opencomputers waitForClickOnButton("->") end ------------------------------User License------------------------------------------ do clear() --How to draw acc conditions how to install openos open opencomputers How to get it? how to install openos open opencomputers local from = 1 local xText, yText, TextWidth, TextHeight = xWindow + 4, yWindow + 2, windowWidth - 8, windowHeight - 7 --Read file sogll persons local lines = {} local file = io.open("MineOS/System/OS/License.txt", "r") for line in file:lines() do table.insert(lines, line) end file:close() how to install openos open opencomputers How to dowload it? how to install openos open opencomputers --Draw thing ecs.textField(xText, yText, TextWidth, TextHeight, lines, from, 0xffffff, 0x262626, 0x888888, ecs.colors.blue) --Draw information --ecs.centerText("x", yWindowEnd - 5 ,"Принимаете ли вы условия лицензионного соглашения?") --Button drawButton(lang.acceptLicense, false) how to install openos open opencomputers How to use it? how to install openos open opencomputers while true do local e = { event.pull() } if e[1] == "touch" then if ecs.clickedAtArea(e[3], e[4], obj["buttons"][lang.acceptLicense][1], obj["buttons"][lang.acceptLicense][2], obj["buttons"][lang.acceptLicense][3], obj["buttons"][lang.acceptLicense][4]) then drawButton(lang.acceptLicense, true) os.sleep(timing) break end elseif e[1] == "scroll" then if e[5] == -1 then how to install openos open opencomputers How to use it? how to install openos open opencomputers if from < #lines then from = from + 1; ecs.textField(xText, yText, TextWidth, TextHeight, lines, from, 0xffffff, 0x262626, 0x888888, ecs.colors.blue) end else if from > 1 then from = from - 1; ecs.textField(xText, yText, TextWidth, TextHeight, lines, from, 0xffffff, 0x262626, 0x888888, ecs.colors.blue) end end end end end -------------------------- Prepare file system ---------------------------------- how to install openos open opencomputers How to get it for free? how to install openos open opencomputers --Create ways to start , and other little things purely for aesthetics local desktopPath = "MineOS/Desktop/" local dockPath = "MineOS/System/OS/Dock/" local applicationsPath = "MineOS/Applications/" local picturesPath = "MineOS/Pictures/" fs.remove(desktopPath) fs.remove(dockPath) fs.makeDirectory(desktopPath .. "My files") how to install openos open opencomputers How to get it? how to install openos open opencomputers fs.makeDirectory(picturesPath) fs.makeDirectory(dockPath) --------------------------Stages of loading----------------------------------- do local barWidth = math.floor(windowWidth * 2 / 3) local xBar = math.floor(xSize/2-barWidth/2) local yBar = yWindowEnd - 3 how to install openos open opencomputers How to dowload it? how to install openos open opencomputers local function drawInfo(x, y, info) ecs.square(x, y, barWidth, 1, ecs.windowColors.background) ecs.colorText(x, y, ecs.colors.gray, info) end ecs.blankWindow(xWindow,yWindow,windowWidth,windowHeight) image.draw(math.floor(xSize/2 - 33), yWindow + 2, imageDownloading) how to install openos open opencomputers How to use it? how to install openos open opencomputers ecs.colorTextWithBack(xBar, yBar - 1, ecs.colors.gray, ecs.windowColors.background, lang.osInstallation) ecs.progressBar(xBar, yBar, barWidth, 1, 0xcccccc, ecs.colors.blue, 0) os.sleep(timing) for app = 1, #applications do --ВСЕ ДЛЯ ГРАФОНА drawInfo(xBar, yBar + 1, lang.downloading .. " " .. applications[app]["name"]) local percent = app / #applications * 100 ecs.progressBar(xBar, yBar, barWidth, 1, 0xcccccc, ecs.colors.blue, percent) how to install openos open opencomputers How to get it? how to install openos open opencomputers ecs.getOSApplication(applications[app], downloadWallpapers) end os.sleep(timing) end --Создаем базовые обои рабочего стола ecs.createShortCut(desktopPath .. "Pictures.lnk", picturesPath) if downloadWallpapers then ecs.createShortCut("MineOS/System/OS/Wallpaper.lnk", picturesPath .. "Girl.pic") end how to install openos open opencomputers How to get it for free? how to install openos open opencomputers --Startup local file = io.open("autorun.lua", "w") file:write("local success, reason = pcall(loadfile(\"OS.lua\")); if not success then print(\"Ошибка: \" .. tostring(reason)) end") file:close() --------------------------Reset Computer----------------------------------- ecs.blankWindow(xWindow,yWindow,windowWidth,windowHeight) image.draw(math.floor(xSize/2 - 16), math.floor(ySize/2 - 11), imageOK) how to install openos open opencomputers How to use it? how to install openos open opencomputers --Draw Centered Background gpu.setBackground(ecs.windowColors.background) gpu.setForeground(ecs.colors.gray) ecs.centerText("x",yWindowEnd - 5, lang.needToRestart) --Button drawButton(lang.restart, false) waitForClickOnButton(lang.restart) ecs.prepareToExit() how to install openos open opencomputers How to get it? how to install openos open opencomputers computer.shutdown(true) how to install openos open opencomputers