GochiPC

2.5

Jul 31st, 2025
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 13.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. wel = "Welcome Player!"
  27.  
  28. -- Monitor
  29. local monitor = peripheral.find("monitor")
  30. if monitor then
  31.     monitor.setBackgroundColor(colors.black)
  32.     monitor.clear()
  33.     monitor.setCursorPos(1,1)
  34.     monitor.write("MineOS2 Signal")
  35. end
  36.  
  37. -- MineOS
  38. local running = true
  39.  
  40. -- start at first
  41. os.setComputerLabel("2.5")
  42. term.setCursorPos(1,1)
  43. term.clear()
  44. term.setTextColor(colors.yellow)
  45. if fs.exists("nsave.txt") then
  46.       local file = fs.open("nsave.txt", "r")
  47.       local saved = file.readAll()
  48.       file.close()
  49.       print("Welcome " .. saved .. "!")
  50. else
  51.       print(wel)
  52. end
  53.  
  54. local speaker = peripheral.find("speaker")
  55. if speaker then
  56.   speaker.playNote("pling", 1.0, 12)
  57.   sleep(0.4)
  58.   speaker.playNote("pling", 1.0, 10)
  59. end
  60. sleep(3)
  61. term.clear()
  62. term.setCursorPos(1,1)
  63. print("MineOS2")
  64.  
  65. -- prompt
  66. while running do
  67.    
  68.     -- detector
  69.     term.setTextColor(colors.yellow)
  70.     io.write("> ")
  71.     term.setTextColor(colors.white)
  72.     local input = read()
  73.     local args = {}
  74.     for word in string.gmatch(input, "[^%s]+") do
  75.         table.insert(args, word)
  76.     end
  77.  
  78.     local command = args[1]
  79.  
  80. -- commands
  81.  
  82.     if command == "about" then
  83.         print("   _______    MineOS")
  84.         print("  |   |   |   Version: 2.5")
  85.         print("  | S | e |   Kernel: DEV2")
  86.         print("  | O | n |   CCID: " .. os.getComputerID())
  87.         print("  |   | i |   Uptime: " .. math.floor(os.clock()) .. "s")
  88.         print("  | > | M |   CR: 2023 - 2025")
  89.         if term.isColor() then
  90.             print("              Color: true")
  91.         else
  92.             print("              Color: false")
  93.         end
  94.        
  95.     elseif command == "help" then
  96.         term.setTextColor(colors.orange)
  97.         print("Help")
  98.         term.setTextColor(colors.white)
  99.         print("tipe 'plist' or 'mlist'")
  100.        
  101.         elseif command == "plist" then
  102.         local dir = shell.dir()
  103.         local files = fs.list(dir)
  104.         for i, file in ipairs(files) do
  105.             local fullPath = fs.combine(dir, file)
  106.             local isStartupInRoot = (dir == "/" or dir == "") and file == "startup.lua"
  107.             local isHidden = file:match("^%.")
  108.             local isRom = file == "rom"
  109.             if not isRom and not isStartupInRoot and not isHidden then
  110.                 if fs.isDir(fullPath) then
  111.                     print("FO " .. file)
  112.                 else
  113.                     print("FI " .. file)
  114.                 end
  115.             end
  116.         end
  117.        
  118.     elseif command == "hello" then
  119.         term.clear()
  120.         term.setCursorPos(1,1)
  121.         term.setTextColor(colors.orange)
  122.         textutils.slowPrint("Hello World!")
  123.         sleep(3)
  124.         term.clear()
  125.         term.setCursorPos(1,1)
  126.        
  127.     elseif command == "pedit" then
  128.      local filename = args[2]
  129.      if filename then
  130.       local lower = string.lower(filename)
  131.       if lower == "startup" or lower == "startup.lua" then
  132.        print("Warning you about to edit OS File")
  133.        sleep(2)
  134.        local prevBG = term.getBackgroundColor()
  135.        shell.run("edit", "startup.lua")
  136.        term.setBackgroundColor(prevBG)
  137.        term.clear()
  138.        term.setCursorPos(1, 1)
  139.       elseif fs.isDir(filename) then
  140.        print("Cannot edit folder")
  141.       else
  142.          local ok, err = pcall(function()
  143.          local prevBG = term.getBackgroundColor()
  144.          shell.run("edit", filename)
  145.          term.setBackgroundColor(prevBG)
  146.          term.clear()
  147.          term.setCursorPos(1, 1)
  148.       end)
  149.       if not term.isColor() then
  150.       term.clear()
  151.       term.setCursorPos(1,1)
  152.       else
  153.        if not ok then print("Edit failed "..tostring(err)) end
  154.        if ok and fs.exists("bsave.txt") then
  155.         local f = fs.open("bsave.txt", "r")
  156.         local saved = f.readAll()
  157.         f.close()
  158.         if colors[saved] then
  159.          term.setBackgroundColor(colors[saved])
  160.          term.clear()
  161.          term.setCursorPos(1, 1)
  162.         end
  163.        end
  164.       end
  165.      end
  166.     end
  167.        
  168.     elseif command == "popen" then
  169.         local progName = args[2]
  170.         if progName then
  171.             local lower = string.lower(progName)
  172.             if lower == "startup" or lower == "startup.lua" then
  173.                 print("Error opening that file")
  174.             elseif shell.resolveProgram(progName) then
  175.                 print("Running " .. progName)
  176.                 shell.run(progName)
  177.             else
  178.                 print("Unknown Program to open")
  179.             end
  180.         end
  181.    
  182.     elseif command == "mlist" then
  183.       local lines = {
  184.         "",
  185.         "hello",
  186.         "about",
  187.         "shutoff",
  188.         "popen <1>",
  189.         "pedit <1>",
  190.         "reboot",
  191.         "cls",
  192.         "shell",
  193.         "cal <math>",
  194.         "plist",
  195.         "mlist",
  196.         "pdelete <1>",
  197.         "pir <ins/run>",
  198.         "prename <1> <2>",
  199.         "cd <1>",
  200.         "mfolder <1>",
  201.         "tcolor <help>",
  202.         "cname <1>",
  203.         "monitor <help> ",
  204.         "time",
  205.         "say <1>"
  206.       }
  207.  
  208.       local w, h = term.getSize()
  209.       local line = 0
  210.       line = 2
  211.       for i = 2, #lines do
  212.         print(lines[i])
  213.         line = line + 1
  214.         if line >= h then
  215.             print("Press any key to continue...")
  216.             os.pullEvent("key")
  217.             term.clear()
  218.             term.setCursorPos(1,1)
  219.             line = 2
  220.         end
  221.       end
  222.        
  223.     elseif command == "shutoff" then
  224.         term.clear()
  225.         term.setCursorPos(1,1)
  226.         print("Please Wait...")
  227.         sleep(1)
  228.         term.setCursorPos(1,1)
  229.         term.setTextColor(colors.red)
  230.         print("ShuttingOFF...")
  231.         sleep(4)
  232.         running = false
  233.         os.shutdown()
  234.    
  235.     elseif command == "reboot" then
  236.         term.clear()
  237.         term.setCursorPos(1,1)
  238.         print("Please Wait...")
  239.         sleep(1)
  240.         term.clear()
  241.         term.setCursorPos(1,1)
  242.         term.setTextColor(colors.red)
  243.         print("Rebooting...")
  244.         sleep(4)
  245.         running = false
  246.         os.reboot()
  247.    
  248.     elseif command == "cls" then
  249.         term.clear()
  250.         term.setCursorPos(1,1)
  251.    
  252.     elseif command == "shell" then
  253.         term.setTextColor(colors.yellow)
  254.         print("MineOS2")
  255.        
  256.     elseif command == "cal" then
  257.         local expression = input:sub(5) -- everything after 'cal '
  258.         local fn, err = load("return " .. expression)
  259.         if fn then
  260.             local ok, result = pcall(fn)
  261.             if ok then
  262.                 print(result)
  263.             else
  264.                 print("Error")
  265.             end
  266.         end
  267.        
  268.     elseif command == "pdelete" then
  269.       local filename = args[2]
  270.  
  271.       if filename then
  272.         filename = filename
  273.         local currentDir = shell.dir()
  274.         local fullPath = fs.combine(currentDir, filename)
  275.         local lower = string.lower(filename)
  276.         if currentDir == "" and (lower == "startup.lua" or lower == "startup") then
  277.             print("Error deleting that file")
  278.         elseif fs.exists(fullPath) then
  279.             fs.delete(fullPath)
  280.             print("Deleted " .. filename)
  281.         else
  282.             print("File not found " .. filename)
  283.         end
  284.       end
  285.        
  286.     elseif command == "pir" then
  287.       local sub = args[2]
  288.       local code = args[3]
  289.  
  290.       if sub == "run" and code then
  291.         shell.run("pastebin", "run", code)
  292.  
  293.       elseif sub == "ins" and code then
  294.         local saveAs = "pir_" .. code
  295.         shell.run("pastebin", "get", code, saveAs)
  296.         print("Installed as " .. saveAs)
  297.       end
  298.        
  299.     elseif command == "prename" then
  300.       local oldName = args[2]
  301.       local newName = args[3]
  302.  
  303.       if not oldName or not newName then
  304.       else
  305.         oldName = oldName .. ".lua"
  306.         newName = newName .. ".lua"
  307.         local currentDir = shell.dir()
  308.         local fullOldPath = fs.combine(currentDir, oldName)
  309.         local fullNewPath = fs.combine(currentDir, newName)
  310.         if currentDir == "" and (oldName == "startup.lua" or newName == "startup.lua") then
  311.             print("Error renaming that file")
  312.         elseif not fs.exists(fullOldPath) then
  313.             print("Not exist" .. oldName)
  314.         elseif fs.exists(fullNewPath) then
  315.             print("Already exists " .. newName)
  316.         else
  317.             fs.move(fullOldPath, fullNewPath)
  318.             print("Renamed " .. newName)
  319.         end
  320.       end
  321.        
  322.     elseif command == "cd" then
  323.         local target = args[2]
  324.         if target and fs.exists(target) and fs.isDir(target) then
  325.             shell.setDir(target)
  326.             print("Changed Dir " .. shell.dir())
  327.         else
  328.             print("Dir not found")
  329.         end
  330.        
  331.     elseif command == "mfolder" then
  332.           local folderName = args[2]
  333.           if folderName then
  334.             local currentDir = shell.dir()
  335.             local fullPath = fs.combine(currentDir, folderName)
  336.             if fs.exists(fullPath) then
  337.               print("Folder exist")
  338.             else
  339.               fs.makeDir(fullPath)
  340.               print("Created " .. folderName)
  341.             end
  342.           end
  343.        
  344.    elseif command == "tcolor" then
  345.     if not term.isColor() then
  346.      print("This computer cant work with colors")
  347.     else
  348.      local colorname = args[2]
  349.      if colorname == "green" then
  350.      term.setBackgroundColor(colors.green)
  351.      term.clear()
  352.      term.setCursorPos(1,1)
  353.      local f = fs.open("bsave.txt", "w")
  354.      f.write("green")
  355.      f.close()
  356.      elseif colorname == "blue" then
  357.      term.setBackgroundColor(colors.blue)
  358.      term.clear()
  359.      term.setCursorPos(1,1)
  360.      local f = fs.open("bsave.txt", "w")
  361.      f.write("blue")
  362.      f.close()
  363.      elseif colorname == "black" then
  364.      term.setBackgroundColor(colors.black)
  365.      term.clear()
  366.      term.setCursorPos(1,1)
  367.      local f = fs.open("bsave.txt", "w")
  368.      f.write("black")
  369.      f.close()
  370.      elseif colorname == "gray" then
  371.      term.setBackgroundColor(colors.gray)
  372.      term.clear()
  373.      term.setCursorPos(1,1)
  374.      local f = fs.open("bsave.txt", "w")
  375.      f.write("gray")
  376.      f.close()
  377.      elseif colorname == "help" then
  378.       print("Colors only that you can change")
  379.       print("Blue/Gray/Black/Green")
  380.      else
  381.      print("Invalid color.")
  382.      end
  383.     end
  384.    elseif command == "cname" then
  385.     if args[2] then
  386.       local file = fs.open("nsave.txt", "w")
  387.       file.write(args[2])
  388.       file.close()
  389.       print("Name saved: " .. args[2])
  390.     end
  391.        
  392.    elseif command == "say" then
  393.     local message = input:match("^%S+%s+(.+)")
  394.     if message then
  395.       print(message)
  396.     end
  397.    elseif command == "time" then
  398.        local current = os.date("%I:%M %p")
  399.        print("time: " .. current)
  400.            
  401.    elseif command == "monitor" then
  402.     if not monitor then
  403.         print("monitor didint detected")
  404.     end
  405.  
  406.     if monitor then
  407.         local moch = args[2]
  408.         local coch = args[3]
  409.  
  410.         if moch == "clear" then
  411.             monitor.clear()
  412.  
  413.         elseif moch == "help" then
  414.             print("color")
  415.             print("clear")
  416.             print("help")
  417.             print("say <1>")
  418.  
  419.         elseif moch == "color" then
  420.             if not monitor.isColor() then
  421.                 print("Monitor not support colors")
  422.             else
  423.                 if coch == "blue" then
  424.                     monitor.setBackgroundColor(colors.blue)
  425.                     monitor.clear()
  426.                     print("changed color blue")
  427.                 elseif coch == "gray" then
  428.                     monitor.setBackgroundColor(colors.gray)
  429.                     monitor.clear()
  430.                     print("changed color gray")
  431.                 elseif coch == "black" then
  432.                     monitor.setBackgroundColor(colors.black)
  433.                     monitor.clear()
  434.                     print("changed color black")
  435.                 elseif coch == "green" then
  436.                     monitor.setBackgroundColor(colors.green)
  437.                     monitor.clear()
  438.                     print("changed color green")
  439.                 elseif coch == "help" then
  440.                     print("colors that you can change")
  441.                     print("blue/gray/black/green")
  442.                 else
  443.                     print("Unknown color")
  444.                 end
  445.             end
  446.  
  447.         elseif moch == "say" then
  448.             local messageParts = {}
  449.             for i = 3, #args do
  450.                 table.insert(messageParts, args[i])
  451.             end
  452.             local message = table.concat(messageParts, " ")
  453.  
  454.             monitor.setCursorPos(1, 1)
  455.             monitor.clear()
  456.             monitor.write(message)
  457.         end
  458.     end
  459.    else
  460.         print("Unknown MProgram to open")
  461.    end
  462. end
  463.  
Advertisement
Add Comment
Please, Sign In to add comment