Advertisement
Le_JuiceBOX

os_computer

Aug 16th, 2022 (edited)
875
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.12 KB | None | 0 0
  1. local SEPERATOR = "======================================="
  2. local PROGDIR = [[OS\PROG\]]
  3.  
  4. local STARTUP = 'shell.run("clear"); shell.run("OS/os.lua")'
  5.  
  6. local osActive = true
  7.  
  8. local options_main = {
  9.     {label="Installer",file="Era6PJf4", cmds = {}},
  10.     {label="Shell",file="LKm6jXGQ"}, cmds = {""},
  11. }
  12.  
  13. local optInd = 1
  14. fs.makeDir(PROGDIR)
  15.  
  16. local options_progs = {}
  17.  
  18.  
  19. function Main()
  20.     makeStartup(STARTUP)
  21.     shell.run("clear")
  22.     print(SEPERATOR)
  23.     print("Frogpulp OS - PC Edition")
  24.     print(SEPERATOR)
  25.     optInd = 1
  26.     for i,opt in ipairs(options_main) do
  27.         print(optInd..". "..opt.label)
  28.         optInd = optInd + 1
  29.     end
  30.     for i,file in ipairs(fs.list(PROGDIR)) do
  31.         table.insert(options_progs,i,string.gsub(file,PROGDIR,""))
  32.     end
  33.     print(SEPERATOR)
  34.     for i,v in pairs(options_progs) do
  35.         print(optInd..". "..v)
  36.         optInd = optInd + 1
  37.     end
  38.     if #options_progs == 0 then
  39.         print("No programs.")
  40.     end
  41.     print(SEPERATOR)
  42.     local inp = io.read()
  43.     inp = tonumber(inp)
  44.     print("Enter program to run: (ex. 3)\n")
  45.     shell.run("clear")
  46.     term.setCursorPos(1,1)
  47.     print("Loading...")
  48.     os.sleep(1)
  49.     if inp <= #options_main then
  50.         local but = options_main[inp]
  51.         if but.label == "Shell" then
  52.             shell.run("clear")
  53.             print(SEPERATOR)
  54.             print("Frogpulp OS - Shell")
  55.             print(SEPERATOR.."\nReboot to return to OS.\n\n")
  56.             osActive = false
  57.             return
  58.         else
  59.             print("Running program...")
  60.             if not fs.exists(but.file) then shell.run("pastebin run "..but.file) end
  61.             shell.run(but.file)
  62.         end
  63.     elseif inp > #options_main then
  64.         shell.run(PROGDIR..options_progs[inp-#options_main])
  65.     else
  66.         print("Unrecognized input...")
  67.         os.sleep(0.5)
  68.         return
  69.     end
  70. end
  71.  
  72. function makeStartup(text) -- new
  73.     if fs.exists("startup.lua") then shell.run("delete startup.lua"); end
  74.     local file = fs.open("startup.lua","w")
  75.     file.write(text)
  76.     file.close()
  77. end
  78.  
  79. repeat Main() until not osActive
  80.  
  81.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement