Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- WARNING DO NOT EDIT SCRIPT THIS EILL BUG OS
- -- if you are best at script why you give it an try
- -- to see make an os but if you are an noob
- -- dont edit
- -- Color Saveing
- if fs.exists("bsave.txt") then
- if not term.isColor() then
- term.setBackgroundColor(colors.black)
- else
- local f = fs.open("bsave.txt", "r")
- local savedColor = f.readAll()
- f.close()
- if savedColor == "green" then
- term.setBackgroundColor(colors.green)
- elseif savedColor == "blue" then
- term.setBackgroundColor(colors.blue)
- elseif savedColor == "black" then
- term.setBackgroundColor(colors.black)
- elseif savedColor == "gray" then
- term.setBackgroundColor(colors.gray)
- end
- end
- term.clear()
- end
- -- MineOS
- local running = true
- -- start at first
- os.setComputerLabel("2.3")
- term.setCursorPos(1,1)
- term.clear()
- term.setTextColor(colors.yellow)
- print("Welcome Player!")
- sleep(3)
- term.clear()
- term.setCursorPos(1,1)
- print("MineOS2")
- -- prompt
- while running do
- -- detector
- term.setTextColor(colors.yellow)
- io.write("> ")
- term.setTextColor(colors.white)
- local input = read()
- local args = {}
- for word in string.gmatch(input, "[^%s]+") do
- table.insert(args, word)
- end
- local command = args[1]
- -- commands
- if command == "about" then
- print(" _______ MineOS")
- print(" | | | Version: 2.3")
- print(" | S | e | Kernel: DEV2")
- print(" | O | n | CCID: " .. os.getComputerID())
- print(" | | i | Uptime: " .. math.floor(os.clock()) .. "s")
- print(" | > | M | CR: 2023 - 2025")
- if term.isColor() then
- print(" Color: true")
- else
- print(" Color: false")
- end
- elseif command == "help" then
- term.setTextColor(colors.orange)
- print("Help")
- term.setTextColor(colors.white)
- print("tipe 'plist' or 'mlist'")
- elseif command == "plist" then
- local dir = shell.dir()
- local files = fs.list(dir)
- for i, file in ipairs(files) do
- local fullPath = fs.combine(dir, file)
- local isStartupInRoot = (dir == "/" or dir == "") and file == "startup.lua"
- local isHidden = file:match("^%.")
- local isRom = file == "rom"
- if not isRom and not isStartupInRoot and not isHidden then
- if fs.isDir(fullPath) then
- print("FO " .. file)
- else
- print("FI " .. file)
- end
- end
- end
- elseif command == "hello" then
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.orange)
- textutils.slowPrint("Hello World!")
- sleep(3)
- term.clear()
- term.setCursorPos(1,1)
- elseif command == "pedit" then
- local filename = args[2]
- if filename then
- local lower = string.lower(filename)
- if lower == "startup" or lower == "startup.lua" then
- print("Warning you about to edit OS File")
- sleep(2)
- local prevBG = term.getBackgroundColor()
- shell.run("edit", "startup.lua")
- term.setBackgroundColor(prevBG)
- term.clear()
- term.setCursorPos(1, 1)
- elseif fs.isDir(filename) then
- print("Cannot edit folder")
- else
- local ok, err = pcall(function()
- local prevBG = term.getBackgroundColor()
- shell.run("edit", filename)
- term.setBackgroundColor(prevBG)
- term.clear()
- term.setCursorPos(1, 1)
- end)
- if not term.isColor() then
- term.clear()
- term.setCursorPos(1,1)
- else
- if not ok then print("Edit failed "..tostring(err)) end
- if ok and fs.exists("bsave.txt") then
- local f = fs.open("bsave.txt", "r")
- local saved = f.readAll()
- f.close()
- if colors[saved] then
- term.setBackgroundColor(colors[saved])
- term.clear()
- term.setCursorPos(1, 1)
- end
- end
- end
- end
- end
- elseif command == "popen" then
- local progName = args[2]
- if progName then
- local lower = string.lower(progName)
- if lower == "startup" or lower == "startup.lua" then
- print("Error opening that file")
- elseif shell.resolveProgram(progName) then
- print("Running " .. progName)
- shell.run(progName)
- else
- print("Unknown Program to open")
- end
- end
- elseif command == "mlist" then
- local lines = {
- "",
- "hello",
- "about",
- "shutoff",
- "popen <1>",
- "pedit <1>",
- "reboot",
- "cls",
- "shell",
- "cal <math>",
- "plist",
- "mlist",
- "pdelete <1>",
- "pir <ins/run>",
- "prename <1> <2>",
- "cd <1>",
- "mfolder <1>",
- "tcolor <color>"
- }
- local w, h = term.getSize()
- local line = 0
- line = 2
- for i = 2, #lines do
- print(lines[i])
- line = line + 1
- if line >= h then
- print("Press any key to continue...")
- os.pullEvent("key")
- term.clear()
- term.setCursorPos(1,1)
- line = 2
- end
- end
- elseif command == "shutoff" then
- term.clear()
- term.setCursorPos(1,1)
- print("Please Wait...")
- sleep(1)
- term.setCursorPos(1,1)
- term.setTextColor(colors.red)
- print("ShuttingOFF...")
- sleep(4)
- running = false
- os.shutdown()
- elseif command == "reboot" then
- term.clear()
- term.setCursorPos(1,1)
- print("Please Wait...")
- sleep(1)
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.red)
- print("Rebooting...")
- sleep(4)
- running = false
- os.reboot()
- elseif command == "cls" then
- term.clear()
- term.setCursorPos(1,1)
- elseif command == "shell" then
- term.setTextColor(colors.yellow)
- print("MineOS2")
- elseif command == "cal" then
- local expression = input:sub(5) -- everything after 'cal '
- local fn, err = load("return " .. expression)
- if fn then
- local ok, result = pcall(fn)
- if ok then
- print(result)
- else
- print("Error")
- end
- end
- elseif command == "pdelete" then
- local filename = args[2]
- if filename then
- filename = filename
- local currentDir = shell.dir()
- local fullPath = fs.combine(currentDir, filename)
- local lower = string.lower(filename)
- if currentDir == "" and (lower == "startup.lua" or lower == "startup") then
- print("Error deleting that file")
- elseif fs.exists(fullPath) then
- fs.delete(fullPath)
- print("Deleted " .. filename)
- else
- print("File not found " .. filename)
- end
- end
- elseif command == "pir" then
- local sub = args[2]
- local code = args[3]
- if sub == "run" and code then
- shell.run("pastebin", "run", code)
- elseif sub == "ins" and code then
- local saveAs = "pir_" .. code
- shell.run("pastebin", "get", code, saveAs)
- print("Installed as " .. saveAs)
- end
- elseif command == "prename" then
- local oldName = args[2]
- local newName = args[3]
- if not oldName or not newName then
- else
- oldName = oldName .. ".lua"
- newName = newName .. ".lua"
- local currentDir = shell.dir()
- local fullOldPath = fs.combine(currentDir, oldName)
- local fullNewPath = fs.combine(currentDir, newName)
- if currentDir == "" and (oldName == "startup.lua" or newName == "startup.lua") then
- print("Error renaming that file")
- elseif not fs.exists(fullOldPath) then
- print("Not exist" .. oldName)
- elseif fs.exists(fullNewPath) then
- print("Already exists " .. newName)
- else
- fs.move(fullOldPath, fullNewPath)
- print("Renamed " .. newName)
- end
- end
- elseif command == "cd" then
- local target = args[2]
- if target and fs.exists(target) and fs.isDir(target) then
- shell.setDir(target)
- print("Changed Dir " .. shell.dir())
- else
- print("Dir not found")
- end
- elseif command == "mfolder" then
- local folderName = args[2]
- if folderName then
- local currentDir = shell.dir()
- local fullPath = fs.combine(currentDir, folderName)
- if fs.exists(fullPath) then
- print("Folder exist")
- else
- fs.makeDir(fullPath)
- print("Created " .. folderName)
- end
- end
- elseif command == "tcolor" then
- if not term.isColor() then
- print("This computer cant work with colors")
- else
- local colorname = args[2]
- if colorname == "green" then
- term.setBackgroundColor(colors.green)
- term.clear()
- term.setCursorPos(1,1)
- local f = fs.open("bsave.txt", "w")
- f.write("green")
- f.close()
- elseif colorname == "blue" then
- term.setBackgroundColor(colors.blue)
- term.clear()
- term.setCursorPos(1,1)
- local f = fs.open("bsave.txt", "w")
- f.write("blue")
- f.close()
- elseif colorname == "black" then
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- local f = fs.open("bsave.txt", "w")
- f.write("black")
- f.close()
- elseif colorname == "gray" then
- term.setBackgroundColor(colors.gray)
- term.clear()
- term.setCursorPos(1,1)
- local f = fs.open("bsave.txt", "w")
- f.write("gray")
- f.close()
- elseif colorname == "help" then
- print("Colors only that you can change")
- print("Blue/Gray/Black/Green")
- else
- print("Invalid color.")
- end
- end
- else
- print("Unknown MProgram to open")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment