GochiPC

2.3

Jul 21st, 2025 (edited)
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.36 KB | None | 0 0
  1. -- WARNING DO NOT EDIT SCRIPT THIS EILL BUG OS
  2. -- if you are best at script why you give it an try
  3. -- to see make an os but if you are an noob
  4. -- dont edit
  5.  
  6. -- Color Saveing
  7. if fs.exists("bsave.txt") then
  8.   if not term.isColor() then
  9.    term.setBackgroundColor(colors.black)
  10.   else
  11.    local f = fs.open("bsave.txt", "r")
  12.    local savedColor = f.readAll()
  13.    f.close()
  14.    if savedColor == "green" then
  15.      term.setBackgroundColor(colors.green)
  16.    elseif savedColor == "blue" then
  17.      term.setBackgroundColor(colors.blue)
  18.    elseif savedColor == "black" then
  19.      term.setBackgroundColor(colors.black)
  20.    elseif savedColor == "gray" then
  21.      term.setBackgroundColor(colors.gray)
  22.    end
  23.   end
  24.   term.clear()
  25. end
  26.  
  27. -- MineOS
  28. local running = true
  29.  
  30. -- start at first
  31. os.setComputerLabel("2.3")
  32. term.setCursorPos(1,1)
  33. term.clear()
  34. term.setTextColor(colors.yellow)
  35. print("Welcome Player!")
  36. sleep(3)
  37. term.clear()
  38. term.setCursorPos(1,1)
  39. print("MineOS2")
  40.  
  41. -- prompt
  42. while running do
  43.    
  44.     -- detector
  45.     term.setTextColor(colors.yellow)
  46.     io.write("> ")
  47.     term.setTextColor(colors.white)
  48.     local input = read()
  49.     local args = {}
  50.     for word in string.gmatch(input, "[^%s]+") do
  51.         table.insert(args, word)
  52.     end
  53.  
  54.     local command = args[1]
  55.  
  56. -- commands
  57.  
  58.     if command == "about" then
  59.         print("   _______    MineOS")
  60.         print("  |   |   |   Version: 2.3")
  61.         print("  | S | e |   Kernel: DEV2")
  62.         print("  | O | n |   CCID: " .. os.getComputerID())
  63.         print("  |   | i |   Uptime: " .. math.floor(os.clock()) .. "s")
  64.         print("  | > | M |   CR: 2023 - 2025")
  65.         if term.isColor() then
  66.             print("              Color: true")
  67.         else
  68.             print("              Color: false")
  69.         end
  70.        
  71.     elseif command == "help" then
  72.         term.setTextColor(colors.orange)
  73.         print("Help")
  74.         term.setTextColor(colors.white)
  75.         print("tipe 'plist' or 'mlist'")
  76.        
  77.         elseif command == "plist" then
  78.         local dir = shell.dir()
  79.         local files = fs.list(dir)
  80.         for i, file in ipairs(files) do
  81.             local fullPath = fs.combine(dir, file)
  82.             local isStartupInRoot = (dir == "/" or dir == "") and file == "startup.lua"
  83.             local isHidden = file:match("^%.")
  84.             local isRom = file == "rom"
  85.             if not isRom and not isStartupInRoot and not isHidden then
  86.                 if fs.isDir(fullPath) then
  87.                     print("FO " .. file)
  88.                 else
  89.                     print("FI " .. file)
  90.                 end
  91.             end
  92.         end
  93.        
  94.     elseif command == "hello" then
  95.         term.clear()
  96.         term.setCursorPos(1,1)
  97.         term.setTextColor(colors.orange)
  98.         textutils.slowPrint("Hello World!")
  99.         sleep(3)
  100.         term.clear()
  101.         term.setCursorPos(1,1)
  102.        
  103.     elseif command == "pedit" then
  104.      local filename = args[2]
  105.      if filename then
  106.       local lower = string.lower(filename)
  107.       if lower == "startup" or lower == "startup.lua" then
  108.        print("Warning you about to edit OS File")
  109.        sleep(2)
  110.        local prevBG = term.getBackgroundColor()
  111.        shell.run("edit", "startup.lua")
  112.        term.setBackgroundColor(prevBG)
  113.        term.clear()
  114.        term.setCursorPos(1, 1)
  115.       elseif fs.isDir(filename) then
  116.        print("Cannot edit folder")
  117.       else
  118.          local ok, err = pcall(function()
  119.          local prevBG = term.getBackgroundColor()
  120.          shell.run("edit", filename)
  121.          term.setBackgroundColor(prevBG)
  122.          term.clear()
  123.          term.setCursorPos(1, 1)
  124.       end)
  125.       if not term.isColor() then
  126.       term.clear()
  127.       term.setCursorPos(1,1)
  128.       else
  129.        if not ok then print("Edit failed "..tostring(err)) end
  130.        if ok and fs.exists("bsave.txt") then
  131.         local f = fs.open("bsave.txt", "r")
  132.         local saved = f.readAll()
  133.         f.close()
  134.         if colors[saved] then
  135.          term.setBackgroundColor(colors[saved])
  136.          term.clear()
  137.          term.setCursorPos(1, 1)
  138.         end
  139.        end
  140.       end
  141.      end
  142.     end
  143.        
  144.     elseif command == "popen" then
  145.         local progName = args[2]
  146.         if progName then
  147.             local lower = string.lower(progName)
  148.             if lower == "startup" or lower == "startup.lua" then
  149.                 print("Error opening that file")
  150.             elseif shell.resolveProgram(progName) then
  151.                 print("Running " .. progName)
  152.                 shell.run(progName)
  153.             else
  154.                 print("Unknown Program to open")
  155.             end
  156.         end
  157.    
  158.     elseif command == "mlist" then
  159.       local lines = {
  160.         "",
  161.         "hello",
  162.         "about",
  163.         "shutoff",
  164.         "popen <1>",
  165.         "pedit <1>",
  166.         "reboot",
  167.         "cls",
  168.         "shell",
  169.         "cal <math>",
  170.         "plist",
  171.         "mlist",
  172.         "pdelete <1>",
  173.         "pir <ins/run>",
  174.         "prename <1> <2>",
  175.         "cd <1>",
  176.         "mfolder <1>",
  177.         "tcolor <color>"
  178.       }
  179.  
  180.       local w, h = term.getSize()
  181.       local line = 0
  182.       line = 2
  183.       for i = 2, #lines do
  184.         print(lines[i])
  185.         line = line + 1
  186.         if line >= h then
  187.             print("Press any key to continue...")
  188.             os.pullEvent("key")
  189.             term.clear()
  190.             term.setCursorPos(1,1)
  191.             line = 2
  192.         end
  193.       end
  194.        
  195.     elseif command == "shutoff" then
  196.         term.clear()
  197.         term.setCursorPos(1,1)
  198.         print("Please Wait...")
  199.         sleep(1)
  200.         term.setCursorPos(1,1)
  201.         term.setTextColor(colors.red)
  202.         print("ShuttingOFF...")
  203.         sleep(4)
  204.         running = false
  205.         os.shutdown()
  206.    
  207.     elseif command == "reboot" then
  208.         term.clear()
  209.         term.setCursorPos(1,1)
  210.         print("Please Wait...")
  211.         sleep(1)
  212.         term.clear()
  213.         term.setCursorPos(1,1)
  214.         term.setTextColor(colors.red)
  215.         print("Rebooting...")
  216.         sleep(4)
  217.         running = false
  218.         os.reboot()
  219.    
  220.     elseif command == "cls" then
  221.         term.clear()
  222.         term.setCursorPos(1,1)
  223.    
  224.     elseif command == "shell" then
  225.         term.setTextColor(colors.yellow)
  226.         print("MineOS2")
  227.        
  228.     elseif command == "cal" then
  229.         local expression = input:sub(5) -- everything after 'cal '
  230.         local fn, err = load("return " .. expression)
  231.         if fn then
  232.             local ok, result = pcall(fn)
  233.             if ok then
  234.                 print(result)
  235.             else
  236.                 print("Error")
  237.             end
  238.         end
  239.        
  240.     elseif command == "pdelete" then
  241.       local filename = args[2]
  242.  
  243.       if filename then
  244.         filename = filename
  245.         local currentDir = shell.dir()
  246.         local fullPath = fs.combine(currentDir, filename)
  247.         local lower = string.lower(filename)
  248.         if currentDir == "" and (lower == "startup.lua" or lower == "startup") then
  249.             print("Error deleting that file")
  250.         elseif fs.exists(fullPath) then
  251.             fs.delete(fullPath)
  252.             print("Deleted " .. filename)
  253.         else
  254.             print("File not found " .. filename)
  255.         end
  256.       end
  257.        
  258.     elseif command == "pir" then
  259.       local sub = args[2]
  260.       local code = args[3]
  261.  
  262.       if sub == "run" and code then
  263.         shell.run("pastebin", "run", code)
  264.  
  265.       elseif sub == "ins" and code then
  266.         local saveAs = "pir_" .. code
  267.         shell.run("pastebin", "get", code, saveAs)
  268.         print("Installed as " .. saveAs)
  269.       end
  270.        
  271.     elseif command == "prename" then
  272.       local oldName = args[2]
  273.       local newName = args[3]
  274.  
  275.       if not oldName or not newName then
  276.       else
  277.         oldName = oldName .. ".lua"
  278.         newName = newName .. ".lua"
  279.         local currentDir = shell.dir()
  280.         local fullOldPath = fs.combine(currentDir, oldName)
  281.         local fullNewPath = fs.combine(currentDir, newName)
  282.         if currentDir == "" and (oldName == "startup.lua" or newName == "startup.lua") then
  283.             print("Error renaming that file")
  284.         elseif not fs.exists(fullOldPath) then
  285.             print("Not exist" .. oldName)
  286.         elseif fs.exists(fullNewPath) then
  287.             print("Already exists " .. newName)
  288.         else
  289.             fs.move(fullOldPath, fullNewPath)
  290.             print("Renamed " .. newName)
  291.         end
  292.       end
  293.        
  294.     elseif command == "cd" then
  295.         local target = args[2]
  296.         if target and fs.exists(target) and fs.isDir(target) then
  297.             shell.setDir(target)
  298.             print("Changed Dir " .. shell.dir())
  299.         else
  300.             print("Dir not found")
  301.         end
  302.        
  303.     elseif command == "mfolder" then
  304.           local folderName = args[2]
  305.           if folderName then
  306.             local currentDir = shell.dir()
  307.             local fullPath = fs.combine(currentDir, folderName)
  308.             if fs.exists(fullPath) then
  309.               print("Folder exist")
  310.             else
  311.               fs.makeDir(fullPath)
  312.               print("Created " .. folderName)
  313.             end
  314.           end
  315.        
  316.    elseif command == "tcolor" then
  317.     if not term.isColor() then
  318.      print("This computer cant work with colors")
  319.     else
  320.      local colorname = args[2]
  321.      if colorname == "green" then
  322.      term.setBackgroundColor(colors.green)
  323.      term.clear()
  324.      term.setCursorPos(1,1)
  325.      local f = fs.open("bsave.txt", "w")
  326.      f.write("green")
  327.      f.close()
  328.      elseif colorname == "blue" then
  329.      term.setBackgroundColor(colors.blue)
  330.      term.clear()
  331.      term.setCursorPos(1,1)
  332.      local f = fs.open("bsave.txt", "w")
  333.      f.write("blue")
  334.      f.close()
  335.      elseif colorname == "black" then
  336.      term.setBackgroundColor(colors.black)
  337.      term.clear()
  338.      term.setCursorPos(1,1)
  339.      local f = fs.open("bsave.txt", "w")
  340.      f.write("black")
  341.      f.close()
  342.      elseif colorname == "gray" then
  343.      term.setBackgroundColor(colors.gray)
  344.      term.clear()
  345.      term.setCursorPos(1,1)
  346.      local f = fs.open("bsave.txt", "w")
  347.      f.write("gray")
  348.      f.close()
  349.      elseif colorname == "help" then
  350.       print("Colors only that you can change")
  351.       print("Blue/Gray/Black/Green")
  352.      else
  353.      print("Invalid color.")
  354.      end
  355.     end
  356.        
  357.     else
  358.         print("Unknown MProgram to open")
  359.     end
  360. end
  361.  
Advertisement
Add Comment
Please, Sign In to add comment