Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- CeGJp05X
- local Terminal = require("/terminal").new()
- function OpenSettings()
- Terminal:reset()
- Terminal:print("&c"..Terminal:makeSeperator("="))
- Terminal:print("&dComputerOS &8- Settings")
- Terminal:print("&c"..Terminal:makeSeperator("="))
- Terminal:print()
- local t = {}
- for i, name in pairs(settings.getNames()) do
- if string.find(name,"bios.") then
- elseif string.find(name,"edit.") then
- elseif string.find(name,"shell.") then
- elseif string.find(name,"lua.") then
- elseif string.find(name,"list.") then
- elseif string.find(name,"paint.") then
- else
- table.insert(t,name)
- end
- end
- for index, value in ipairs(t) do
- print(index..". "..value)
- end
- Terminal:pressAnyKeyToContinue()
- end
- function OpenShell()
- Terminal:reset()
- print("Opening shell...")
- os.sleep(0.5)
- Terminal:reset()
- Terminal:reset()
- Terminal:print("&c"..Terminal:makeSeperator("="))
- Terminal:print("&dComputerOS &8- Shell")
- Terminal:print("&c"..Terminal:makeSeperator("="))
- Terminal:print()
- print("Restart to go back!")
- print()
- return true
- end
- function RunProgram()
- Terminal:reset()
- local path = Terminal:promptFilePath("/OS/Programs",false,"&1Select a program to run ~\n",1)
- if path then
- Terminal:reset()
- print("Opening "..path.."...")
- os.sleep(0.25)
- shell.run(path)
- else
- return
- end
- end
- local mainMenu = {
- {
- Name = "Shell",
- Func = function()
- OpenShell()
- return true;
- end,
- },
- {
- Name = "Applications",
- Func = RunProgram,
- },
- {
- Name = "File Explorer",
- Func = require("/OS/fileExplorer"),
- },
- {
- Name = "Update",
- Func = function()
- Terminal:reset()
- if Terminal:promptConf("Are you sure?") then
- shell.run("/OS/update.lua")
- end
- Terminal:reset()
- end,
- },
- {
- Name = "Pastebin",
- Func = function()
- Terminal:reset()
- Terminal:display(0,
- "&c"..Terminal:makeSeperator("="),
- " &dPastebin wizard ~",
- "&c"..Terminal:makeSeperator("=")
- )
- local _,mode = Terminal:promptOptions("Choose an option:",false,{"Run","Download","Cancel"},5)
- if mode == 3 then
- return
- end
- Terminal:reset()
- Terminal:display(0,
- "&c"..Terminal:makeSeperator("="),
- " &dPastebin wizard ~",
- "&c"..Terminal:makeSeperator("="),
- ""
- )
- local pasteId = Terminal:prompt("Enter the pastebin Id:")
- Terminal:reset()
- Terminal:display(0,
- "&c"..Terminal:makeSeperator("="),
- " &dPastebin wizard ~",
- "&c"..Terminal:makeSeperator("="),
- ""
- )
- if mode == 1 then
- shell.run("pastebin run "..pasteId)
- elseif mode == 2 then
- Terminal:reset()
- Terminal:display(0,
- "&c"..Terminal:makeSeperator("="),
- " &dPastebin wizard ~",
- "&c"..Terminal:makeSeperator("="),
- ""
- )
- local saveLocations = {"OS/Programs/","OS/Programs/Turtle/","Custom Directory"}
- local _,fileLocInd = Terminal:promptOptions("Choose a directory:",false,saveLocations,5)
- local fileLoc = saveLocations[fileLocInd]
- if fileLocInd == 3 then
- Terminal:reset()
- Terminal:display(0,
- "&c"..Terminal:makeSeperator("="),
- " &dPastebin wizard ~",
- "&c"..Terminal:makeSeperator("="),
- ""
- )
- fileLoc = Terminal:prompt("Enter a directory to save the file into: (e.g /OS/)")
- end
- Terminal:reset()
- Terminal:display(0,
- "&c"..Terminal:makeSeperator("="),
- " &dPastebin wizard ~",
- "&c"..Terminal:makeSeperator("="),
- ""
- )
- local fileName = Terminal:prompt("Name the downloaded file: (e.g script.lua)")
- Terminal:reset()
- Terminal:display(0,
- "&c"..Terminal:makeSeperator("="),
- " &dPastebin wizard ~",
- "&c"..Terminal:makeSeperator("="),
- ""
- )
- Terminal:print("Connecting script to the updater redownloads")
- Terminal:print("this script when using this PC's updater.")
- Terminal:print()
- local addFileToUpdater = Terminal:promptConf("Connect to updater?",true)
- if addFileToUpdater then
- settings.load()
- local pastebinScripts = settings.get("PastebinScripts",{})
- table.insert(pastebinScripts,{
- FileName = fileName,
- FilePath = fileLoc,
- PasteId = pasteId
- })
- settings.set("PastebinScripts",pastebinScripts)
- settings.save()
- end
- shell.run("pastebin get "..pasteId.." "..fileLoc..fileName)
- Terminal:pressAnyKeyToContinue()
- end
- end,
- },
- {
- Name = "Settings",
- Func = function()
- Terminal:reset()
- shell.run("OS/options.lua")
- end,
- },
- {
- Name = "Lua",
- Func = function()
- Terminal:reset()
- Terminal:display(0,
- "&c"..Terminal:makeSeperator("="),
- " &dLua ~",
- "&c"..Terminal:makeSeperator("="),
- ""
- )
- shell.run("lua")
- end,
- },
- }
- local diskDrive = nil
- function Main()
- local mode = 0
- fs.delete("."..Terminal:getComputerLabel() or ".Untitled")
- fs.makeDir("."..Terminal:getComputerLabel() or ".Untitled")
- diskDrive = peripheral.find("drive")
- if diskDrive then
- table.insert(mainMenu, {
- Name = "Read Disk",
- Func = function()
- if fs.exists("/disk/install.lua") then
- Terminal:reset()
- local resName, resInd = Terminal:promptOptions("What do you want to do?",true,{"Install","File Explorer","Cancel"})
- if resInd == 1 then
- shell.run("/disk/install.lua")
- elseif resInd == 2 then
- Terminal:promptFilePath("/disk/",true,"Choose file in disk ~")
- elseif resInd == 3 then
- return
- end
- else
- Terminal:promptFilePath("/disk/",true,"Choose file in disk ~")
- return
- end
- end
- })
- end
- local res = false
- repeat
- res = WriteHomeScreen()
- until res
- end
- function WriteHomeScreen()
- Terminal:reset()
- Terminal:display(0,
- "&c"..Terminal:makeSeperator("="),
- "&dComputer OS ~",
- "&c"..Terminal:makeSeperator("=")
- )
- local m = {}
- for i,data in ipairs(mainMenu) do
- m[i] = (" "..data.Name)
- end
- if turtle == nil then
- Terminal:writeLine(Terminal.size.y,"&7"..Terminal:getComputerLabel().." (ID: "..os.getComputerID()..")")
- else
- Terminal:writeLine(Terminal.size.y,"&7"..Terminal:getComputerLabel().." (ID: "..os.getComputerID()..") (FL: "..Terminal.formatInt(turtle.getFuelLevel())..")")
- end
- local _,res = Terminal:promptOptions(nil,false,m,4) -- prompt main menu options
- return mainMenu[res].Func()
- end
- Main()
Advertisement
Add Comment
Please, Sign In to add comment