Advertisement
Le_JuiceBOX

os_turtle

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