Advertisement
Le_JuiceBOX

os_installer

Aug 16th, 2022 (edited)
752
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.59 KB | None | 0 0
  1. local PASTEBIN_URL = "https://pastebin.com/"
  2. local PASTEBIN_RAW_URL = "https://pastebin.com/raw/"
  3. local SEPERATOR = "======================================="
  4. local PROGDIR = 'OS/PROG/'
  5.  
  6. local repo = {
  7.     {
  8.         Name = "FrogpulpOS - Turtle",
  9.         FileName = "os", Id = "rqwVKAfR",
  10.         Path="OS/",
  11.         UsePasteLink = true,
  12.     },
  13.     {
  14.         Name = "FrogpulpOS - Computer",
  15.         FileName = "os", Id = "m4Ljnijb",
  16.         Path="OS/",
  17.         UsePasteLink = true,
  18.     },
  19.     {
  20.         Name = "Turtle - Bore v2.1",
  21.         FileName = "bore_v2-1",
  22.         Id = "VdYprGR1",
  23.         Path = PROGDIR,
  24.         UsePasteLink = true,
  25.     },
  26.     {
  27.         Name = "Turtle - Bore v2",
  28.         FileName = "bore_v2",
  29.         Id = "7h9kZ1ZM",
  30.         Path = PROGDIR,
  31.         UsePasteLink = true,
  32.     },
  33.     {
  34.         Name = "Turtle - Floor",
  35.         FileName = "bore_floor",
  36.         Id = "nMxM1syd",
  37.         Path = PROGDIR,
  38.         UsePasteLink = true,
  39.     },
  40.     {
  41.         Name = "Bore Blacklist [Junk Stone]",
  42.         FileName = "bore_blacklist_junkStone",
  43.         Id = "3dbkNt7w",
  44.         Path = PROGDIR,
  45.         UsePasteLink = false,
  46.     },
  47.     {
  48.         Name = "LabelColor - Disks",
  49.         FileName = "label_disk",
  50.         Id = "wNckUNcx",
  51.         Path = PROGDIR,
  52.         UsePasteLink = true,
  53.     },
  54.     {
  55.         Name = "LabelColor - Computer",
  56.         FileName = "label_computer",
  57.         Id = "LDm4Wp8M",
  58.         Path = PROGDIR,
  59.         UsePasteLink = true,
  60.     },
  61.     {
  62.         Name = "Lava Refuel",
  63.         FileName = "lava_refuel",
  64.         Id = "PJcTmbTp",
  65.         Path = PROGDIR,
  66.         UsePasteLink = true,
  67.     },
  68.     {
  69.         Name = "Lava Refuel - Idle",
  70.         FileName = "lava_refuel_idle",
  71.         Id = "CGescCnf",
  72.         Path = PROGDIR,
  73.         UsePasteLink = true,
  74.     },
  75. }
  76.  
  77. function makeFile(name, repoInd)
  78.     local fi = repo[repoInd]
  79.     local n = fi.Path..name..".lua"
  80.     if fs.exists(n) then shell.run("delete "..n); end
  81.     if fi.UsePasteLink then
  82.         local file = fs.open(n,"w")
  83.         file.write("shell.run(\"pastebin run "..repo[repoInd].Id.."\")")
  84.         file.close()
  85.     else
  86.         shell.run("pastebin get "..fi.Id.." "..fi.Path..fi.FileName..".lua")
  87.     end
  88.    
  89. end
  90.  
  91. function split(inputstr, sep)
  92.     if sep == nil then
  93.             sep = "%s"
  94.     end
  95.     local t={}
  96.     for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
  97.             table.insert(t, str)
  98.     end
  99.     return t
  100. end
  101.  
  102.  
  103. function Main()
  104.     coroutine.wrap(function()
  105.         local event, key, isHeld = os.pullEvent("key")
  106.         print(tostring(key))
  107.         if key == keys.up then
  108.             term.scroll(1)
  109.         elseif key == keys.down then
  110.             term.scroll(-1)
  111.         end
  112.         return
  113.     end)()
  114.     --makeFile("installer","Era6PJf4")
  115.     local installedOS = false
  116.     shell.run("clear")
  117.     print(SEPERATOR)
  118.     print("Installer ~")
  119.     print(SEPERATOR)
  120.     for i,paste in pairs(repo) do print(i..". "..paste.Name) end
  121.     print("\nInput files to download: (ex. 1 or 1 3 4, q to quit)\n")
  122.     local txt = io.read()
  123.     local input = split(txt)
  124.     for i,num in pairs(input) do
  125.         if num == "q" then shell.run("reboot") end
  126.         local paste = repo[tonumber(num)]
  127.         if tonumber(num) == 1 then installedOS = true end
  128.         makeFile(paste.FileName,tonumber(num))
  129.     end
  130.     shell.run("clear")
  131.     print(tostring(#input).." files downloaded...")
  132.     os.sleep(1)
  133.     if installedOS then
  134.         shell.run("OS/os.lua")
  135.     else
  136.         shell.run("reboot")
  137.     end
  138. end
  139.  
  140. Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement