Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------
- -- WHAT IS THIS? --
- --------------------------------------
- -- This is a Lua script for the Minecraft
- -- mod Computercraft (or CC: Tweaked).
- -- It installs an OS suitable for all devices
- -- (basic and advanced normal and pocket computers,
- -- turtles and monitors) that I'm developing.
- --____________________________________
- -- WARNING
- -- The OS is not finished and I
- -- do not assure that it will work
- -- nor do i assure that any future
- -- version will work.
- -- If the current install is working
- -- make a backup before downloading an
- -- update.
- --------------------------------------
- -- HOW TO INSTALL --
- --------------------------------------
- -- First, be sure that
- -- YOU DO NOT HAVE A STARTUP FILE
- -- on this device.
- -- This program sets itself as the startup file,
- -- (but only if no other startup file is present,
- -- so no file is overwritten by mistake)
- -- If you do have one, run:
- -- delete startup.lua
- -- to delete it.
- -- Then simply run:
- --
- -- pastebin run qJSSf0qg
- --
- -- Now you are set, this will automatically
- -- run the installer.
- --____________________________________
- -- WARNING
- -- None of the other "CyberOs"
- -- files in my pastebin account are
- -- meant to be downloaded by other
- -- means that of this installer
- -- This program auto-manages the
- -- proper installation process and run
- -- conditions of CyberOs
- --!!!!!!!!!!!!!!!!!!!!!!!!!!!!!--
- -- FOR THE DEVELOPER ONLY (ME) --
- --!!!!!!!!!!!!!!!!!!!!!!!!!!!!!--
- -- TODO:
- -- Complete the themes icons/images
- -- Make the installer more user friendly
- -- Explain how to update a current installation
- -- Implement all other CyberOSs except Next
- -- Folder where files are installed
- INSTALL_FOLDER = "CyberOS"
- local x, y = term.getSize()
- local osName = "CyberOs"
- local osId = "AZAXFw5b"
- local startupId = "qJSSf0qg"
- local osTierName, osTierId
- local osDeviceName, osDeviceId
- if term.isColor() then
- osTierName = "CyberOsColor"
- osTierId = "ATuWkjAJ"
- else
- osTierName = "CyberOsLite"
- osTierId = "ByAJwwMp"
- end
- -- MONITOR
- if monitor then
- osDeviceName = "CyberOsMonitor"
- osDeviceId = nil
- -- POCKET COMPUTER
- elseif pocket then
- assert(x==39 and y==13, "Something went wrong, size X, Y: '"..x..", "..y.."' is not the 26, 20 expected from a pocket computer")
- osDeviceName = "CyberOsPocket"
- osDeviceId = "BxMFPgc9"
- -- TURTLE
- elseif turtle then
- assert(x==39 and y==13, "Something went wrong, size X, Y: '"..x..", "..y.."' is not the 39, 13 expected from a turtle")
- osDeviceName = "CyberOsTurtle"
- osDeviceId = nil
- -- COMPUTER
- else
- assert(x==51 and y==19, "Something went wrong, size X, Y: '"..x..", "..y.."' is not the 51, 19 expected from a computer")
- osDeviceName = "CyberOsHome"
- osDeviceId = "rd1GDixz"
- end
- -------------------------------------------------------
- -- THIS BIT RUNS ONLY IF INSTALL_FOLDER DOES NOT EXIST
- -- aka CyberOs was never installed.
- -- Creates INSTALL_FOLDER, saves the program as startup
- -- and creates an uninstaller.
- -------------------------------------------------------
- if not fs.exists(INSTALL_FOLDER) then
- if not fs.exists("startup.lua") then
- fs.makeDir(INSTALL_FOLDER)
- shell.run("pastebin", "get", startupId, "startup.lua")
- -- Create an uninstaller
- if fs.exists("uninstallCyberOs")==false then
- local f = fs.open("uninstallCyberOs.lua", "w")
- f.writeLine("fs.delete(\""..INSTALL_FOLDER.."\")")
- f.writeLine("fs.delete(\"startup.lua\")")
- f.writeLine("fs.delete(\"uninstallCyberOs.lua\")")
- f.writeLine("os.reboot()")
- f.close()
- end
- else
- error("To install this OS, no startup.lua file must be present. Delete it with: 'delete startup.lua' and try again")
- end
- end
- --- Local funtion of the installer,
- -- it downloads pastebin apiId
- -- to INSTALL_FOLDER/apiName.lua
- -- and loads it as an API.
- local initApi = function (apiId, apiName)
- local apiPath = INSTALL_FOLDER .. "/" .. apiName .. ".lua"
- if not fs.exists(apiPath) then
- shell.run("pastebin", "get", apiId, apiPath)
- end
- os.loadAPI(apiPath)
- end
- ----------------------------------
- -- Checks for API files, if not
- -- present it downloads them.
- -- Then proceed to load those APIs
- -----------------------------------
- -- Load or install CyberOs, common class to every device
- initApi(osId, osName)
- -- Load or install CyberOsTier (Lite or Color aka Baasic or Advanced)
- initApi(osTierId, osTierName)
- -- Load or install CyberOsDevice (Home, Monitor, Pocket or Turtle)
- if osDeviceId == nil then
- CyberOs.basicWarning("No specific version of the API was found for this Device. "..deviceType.." may be under development.")
- else
- initApi(osDeviceId, osDeviceName)
- end
- ----------------
- -- DISCLAIMER --
- ----------------
- CyberOs.basicWarning("This project is in it's early development stage. Please understand that most functionalities are yet to be implemented, that this Os is prone to crashing and that the Lua files on Pastebin can change at any time. Thank you for downloading this. --The Developer.")
- -- The class defining the tier (basic or advanced)
- local tierClass = _G[osTierName].class
- -- The class defining the device (computer, turtle, etc)
- local deviceClass = _G[osDeviceName].class
- -- The instance representing the OS tweaked for this specific system
- local instance = CyberOs.createInstance(tierClass, deviceClass, shell)
- -- Checks for the settings file, if not
- -- present creates it
- if not fs.exists(INSTALL_FOLDER .. "/.settings") then
- local settings = {}
- settings["bgcolor"] = 32768
- local f = fs.open(INSTALL_FOLDER .. "/.settings", "w")
- f.writeLine(textutils.serialize(settings))
- f.close()
- settings["theme"] = instance:themeSelection()
- f = fs.open(INSTALL_FOLDER .. "/.settings", "w")
- f.writeLine(textutils.serialize(settings))
- f.close()
- end
- instance:startupAnimation()
- -- Checks for the .registeredTurtles file,
- -- if not present creates it
- -- TODO May be better to do this only when needed
- if fs.exists(INSTALL_FOLDER .. "/.registeredTurtles")==false then
- local f = fs.open(INSTALL_FOLDER .. "/.registeredTurtles", "w")
- f.close()
- end
- instance:setBackground()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement